(include "#.scm")

(check-same-behavior ("" "##" "~~lib/gambit/prim/number#.scm")

;; R4RS

(*) (* 2.) (* 12345678901234567890 4.) (* 1/5 6 7)
(+) (+ 1.) (+ 12345678901234567890 3.) (+ 4 1/5 6)
(- 1.) (- 12345678901234567890 3.) (- 4 1/5 6)
(/ 2.) (/ 12345678901234567890 4.) (/ 1/5 6 7)

(<) (< 1.) (< 1 2.) (< -0. 0) (< 2. 1/2) (< 1. 2. 3.) (< 1. 1. 1.) (< 12345678901234567890 2. 1.)
(<=)(<= 1.)(<= 1 2.)(<= -0. 0)(<= 2. 1/2)(<= 1. 2. 3.)(<= 1. 1. 1.)(<= 12345678901234567890 2. 1.)
(=) (= 1.) (= 1 2.) (= -0. 0) (= 2. 1/2) (= 1. 2. 3.) (= 1. 1. 1.) (= 12345678901234567890 2. 1.)
(>) (> 1.) (> 1 2.) (> -0. 0) (> 2. 1/2) (> 1. 2. 3.) (> 1. 1. 1.) (> 12345678901234567890 2. 1.)
(>=)(>= 1.)(>= 1 2.)(>= -0. 0)(>= 2. 1/2)(>= 1. 2. 3.)(>= 1. 1. 1.)(>= 12345678901234567890 2. 1.)

(abs -42) (abs 42.) (abs 12345678901234567890) (abs -1/2)
(acos .5) (acos 1/2)
(angle 1+2i)
(asin .5) (asin 1/2)
(atan .5) (atan 1. 2.) (atan 1/2) (atan 1 2)

(ceiling -15/10)(ceiling -1.1)(ceiling -1)(ceiling -.9)(ceiling -1/2)
(ceiling -0.)(ceiling 0.)
(ceiling 1/2)(ceiling .9)(ceiling 12345678901234567890)(ceiling 1.1)(ceiling 1.5)

(complex? 'a) (complex? 1) (complex? 12345678901234567890) (complex? 2.) (complex? 1/2) (complex? 1+2i)
(cos 2.) (cos 2)
(denominator 2/3)
(even? -1) (even? 0.) (even? 12345678901234567890)
(exact->inexact 1/10)
(exact? -.5) (exact? 0) (exact? 12345678901234567890) (exact? +inf.0) (exact? +nan.0)
(exp 2.) (exp 2)
(expt 1.5 10.) (expt 15/10 10)

(floor -15/10)(floor -1.1)(floor -1)(floor -.9)(floor -1/2)
(floor -0.)(floor 0.)
(floor 1/2)(floor .9)(floor 12345678901234567890)(floor 1.1)(floor 1.5)

(gcd) (gcd 5) (gcd 12 42) (gcd 12 42 10)
(imag-part 1+2i)
(inexact->exact 1.5)
(inexact? -.5) (inexact? 0) (inexact? 12345678901234567890) (inexact? +inf.0) (inexact? +nan.0)
(integer? -.5) (integer? 0) (integer? 12345678901234567890) (integer? +inf.0) (integer? +nan.0)
(lcm) (lcm 5) (lcm 12 42) (lcm 12 42 10)
(log 10.) (log 10) (log 10 2)
(magnitude 1+2i)
(make-polar 1. 0)
(make-rectangular 1. 2.)
(max 1) (max 1. 2) (max 2. 1/2) (max 1 12345678901234567890 2.) (max 2 4 1 3)
(min 1) (min 1. 2) (min 2. 1/2) (min 1 12345678901234567890 2.) (min 2 4 1 3)
(modulo 17 3) (modulo -17 -3) (modulo -17 3) (modulo 17 -3)
(negative? -1) (negative? -0.) (negative? 1/2) (negative? 12345678901234567890)
(number->string 123) (number->string 123 16)
(number? 'a) (number? 1) (number? 12345678901234567890) (number? 2.) (number? 1/2) (number? 1+2i)
(numerator 2/3)
(odd? -1) (odd? 0.) (odd? 12345678901234567890)
(positive? -1) (positive? -0.) (positive? 1/2) (positive? 12345678901234567890)
(quotient 17 3) (quotient -17 -3) (quotient -17 3) (quotient 17 -3)
(rational? 'a) (rational? 1) (rational? 12345678901234567890) (rational? 2.) (rational? 1/2) (rational? 1+2i)
(rationalize 0.3 1/4)
(real-part 1+2i)
(real? -.5) (real? 0) (real? 12345678901234567890) (real? +inf.0) (real? +nan.0)
(remainder 17 3) (remainder -17 -3) (remainder -17 3) (remainder 17 -3)

(round -15/10)(round -1.1)(round -1)(round -.9)(round -1/2)
(round -0.)(round 0.)
(round 1/2)(round .9)(round 12345678901234567890)(round 1.1)(round 1.5)

(sin 2.) (sin 2)
(sqrt 1.5) (sqrt 15/10)
(string->number "-42")
(tan 2.) (tan 2)

(truncate -15/10)(truncate -1.1)(truncate -1)(truncate -.9)(truncate -1/2)
(truncate -0.)(truncate 0.)
(truncate 1/2)(truncate .9)(truncate 12345678901234567890)(truncate 1.1)(truncate 1.5)

(zero? -1) (zero? -0.) (zero? 1/2) (zero? 12345678901234567890)

;; R7RS

(exact 1/10) (exact 1.5)
(##call-with-values (lambda () (exact-integer-sqrt 200)) ##list)
(exact-integer? 123) (exact-integer? 'a)
(finite? -0.) (finite? 1/2) (finite? 12345678901234567890) (finite? +inf.0) (finite? +nan.0)
(floor-quotient -50 7)
(floor-remainder -50 7)
(##call-with-values (lambda () (floor/ -50 7)) ##list)
(inexact 1/10) (inexact 1.5)
(infinite? -0.) (infinite? 1/2) (infinite? 12345678901234567890) (infinite? +inf.0) (infinite? +nan.0)
(nan? -0.) (nan? 1/2) (nan? 12345678901234567890) (nan? +inf.0) (nan? +nan.0)
(square 1.5) (square 15/10)
(truncate-quotient -50 7)
(truncate-remainder -50 7)
(##call-with-values (lambda () (truncate/ -50 7)) ##list)

;; Gambit

(acosh 1.5) (acosh 15/10)
(all-bits-set? 17 29) (all-bits-set? 17 15)
(any-bit-set? 17 29) (any-bit-set? 17 15)
(any-bits-set? 17 29) (any-bits-set? 17 15)
(arithmetic-shift 100 4) (arithmetic-shift 100 -4)
(asinh .5) (asinh 1/2)
(atanh .5) (atanh 1/2)
(balanced-quotient -50 7)
(balanced-remainder -50 7)
(##call-with-values (lambda () (balanced/ -50 7)) ##list)
(bit-count 0) (bit-count 1) (bit-count 2) (bit-count 3) (bit-count 12345)
(bit-field 179 1 6)
(bit-field-any? 179 1 6)
(bit-field-clear 179 1 6)
(bit-field-every? 179 1 6)
(bit-field-replace 1032 179 1 6)
(bit-field-replace-same 1032 179 1 6)
(bit-field-reverse 179 1 6)
(bit-field-rotate 179 2 1 6)
(bit-field-set 179 1 6)
(bit-set? 1 17) (bit-set? 4 17)
(bit-swap 1 6 179)
;;unimplemented;;(bits #f #t #t #f #t)
;;unimplemented;;(bits->list 19)
;;unimplemented;;(bits->vector 19)
(bitwise-and) (bitwise-and 6) (bitwise-and 6 10) (bitwise-and 6 10 67)
(bitwise-andc1 12 5)
(bitwise-andc2 12 5)
(bitwise-eqv) (bitwise-eqv 85) (bitwise-eqv 85 204) (bitwise-eqv 85 204 240)
(bitwise-fold list 'end 14)
(let ((r 'end)) (bitwise-for-each (lambda (x) (set! r (list x r))) 14) r)
(bitwise-if 3 1 8)
(bitwise-ior) (bitwise-ior 6) (bitwise-ior 6 10) (bitwise-ior 6 10 67)
(bitwise-merge 3 6 13)
(bitwise-nand 12 5)
(bitwise-nor 12 5)
(bitwise-not 0) (bitwise-not -1) (bitwise-not 10)
(bitwise-orc1 12 5)
(bitwise-orc2 12 5)
(bitwise-unfold (lambda (i) (= i 10)) even? (lambda (i) (+ i 1)) 0)
(bitwise-xor) (bitwise-xor 6) (bitwise-xor 6 10) (bitwise-xor 6 10 67)
(ceiling-quotient -50 7)
(ceiling-remainder -50 7)
(##call-with-values (lambda () (ceiling/ -50 7)) ##list)
(clear-bit-field 4 2 240)
(conjugate 0)
(copy-bit 2 15 #f)
(copy-bit-field 4 2 16 240)
(cosh .5) (cosh 1/2)
;;unimplemented;;default-random-source
(euclidean-quotient -50 7)
(euclidean-remainder -50 7)
(##call-with-values (lambda () (euclidean/ -50 7)) ##list)
(every-bit-set? 17 29) (every-bit-set? 17 15)
(extract-bit-field 4 2 240)
(first-set-bit 0) (first-set-bit 1) (first-set-bit 20)
(integer-length 0) (integer-length 10)
(integer-nth-root 1024 3)
(integer-sqrt 200)
;;unimplemented;;(list->bits '(#f #t #t #f #t))
(procedure? (make-bitwise-generator 13))

;;unimplemented;;(make-random-source)
;;unimplemented;;(random-f64vector 5)
;;unimplemented;;(random-integer 5)
;;unimplemented;;(random-real)
;;unimplemented;;(random-source-make-f64vectors default-random-source)
;;unimplemented;;(random-source-make-integers default-random-source)
;;unimplemented;;(random-source-make-reals default-random-source)
;;unimplemented;;(random-source-make-u8vectors default-random-source)
;;unimplemented;;(random-source-pseudo-randomize! default-random-source 0 0)
;;unimplemented;;(random-source-randomize! default-random-source)
;;unimplemented;;(random-source-state-ref default-random-source)
;;unimplemented;;(random-source-state-set! default-random-source (random-source-state-ref default-random-source))
;;unimplemented;;(random-source? default-random-source)
;;unimplemented;;(random-u8vector 5)

(replace-bit-field 4 2 1 240)
(round-quotient -50 7)
(round-remainder -50 7)
(##call-with-values (lambda () (round/ -50 7)) ##list)
(sinh .5) (sinh 1/2)
(tanh .5) (tanh 1/2)
(test-bit-field? 4 2 240) (test-bit-field? 1 2 240)
;;unimplemented;;(vector->bits '#(#f #t #t #f #t))

)
