From a48e29d55740dc2c4daa07fbfeea29b5d60adc80 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 16 Nov 2018 16:57:59 +0000 Subject: [PATCH] Add tests for integer?. It incorrectly reports infinities as integers, so xfail. --- tests/runtime/test-arith.scm | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) 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 -- 2.25.1