|
59 | 59 | :long-opt "--[no-]foo"}))) |
60 | 60 | (testing "throws AssertionError on unset :id, duplicate :short-opt or :long-opt, |
61 | 61 | multiple :default(-fn) entries per :id, or both :assoc-fn/:update-fn present" |
62 | | - (is (thrown? #?(:clj AssertionError :cljs :default) |
| 62 | + (is (thrown? #?(:clj AssertionError :cljr Exception :cljs :default) |
63 | 63 | (compile-option-specs [["-a" :id nil]]))) |
64 | | - (is (thrown? #?(:clj AssertionError :cljs :default) |
| 64 | + (is (thrown? #?(:clj AssertionError :cljr Exception :cljs :default) |
65 | 65 | (compile-option-specs [{:id :a :short-opt "-a"} {:id :b :short-opt "-a"}]))) |
66 | | - (is (thrown? #?(:clj AssertionError :cljs :default) |
| 66 | + (is (thrown? #?(:clj AssertionError :cljr Exception :cljs :default) |
67 | 67 | (compile-option-specs [{:id :alpha :long-opt "--alpha"} {:id :beta :long-opt "--alpha"}]))) |
68 | | - (is (thrown? #?(:clj AssertionError :cljs :default) |
| 68 | + (is (thrown? #?(:clj AssertionError :cljr Exception :cljs :default) |
69 | 69 | (compile-option-specs [{:id :alpha :default 0} {:id :alpha :default 1}]))) |
70 | | - (is (thrown? #?(:clj AssertionError :cljs :default) |
| 70 | + (is (thrown? #?(:clj AssertionError :cljr Exception :cljs :default) |
71 | 71 | (compile-option-specs [{:id :alpha :default-fn (constantly 0)} |
72 | 72 | {:id :alpha :default-fn (constantly 1)}]))) |
73 | | - (is (thrown? #?(:clj AssertionError :cljs :default) |
| 73 | + (is (thrown? #?(:clj AssertionError :cljr Exception :cljs :default) |
74 | 74 | (compile-option-specs [{:id :alpha :assoc-fn assoc :update-fn identity}])))) |
75 | 75 | (testing "desugars `--long-opt=value`" |
76 | 76 | (is (= (map (juxt :id :long-opt :required) |
|
99 | 99 | (with-out-str |
100 | 100 | #?(:clj (binding [*err* *out*] |
101 | 101 | (compile-option-specs [[nil "--alpha" :validate nil :flag true]])) |
| 102 | + :cljr (binding [*err* *out*] |
| 103 | + (compile-option-specs [[nil "--alpha" :validate nil :flag true]])) |
102 | 104 | :cljs (binding [*print-err-fn* *print-fn*] |
103 | 105 | (compile-option-specs [[nil "--alpha" :validate nil :flag true]])))))) |
104 | 106 | (is (re-find #"Warning:.* :validate" |
105 | 107 | (with-out-str |
106 | 108 | #?(:clj (binding [*err* *out*] |
107 | 109 | (compile-option-specs [{:id :alpha :validate nil}])) |
| 110 | + :cljr (binding [*err* *out*] |
| 111 | + (compile-option-specs [{:id :alpha :validate nil}])) |
108 | 112 | :cljs (binding [*print-err-fn* *print-fn*] |
109 | 113 | (compile-option-specs [{:id :alpha :validate nil}]))))))))) |
110 | 114 |
|
|
113 | 117 |
|
114 | 118 | (defn parse-int [x] |
115 | 119 | #?(:clj (Integer/parseInt x) |
| 120 | + :cljr (Int32/Parse x) |
116 | 121 | :cljs (do (assert (re-seq #"^\d" x)) |
117 | 122 | (js/parseInt x)))) |
118 | 123 |
|
|
440 | 445 | "Usage: myprog [--alpha|--beta] arg1 arg2")))) |
441 | 446 |
|
442 | 447 | (comment |
443 | | - ;; Chas Emerick's PhantomJS test runner |
444 | | - (spit "target/runner.js" |
445 | | - (slurp (clojure.java.io/resource "cemerick/cljs/test/runner.js"))) |
446 | | - |
447 | 448 | ;; CLJS test runner; same as `lein cljsbuild test` |
448 | 449 | (defn run-cljs-tests [] |
449 | 450 | (println |
|
0 commit comments