rlm@10: ; Copyright (c) Rich Hickey. All rights reserved. rlm@10: ; The use and distribution terms for this software are covered by the rlm@10: ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) rlm@10: ; which can be found in the file epl-v10.html at the root of this distribution. rlm@10: ; By using this software in any fashion, you are agreeing to be bound by rlm@10: ; the terms of this license. rlm@10: ; You must not remove this notice, or any other, from this software. rlm@10: rlm@10: ; Author: Frantisek Sodomka, Stephen C. Gilardi rlm@10: rlm@10: rlm@10: (ns clojure.test-clojure.vars rlm@10: (:use clojure.test)) rlm@10: rlm@10: ; http://clojure.org/vars rlm@10: rlm@10: ; def rlm@10: ; defn defn- defonce rlm@10: rlm@10: ; declare intern binding find-var var rlm@10: rlm@10: (def a) rlm@10: (deftest test-binding rlm@10: (are [x y] (= x y) rlm@10: (eval `(binding [a 4] a)) 4 ; regression in Clojure SVN r1370 rlm@10: )) rlm@10: rlm@10: ; with-local-vars var-get var-set alter-var-root [var? (predicates.clj)] rlm@10: ; with-in-str with-out-str rlm@10: ; with-open rlm@10: ; with-precision rlm@10: rlm@10: (deftest test-with-precision rlm@10: (are [x y] (= x y) rlm@10: (with-precision 4 (+ 3.5555555M 1)) 4.556M rlm@10: (with-precision 6 (+ 3.5555555M 1)) 4.55556M rlm@10: (with-precision 6 :rounding CEILING (+ 3.5555555M 1)) 4.55556M rlm@10: (with-precision 6 :rounding FLOOR (+ 3.5555555M 1)) 4.55555M rlm@10: (with-precision 6 :rounding HALF_UP (+ 3.5555555M 1)) 4.55556M rlm@10: (with-precision 6 :rounding HALF_DOWN (+ 3.5555555M 1)) 4.55556M rlm@10: (with-precision 6 :rounding HALF_EVEN (+ 3.5555555M 1)) 4.55556M rlm@10: (with-precision 6 :rounding UP (+ 3.5555555M 1)) 4.55556M rlm@10: (with-precision 6 :rounding DOWN (+ 3.5555555M 1)) 4.55555M rlm@10: (with-precision 6 :rounding UNNECESSARY (+ 3.5555M 1)) 4.5555M)) rlm@10: rlm@10: (deftest test-settable-math-context rlm@10: (is (= rlm@10: (clojure.main/with-bindings rlm@10: (set! *math-context* (java.math.MathContext. 8)) rlm@10: (+ 3.55555555555555M 1)) rlm@10: 4.5555556M))) rlm@10: rlm@10: ; set-validator get-validator rlm@10: rlm@10: ; doc find-doc test rlm@10: