Fix tests of markers to periods conversion.
This commit is contained in:
parent
700dd7cfd3
commit
0d127e7200
1 changed files with 4 additions and 7 deletions
11
period.scm
11
period.scm
|
@ -61,18 +61,15 @@
|
|||
;; Converts list of start/stop markers to list of pairs of months -
|
||||
;; periods.
|
||||
(define (period-markers->periods l)
|
||||
(print "===")
|
||||
(let loop ((l l)
|
||||
(ps '())
|
||||
(cb #f))
|
||||
(print l)
|
||||
(if (null? l)
|
||||
(if cb
|
||||
(reverse (cons (cons cb #f) ps))
|
||||
(reverse ps))
|
||||
(let ((m (car l))
|
||||
(rmt (if cb 'stop 'start)))
|
||||
(print " m: " m)
|
||||
(if (eq? (car m) rmt)
|
||||
(if cb
|
||||
(loop (cdr l)
|
||||
|
@ -151,16 +148,16 @@
|
|||
(run-tests
|
||||
period
|
||||
(test-equal? sort-period-markers
|
||||
(sort-period-markers '((start 2023 1) (stop 2022 10) (start 2022 3)))
|
||||
'((start 2022 3) (stop 2022 10) (start 2023 1)))
|
||||
(sort-period-markers '((start (2023 1)) (stop (2022 10)) (start (2022 3))))
|
||||
'((start (2022 3)) (stop (2022 10)) (start (2023 1))))
|
||||
(test-equal? period-markers->periods
|
||||
(period-markers->periods
|
||||
'((start 2022 3) (stop 2022 10) (start 2023 1) (stop 2023 4)))
|
||||
'((start (2022 3)) (stop (2022 10)) (start (2023 1)) (stop (2023 4))))
|
||||
'(((2022 3) . (2022 10))
|
||||
((2023 1) . (2023 4))))
|
||||
(test-equal? period-markers->periods-open
|
||||
(period-markers->periods
|
||||
'((start 2022 3) (stop 2022 10) (start 2023 1) (stop 2023 4) (start 2023 5)))
|
||||
'((start (2022 3)) (stop (2022 10)) (start (2023 1)) (stop (2023 4)) (start (2023 5))))
|
||||
'(((2022 3) . (2022 10))
|
||||
((2023 1) . (2023 4))
|
||||
((2023 5) . #f)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue