diff options
author | Marius Vollmer <mvo@zagadka.de> | 2003-11-19 05:15:51 +0000 |
---|---|---|
committer | Marius Vollmer <mvo@zagadka.de> | 2003-11-19 05:15:51 +0000 |
commit | c1f1071afcd05c132ba0bfa849632df135c483b9 (patch) | |
tree | a4bac56e750cef0e4572e4bb36ae93c2fd86652b /test-suite/tests/fractions.test | |
parent | fb16d26e2330e49b5afacaaff029b53bd1c64775 (diff) | |
download | guile-c1f1071afcd05c132ba0bfa849632df135c483b9.tar.gz |
Changed to reflect the fact that rationalize only returns an exact
result for exact arguments. Fixed bugs in tests that were not caught
previously since all fraction were treated as equal regardless of
value.
Diffstat (limited to 'test-suite/tests/fractions.test')
-rw-r--r-- | test-suite/tests/fractions.test | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/test-suite/tests/fractions.test b/test-suite/tests/fractions.test index 2e7e05e8c..90320f247 100644 --- a/test-suite/tests/fractions.test +++ b/test-suite/tests/fractions.test @@ -124,30 +124,26 @@ (testeqv (abs 101/17452826108659293487) 101/17452826108659293487) (testeqv (abs -101/17452826108659293487) 101/17452826108659293487) (testeqv (exact->inexact 3/4) .75) - (testeqv (inexact->exact .3) 3/10) - (testeqv (inexact->exact -.3) -3/10) - (testeqv (inexact->exact .33) 33/10) - (testeq (< (- (exact->inexact 10197734562406803221/17452826108659293487) .584302765576009) .0000001) #t) - (testeqv (rationalize .76 .1) 3/4) - (testeqv (rationalize .723 .1) 2/3) - (testeqv (rationalize .723 .01) 5/7) - (testeqv (rationalize -.723 .01) -5/7) - (testeqv (rationalize 10.2 .01) 51/5) - (testeqv (rationalize -10.2 .01) -51/5) - (testeqv (rationalize 10197734562406803221/17452826108659293487 .1) 1/2) - (testeqv (rationalize 10197734562406803221/17452826108659293487 .01) 7/12) - (testeqv (rationalize 10197734562406803221/17452826108659293487 .001) 7/12) - (testeqv (rationalize 10197734562406803221/17452826108659293487 .0001) 52/89) + (testeqv (inexact->exact .5) 1/2) + (testeqv (inexact->exact -.5) -1/2) + (testeqv (inexact->exact (exact->inexact 2135445/16777216)) 2135445/16777216) + (testeq (< (- (exact->inexact 10197734562406803221/17452826108659293487) + .584302765576009) .0000001) #t) + (testeqv (rationalize #e0.76 1/10) 3/4) + (testeqv (rationalize #e0.723 1/10) 2/3) + (testeqv (rationalize #e0.723 1/100) 5/7) + (testeqv (rationalize #e-0.723 1/100) -5/7) + (testeqv (rationalize #e10.2 1/100) 51/5) + (testeqv (rationalize #e-10.2 1/100) -51/5) + (testeqv (rationalize 10197734562406803221/17452826108659293487 1/10) 1/2) + (testeqv (rationalize 10197734562406803221/17452826108659293487 1/100) 7/12) + (testeqv (rationalize 10197734562406803221/17452826108659293487 1/1000) 7/12) + (testeqv (rationalize 10197734562406803221/17452826108659293487 1/10000) 52/89) (testeqv (rationalize 3/10 1/10) 1/3) (testeqv (rationalize 3/10 -1/10) 1/3) (testeqv (rationalize -3/10 1/10) -1/3) (testeqv (rationalize -3/10 -1/10) -1/3) (testeqv (rationalize 3/10 4/10) 0) - (testeqv (rationalize .3 4/10) 0) - (testeqv (rationalize .3 0.0) 3/10) - (testeqv (rationalize -.3 0.0) -3/10) - (testeqv (rationalize .12345 0.0) 2469/2000) - (testeqv (rationalize 10.3 0.0) 103/10) (testeq (exact? #i2/3) #f) (testeq (exact? -15/16) #t) (testeq (exact? (/ 2 3)) #t) @@ -178,7 +174,7 @@ (testeqv (+ 1 1/4 1/3) 19/12) (testeqv (* 3/5 1/6 3) 3/10) (testeqv 0/3 0) - (testeqv (1- 1/2) 1/2) + (testeqv (1- 1/2) -1/2) (testeqv (1+ 1/2) 3/2) (testeq (zero? 3/4) #f) (testeq (zero? 0/4) #t) @@ -217,7 +213,7 @@ (testeqv (min 1/2 3/4 4/5 5/6 6/7) 1/2) (testeqv (expt -1/2 5) -1/32) (testeqv (expt 1/2 -10) 1024) - (testeqv (rationalize .3 1/10) 1/3) + (testeqv (rationalize #e.3 1/10) 1/3) (test= (make-rectangular 1/2 -1/2) 0.5-0.5i) (test= (sqrt 1/4) 0.5) (testeqv (string->number "3/4") 3/4) @@ -335,9 +331,9 @@ (testeq (let ((error (catch #t (lambda () (gcd 1/2 3)) (lambda args (car args))))) error) 'wrong-type-arg) (testeq (let ((error (catch #t (lambda () (numerator 1+i)) (lambda args (car args))))) error) 'wrong-type-arg) (test= (- 0+6i 1/4 0.5 7) -7.75+6.0i) - (testeqv (rationalize 2.5 .001) 5/2) - (testeqv (rationalize 7/3 .001) 7/3) - (testeqv (rationalize 3.14159265 .1) 22/7) + (testeqv (rationalize #e2.5 1/1000) 5/2) + (testeqv (rationalize 7/3 1/1000) 7/3) + (testeqv (rationalize #e3.14159265 1/10) 22/7) (testeqv (numerator (/ 8 -6)) -4) (testeqv (denominator (/ 8 -6)) 3) (testeqv (gcd (numerator 7/9) (denominator 7/9)) 1) |