fix in-inclusive-range when last bound is not an explicit number

This commit is contained in:
Gustavo Massaccesi 2021-05-19 11:00:39 -03:00
parent f2933d5ab8
commit aa7a5b9509
2 changed files with 9 additions and 0 deletions

View File

@ -16,16 +16,24 @@
(if 64-bit? (- (expt 2 60) 1) +536870911) (if 64-bit? (- (expt 2 60) 1) +536870911)
(if 64-bit? (- (expt 2 62) 1) +1073741823))) (if 64-bit? (- (expt 2 62) 1) +1073741823)))
(define (five) 5)
(test-sequence [(0 1 2)] 3) (test-sequence [(0 1 2)] 3)
(test-sequence [(0 1 2)] (in-range 3)) (test-sequence [(0 1 2)] (in-range 3))
(test-sequence [(3 4 5)] (in-range 3 6)) (test-sequence [(3 4 5)] (in-range 3 6))
(test-sequence [(7 6 5)] (in-range 7 4 -1)) (test-sequence [(7 6 5)] (in-range 7 4 -1))
(test-sequence [(5 6)] (in-range (five) 7))
(test-sequence [(3 4)] (in-range 3 (five)))
(test-sequence [(0 5)] (in-range 0 10 (five)))
(test-sequence [(3.0 4.0 5.0)] (in-range 3.0 6.0)) (test-sequence [(3.0 4.0 5.0)] (in-range 3.0 6.0))
(test-sequence [(3.0 3.5 4.0 4.5 5.0 5.5)] (in-range 3.0 6.0 0.5)) (test-sequence [(3.0 3.5 4.0 4.5 5.0 5.5)] (in-range 3.0 6.0 0.5))
(test-sequence [(3.0 3.1 3.2)] (in-range 3.0 3.3 0.1)) (test-sequence [(3.0 3.1 3.2)] (in-range 3.0 3.3 0.1))
(test-sequence [(6 7)] (in-inclusive-range 6 7)) (test-sequence [(6 7)] (in-inclusive-range 6 7))
(test-sequence [(3 4 5 6)] (in-inclusive-range 3 6)) (test-sequence [(3 4 5 6)] (in-inclusive-range 3 6))
(test-sequence [(7 6 5 4)] (in-inclusive-range 7 4 -1)) (test-sequence [(7 6 5 4)] (in-inclusive-range 7 4 -1))
(test-sequence [(5 6 7)] (in-inclusive-range (five) 7))
(test-sequence [(3 4 5)] (in-inclusive-range 3 (five)))
(test-sequence [(0 5 10)] (in-inclusive-range 0 10 (five)))
(test-sequence [(3.0 4.0 5.0 6.0)] (in-inclusive-range 3.0 6.0)) (test-sequence [(3.0 4.0 5.0 6.0)] (in-inclusive-range 3.0 6.0))
(test-sequence [(3.0 3.5 4.0 4.5 5.0 5.5 6.0)] (in-inclusive-range 3.0 6.0 0.5)) (test-sequence [(3.0 3.5 4.0 4.5 5.0 5.5 6.0)] (in-inclusive-range 3.0 6.0 0.5))
(test-sequence [(#e3.0 #e3.1 #e3.2 #e3.3)] (in-inclusive-range #e3.0 #e3.3 #e0.1)) (test-sequence [(#e3.0 #e3.1 #e3.2 #e3.3)] (in-inclusive-range #e3.0 #e3.3 #e0.1))

View File

@ -2178,6 +2178,7 @@
#'id #'a #'b #'step #'id #'a #'b #'step
(and (memq (syntax-e #'step) '(1 -1)) (and (memq (syntax-e #'step) '(1 -1))
(fixnum? (syntax-e #'a)) (fixnum? (syntax-e #'a))
(fixnum? (syntax-e #'b))
(fixnum? ((if (eq? (syntax-e #'step) 1) add1 sub1) (fixnum? ((if (eq? (syntax-e #'step) 1) add1 sub1)
(syntax-e #'b)))) (syntax-e #'b))))
#'(check-range-generic 'in-inclusive-range) #'(check-range-generic 'in-inclusive-range)