summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorStephen C. Gilardi <squeegee@squeegee-mbp.scgilardi.selfip.net>2009-06-30 13:00:04 -0400
committerChouser <chouser@n01se.net>2009-07-09 23:21:37 -0400
commitab7947e68a5b435f243790e197cfdb781d47986f (patch)
tree62171ddf2c21bf5532e41cbfcd172d29d22ca599 /test
parenta1397390d8b3b63f2039359520629d87b152d717 (diff)
Refs #137: make *math-context* settable, with test + tests of with-precision
Signed-off-by: Chouser <chouser@n01se.net>
Diffstat (limited to 'test')
-rw-r--r--test/clojure/test_clojure/vars.clj21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/clojure/test_clojure/vars.clj b/test/clojure/test_clojure/vars.clj
index 12e8a60c..540495f3 100644
--- a/test/clojure/test_clojure/vars.clj
+++ b/test/clojure/test_clojure/vars.clj
@@ -21,10 +21,29 @@
(def a)
(deftest test-binding
- (are (= _1 _2)
+ (are [_1 _2] (= _1 _2)
(eval `(binding [a 4] a)) 4 ; regression in Clojure SVN r1370
))
+(deftest test-with-precision
+ (are [x y] (= x y)
+ (with-precision 4 (+ 3.5555555M 1)) 4.556M
+ (with-precision 6 (+ 3.5555555M 1)) 4.55556M
+ (with-precision 6 :rounding CEILING (+ 3.5555555M 1)) 4.55556M
+ (with-precision 6 :rounding FLOOR (+ 3.5555555M 1)) 4.55555M
+ (with-precision 6 :rounding HALF_UP (+ 3.5555555M 1)) 4.55556M
+ (with-precision 6 :rounding HALF_DOWN (+ 3.5555555M 1)) 4.55556M
+ (with-precision 6 :rounding HALF_EVEN (+ 3.5555555M 1)) 4.55556M
+ (with-precision 6 :rounding UP (+ 3.5555555M 1)) 4.55556M
+ (with-precision 6 :rounding DOWN (+ 3.5555555M 1)) 4.55555M
+ (with-precision 6 :rounding UNNECESSARY (+ 3.5555M 1)) 4.5555M))
+
+(deftest test-settable-math-context
+ (is (=
+ (clojure.main/with-bindings
+ (set! *math-context* (java.math.MathContext. 8))
+ (+ 3.55555555555555M 1))
+ 4.5555556M)))
; with-local-vars var-get var-set alter-var-root [var? (predicates.clj)]
; with-in-str with-out-str