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 -
|
;; Converts list of start/stop markers to list of pairs of months -
|
||||||
;; periods.
|
;; periods.
|
||||||
(define (period-markers->periods l)
|
(define (period-markers->periods l)
|
||||||
(print "===")
|
|
||||||
(let loop ((l l)
|
(let loop ((l l)
|
||||||
(ps '())
|
(ps '())
|
||||||
(cb #f))
|
(cb #f))
|
||||||
(print l)
|
|
||||||
(if (null? l)
|
(if (null? l)
|
||||||
(if cb
|
(if cb
|
||||||
(reverse (cons (cons cb #f) ps))
|
(reverse (cons (cons cb #f) ps))
|
||||||
(reverse ps))
|
(reverse ps))
|
||||||
(let ((m (car l))
|
(let ((m (car l))
|
||||||
(rmt (if cb 'stop 'start)))
|
(rmt (if cb 'stop 'start)))
|
||||||
(print " m: " m)
|
|
||||||
(if (eq? (car m) rmt)
|
(if (eq? (car m) rmt)
|
||||||
(if cb
|
(if cb
|
||||||
(loop (cdr l)
|
(loop (cdr l)
|
||||||
|
@ -151,16 +148,16 @@
|
||||||
(run-tests
|
(run-tests
|
||||||
period
|
period
|
||||||
(test-equal? sort-period-markers
|
(test-equal? sort-period-markers
|
||||||
(sort-period-markers '((start 2023 1) (stop 2022 10) (start 2022 3)))
|
(sort-period-markers '((start (2023 1)) (stop (2022 10)) (start (2022 3))))
|
||||||
'((start 2022 3) (stop 2022 10) (start 2023 1)))
|
'((start (2022 3)) (stop (2022 10)) (start (2023 1))))
|
||||||
(test-equal? period-markers->periods
|
(test-equal? period-markers->periods
|
||||||
(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))
|
'(((2022 3) . (2022 10))
|
||||||
((2023 1) . (2023 4))))
|
((2023 1) . (2023 4))))
|
||||||
(test-equal? period-markers->periods-open
|
(test-equal? period-markers->periods-open
|
||||||
(period-markers->periods
|
(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))
|
'(((2022 3) . (2022 10))
|
||||||
((2023 1) . (2023 4))
|
((2023 1) . (2023 4))
|
||||||
((2023 5) . #f)))
|
((2023 5) . #f)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue