;;;; number-limits-test.scm -*- Scheme -*- ;;;; Kon Lovett, Mar '20 ;;;; Kon Lovett, Jul '18 (import test) (import (test-utils gloss) (only (chicken format) format)) ;; (test-begin "Number Limits") (import number-limits) ;;; (import (chicken fixnum) (chicken flonum)) (gloss "** long long" (if (positive? long-long-size) "supported" "unsupported") "**") (gloss "** unsigned long long" (if (positive? unsigned-long-long-size) "supported" "unsupported") "**") #; (gloss "** long double" (if (fp= maximum-long-double maximum-long-double) "supported" "unsupported") "**") (gloss " machine-word-bits:" machine-word-bits) (gloss " machine-word-precision:" machine-word-precision) (gloss "maximum-unsigned-machine-word:" maximum-unsigned-machine-word) (gloss " most-negative-machine-word:" most-negative-machine-word) (gloss " most-positive-machine-word:" most-positive-machine-word) (gloss " unsigned-integer32-size:" unsigned-integer32-size) (gloss " maximum-unsigned-integer32:" maximum-unsigned-integer32) (gloss " most-negative-integer32:" most-negative-integer32) (gloss " most-positive-integer32:" most-positive-integer32) (gloss " unsigned-integer64-size:" unsigned-integer64-size) (gloss " maximum-unsigned-integer64:" maximum-unsigned-integer64) (gloss " most-negative-integer64:" most-negative-integer64) (gloss " most-positive-integer64:" most-positive-integer64) (gloss " most-negative-long:" most-negative-long) (gloss " most-positive-long:" most-positive-long) (gloss " most-negative-fixnum:" most-negative-fixnum) (gloss " most-positive-fixnum:" most-positive-fixnum) (gloss " char-size:" char-size) (gloss " unsigned-char-size:" unsigned-char-size) (gloss " short-size:" short-size) (gloss " unsigned-short-size:" unsigned-short-size) (gloss " long-size:" long-size) (gloss " unsigned-long-size:" unsigned-long-size) (gloss " long-long-size:" long-long-size) (gloss " unsigned-long-long-size:" unsigned-long-long-size) (test-assert (fx= float-radix flonum-radix)) (test-assert (fp= maximum-double maximum-flonum)) (test-assert (fp= minimum-double minimum-flonum)) (cond-expand (64bit (test-assert (= most-positive-integer64 (+ (* 2 most-positive-fixnum) 1))) (test-assert (= most-negative-integer64 (* 2 most-negative-fixnum))) ) (else (test-assert (= most-positive-integer32 (+ (* 2 most-positive-fixnum) 1))) (test-assert (= most-negative-integer32 (* 2 most-negative-fixnum))) ) ) (test-assert (= (- most-negative-machine-word) (- 0 most-negative-machine-word))) (test-assert (= most-positive-machine-word (- (- most-negative-machine-word) 1))) (test-assert (= most-positive-fixnum (- (- most-negative-fixnum) 1))) (test-assert (= most-positive-machine-word (+ most-positive-fixnum (- most-negative-fixnum)))) (test-assert (= (- most-negative-fixnum) (- 0 most-negative-fixnum))) (test-end "Number Limits") (test-exit)