annotate src/clojure/test_clojure/vars.clj @ 10:ef7dbbd6452c

added clojure source goodness
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Aug 2010 06:25:44 -0400
parents
children
rev   line source
rlm@10 1 ; Copyright (c) Rich Hickey. All rights reserved.
rlm@10 2 ; The use and distribution terms for this software are covered by the
rlm@10 3 ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
rlm@10 4 ; which can be found in the file epl-v10.html at the root of this distribution.
rlm@10 5 ; By using this software in any fashion, you are agreeing to be bound by
rlm@10 6 ; the terms of this license.
rlm@10 7 ; You must not remove this notice, or any other, from this software.
rlm@10 8
rlm@10 9 ; Author: Frantisek Sodomka, Stephen C. Gilardi
rlm@10 10
rlm@10 11
rlm@10 12 (ns clojure.test-clojure.vars
rlm@10 13 (:use clojure.test))
rlm@10 14
rlm@10 15 ; http://clojure.org/vars
rlm@10 16
rlm@10 17 ; def
rlm@10 18 ; defn defn- defonce
rlm@10 19
rlm@10 20 ; declare intern binding find-var var
rlm@10 21
rlm@10 22 (def a)
rlm@10 23 (deftest test-binding
rlm@10 24 (are [x y] (= x y)
rlm@10 25 (eval `(binding [a 4] a)) 4 ; regression in Clojure SVN r1370
rlm@10 26 ))
rlm@10 27
rlm@10 28 ; with-local-vars var-get var-set alter-var-root [var? (predicates.clj)]
rlm@10 29 ; with-in-str with-out-str
rlm@10 30 ; with-open
rlm@10 31 ; with-precision
rlm@10 32
rlm@10 33 (deftest test-with-precision
rlm@10 34 (are [x y] (= x y)
rlm@10 35 (with-precision 4 (+ 3.5555555M 1)) 4.556M
rlm@10 36 (with-precision 6 (+ 3.5555555M 1)) 4.55556M
rlm@10 37 (with-precision 6 :rounding CEILING (+ 3.5555555M 1)) 4.55556M
rlm@10 38 (with-precision 6 :rounding FLOOR (+ 3.5555555M 1)) 4.55555M
rlm@10 39 (with-precision 6 :rounding HALF_UP (+ 3.5555555M 1)) 4.55556M
rlm@10 40 (with-precision 6 :rounding HALF_DOWN (+ 3.5555555M 1)) 4.55556M
rlm@10 41 (with-precision 6 :rounding HALF_EVEN (+ 3.5555555M 1)) 4.55556M
rlm@10 42 (with-precision 6 :rounding UP (+ 3.5555555M 1)) 4.55556M
rlm@10 43 (with-precision 6 :rounding DOWN (+ 3.5555555M 1)) 4.55555M
rlm@10 44 (with-precision 6 :rounding UNNECESSARY (+ 3.5555M 1)) 4.5555M))
rlm@10 45
rlm@10 46 (deftest test-settable-math-context
rlm@10 47 (is (=
rlm@10 48 (clojure.main/with-bindings
rlm@10 49 (set! *math-context* (java.math.MathContext. 8))
rlm@10 50 (+ 3.55555555555555M 1))
rlm@10 51 4.5555556M)))
rlm@10 52
rlm@10 53 ; set-validator get-validator
rlm@10 54
rlm@10 55 ; doc find-doc test
rlm@10 56