improve contract0stronger? for between/c vs integer-in

This commit is contained in:
Robby Findler 2020-08-18 14:28:26 -05:00
parent 7d8a95a943
commit afb68b29d4
2 changed files with 13 additions and 0 deletions

View File

@ -68,6 +68,13 @@
(ctest #t trust/not-stronger? (integer-in 0 #f) (and/c exact-nonnegative-integer? (>=/c -4)))
(ctest #t trust/not-stronger? (and/c exact-nonnegative-integer? (>=/c -4)) (integer-in 0 #f))
(ctest #t trust/not-stronger? (integer-in -1 10) (between/c -1 10))
(ctest #t trust/not-stronger? (integer-in 2 10) (between/c -1 10))
(ctest #t trust/not-stronger? (integer-in -1 6) (between/c -1 10))
(ctest #f trust/not-stronger? (integer-in -1 11) (between/c -1 10))
(ctest #t trust/not-stronger? (integer-in -1 10) real?)
(ctest #t trust/not-stronger? exact-integer? real?)
(ctest #t trust/not-stronger? #\a (char-in #\a #\c))
(ctest #f trust/not-stronger? #\a (char-in #\b #\c))
(ctest #t trust/not-stronger? (char-in #\f #\q) (char-in #\a #\z))

View File

@ -322,6 +322,12 @@
(define that-start (or (integer-in-ctc-start that) -inf.0))
(define that-end (or (integer-in-ctc-end that) +inf.0))
(<= that-start this-start this-end that-end)]
[(between/c-s? that)
(define that-low (between/c-s-low that))
(define that-high (between/c-s-high that))
(define this-start (or (integer-in-ctc-start this) -inf.0))
(define this-end (or (integer-in-ctc-end this) +inf.0))
(<= that-low this-start this-end that-high)]
[else #f]))
(define (integer-in-equivalent this that)