annotate src/clojure/test_clojure/java/shell.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 (ns clojure.test-clojure.java.shell
rlm@10 10 (:use clojure.test
rlm@10 11 [clojure.java.shell :as sh])
rlm@10 12 (:import (java.io File)))
rlm@10 13
rlm@10 14 (def platform-enc (.name (java.nio.charset.Charset/defaultCharset)))
rlm@10 15 (def default-enc "UTF-8")
rlm@10 16
rlm@10 17 (deftest test-parse-args
rlm@10 18 (are [x y] (= x y)
rlm@10 19 [[] {:in-enc default-enc :out-enc default-enc :dir nil :env nil}] (#'sh/parse-args [])
rlm@10 20 [["ls"] {:in-enc default-enc :out-enc default-enc :dir nil :env nil}] (#'sh/parse-args ["ls"])
rlm@10 21 [["ls" "-l"] {:in-enc default-enc :out-enc default-enc :dir nil :env nil}] (#'sh/parse-args ["ls" "-l"])
rlm@10 22 [["ls"] {:in-enc default-enc :out-enc "ISO-8859-1" :dir nil :env nil}] (#'sh/parse-args ["ls" :out-enc "ISO-8859-1"])
rlm@10 23 [[] {:in-enc platform-enc :out-enc platform-enc :dir nil :env nil}] (#'sh/parse-args [:in-enc platform-enc :out-enc platform-enc])))
rlm@10 24
rlm@10 25 (deftest test-with-sh-dir
rlm@10 26 (are [x y] (= x y)
rlm@10 27 nil *sh-dir*
rlm@10 28 "foo" (with-sh-dir "foo" *sh-dir*)))
rlm@10 29
rlm@10 30 (deftest test-with-sh-env
rlm@10 31 (are [x y] (= x y)
rlm@10 32 nil *sh-env*
rlm@10 33 {:KEY "VAL"} (with-sh-env {:KEY "VAL"} *sh-env*)))
rlm@10 34
rlm@10 35 (deftest test-as-env-strings
rlm@10 36 (are [x y] (= x y)
rlm@10 37 nil (#'sh/as-env-strings nil)
rlm@10 38 ["FOO=BAR"] (seq (#'sh/as-env-strings {"FOO" "BAR"}))
rlm@10 39 ["FOO_SYMBOL=BAR"] (seq (#'sh/as-env-strings {'FOO_SYMBOL "BAR"}))
rlm@10 40 ["FOO_KEYWORD=BAR"] (seq (#'sh/as-env-strings {:FOO_KEYWORD "BAR"}))))
rlm@10 41