diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/clojure/test_clojure/vars.clj	Sat Aug 21 06:25:44 2010 -0400
     1.3 @@ -0,0 +1,56 @@
     1.4 +;   Copyright (c) Rich Hickey. All rights reserved.
     1.5 +;   The use and distribution terms for this software are covered by the
     1.6 +;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
     1.7 +;   which can be found in the file epl-v10.html at the root of this distribution.
     1.8 +;   By using this software in any fashion, you are agreeing to be bound by
     1.9 +;   the terms of this license.
    1.10 +;   You must not remove this notice, or any other, from this software.
    1.11 +
    1.12 +; Author: Frantisek Sodomka, Stephen C. Gilardi
    1.13 +
    1.14 +
    1.15 +(ns clojure.test-clojure.vars
    1.16 +  (:use clojure.test))
    1.17 +
    1.18 +; http://clojure.org/vars
    1.19 +
    1.20 +; def
    1.21 +; defn defn- defonce
    1.22 +
    1.23 +; declare intern binding find-var var
    1.24 +
    1.25 +(def a)
    1.26 +(deftest test-binding
    1.27 +  (are [x y] (= x y)
    1.28 +      (eval `(binding [a 4] a)) 4     ; regression in Clojure SVN r1370
    1.29 +  ))
    1.30 +
    1.31 +; with-local-vars var-get var-set alter-var-root [var? (predicates.clj)]
    1.32 +; with-in-str with-out-str
    1.33 +; with-open
    1.34 +; with-precision
    1.35 +
    1.36 +(deftest test-with-precision
    1.37 +  (are [x y] (= x y)
    1.38 +       (with-precision 4 (+ 3.5555555M 1)) 4.556M
    1.39 +       (with-precision 6 (+ 3.5555555M 1)) 4.55556M
    1.40 +       (with-precision 6 :rounding CEILING     (+ 3.5555555M 1)) 4.55556M
    1.41 +       (with-precision 6 :rounding FLOOR       (+ 3.5555555M 1)) 4.55555M
    1.42 +       (with-precision 6 :rounding HALF_UP     (+ 3.5555555M 1)) 4.55556M
    1.43 +       (with-precision 6 :rounding HALF_DOWN   (+ 3.5555555M 1)) 4.55556M
    1.44 +       (with-precision 6 :rounding HALF_EVEN   (+ 3.5555555M 1)) 4.55556M
    1.45 +       (with-precision 6 :rounding UP          (+ 3.5555555M 1)) 4.55556M
    1.46 +       (with-precision 6 :rounding DOWN        (+ 3.5555555M 1)) 4.55555M
    1.47 +       (with-precision 6 :rounding UNNECESSARY (+ 3.5555M 1))    4.5555M))
    1.48 +
    1.49 +(deftest test-settable-math-context
    1.50 +  (is (=
    1.51 +       (clojure.main/with-bindings
    1.52 +         (set! *math-context* (java.math.MathContext. 8))
    1.53 +         (+ 3.55555555555555M 1))
    1.54 +       4.5555556M)))
    1.55 +
    1.56 +; set-validator get-validator
    1.57 +
    1.58 +; doc find-doc test
    1.59 +