From: Taylor R Campbell Date: Fri, 16 Nov 2018 16:57:59 +0000 (+0000) Subject: Add tests for integer?. X-Git-Tag: mit-scheme-pucked-10.1.2~16^2~69 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=a48e29d55740dc2c4daa07fbfeea29b5d60adc80;p=mit-scheme.git Add tests for integer?. It incorrectly reports infinities as integers, so xfail. --- diff --git a/tests/runtime/test-arith.scm b/tests/runtime/test-arith.scm index 8f60ea75f..f4177ec9d 100644 --- a/tests/runtime/test-arith.scm +++ b/tests/runtime/test-arith.scm @@ -32,6 +32,15 @@ USA. (assert-true (flo:flonum? object)) (assert-true (flo:nan? object))) +(define (not-integer? x) + (not (integer? x))) + +(define assert-integer + (predicate-assertion integer? "integer")) + +(define assert-not-integer + (predicate-assertion not-integer? "not integer")) + (define (define-enumerated-test prefix elements procedure) (let ((n (vector-length elements))) (do ((i 0 (+ i 1))) ((>= i n)) @@ -375,4 +384,29 @@ USA. (let ((x (vector-ref v 0)) (y (vector-ref v 1))) (assert-eqv (- x) y) - (assert-eqv (- 0 (flo:copysign 1. x)) (flo:copysign 1. y))))) \ No newline at end of file + (assert-eqv (- 0 (flo:copysign 1. x)) (flo:copysign 1. y))))) + +(define-enumerated-test 'integer? + (vector + 0 + 1 + (* 1/2 (identity-procedure 2)) + 0. + 1. + 1.+0.i) + assert-integer) + +(define-enumerated-test 'not-integer? + (vector + 1/2 + 0.1 + 1+2i + (flo:nan.0)) + assert-not-integer) + +(define-enumerated-test 'not-integer?/broken + (vector + (flo:+inf.0) + (flo:-inf.0)) + (lambda (x) + (expect-failure (lambda () (assert-not-integer x))))) \ No newline at end of file