|
186 | 186 |
|
187 | 187 | (deftest fn-test
|
188 | 188 | #_(is (thrown-with-msg?
|
189 |
| - #?(:clj Exception :cljs js/Error) #"arg" |
190 |
| - (eval* '((fn foo [x] (if (< x 3) (foo 1 (inc x)) x)) 0)))) |
| 189 | + #?(:clj Exception :cljs js/Error) #"arg" |
| 190 | + (eval* '((fn foo [x] (if (< x 3) (foo 1 (inc x)) x)) 0)))) |
191 | 191 | (is (= 3 (eval* '((fn foo [x] (if (< x 3) (foo (inc x)) x)) 0))))
|
192 | 192 | (is (= [2 3] (eval* '((fn foo [[x & xs]] xs) [1 2 3]))))
|
193 | 193 | (is (= [2 3] (eval* '((fn foo [x & xs] xs) 1 2 3))))
|
|
429 | 429 | (let [d (ex-data ex)]
|
430 | 430 | d))))
|
431 | 431 | #_(tu/assert-submap {:type :sci/error, :line 1, :column 25,
|
432 |
| - :message #"Wrong number of args \(0\) passed to: user/foo"} |
433 |
| - (try (eval* (str "(defmacro foo [x & xs]) " |
434 |
| - "(foo)")) |
435 |
| - (catch #?(:clj clojure.lang.ExceptionInfo :cljs ExceptionInfo) ex |
436 |
| - (let [d (ex-data ex)] |
437 |
| - d)))))) |
| 432 | + :message #"Wrong number of args \(0\) passed to: user/foo"} |
| 433 | + (try (eval* (str "(defmacro foo [x & xs]) " |
| 434 | + "(foo)")) |
| 435 | + (catch #?(:clj clojure.lang.ExceptionInfo :cljs ExceptionInfo) ex |
| 436 | + (let [d (ex-data ex)] |
| 437 | + d)))))) |
438 | 438 |
|
439 | 439 | (deftest disable-arity-checks-test
|
440 | 440 | (is (thrown-with-msg? #?(:clj Exception :cljs js/Error)
|
|
1153 | 1153 | sci-ns (update-vals* publics #(sci/copy-var* % ens))
|
1154 | 1154 | ctx (sci/init {:namespaces {'edamame.core sci-ns}})
|
1155 | 1155 | output (sci/eval-string* ctx "(require '[edamame.core :as e]) (e/parse-string \"1\")")]
|
1156 |
| - (is (= 1 output)))) |
| 1156 | + (is (= 1 output))) |
| 1157 | + (is (= 'inc (-> (sci/copy-var* #'inc (sci/create-ns 'clojure.core)) |
| 1158 | + meta :name)))) |
1157 | 1159 |
|
1158 | 1160 | (deftest data-readers-test
|
1159 | 1161 | (is (= 2 (sci/eval-string "#t/tag 1" {:readers {'t/tag inc}})))
|
|
1373 | 1375 | (deftest copy-ns-default-meta-test
|
1374 | 1376 | (testing "copy-ns default meta includes name"
|
1375 | 1377 | (let [sci-ns (sci/copy-ns sci.copy-ns-test-ns
|
1376 |
| - (sci/create-ns 'sci.copy-ns-test-ns))] |
| 1378 | + (sci/create-ns 'sci.copy-ns-test-ns))] |
1377 | 1379 | (is (every? (fn [[var-name meta]] (and (symbol? var-name) (= var-name (:name meta))))
|
1378 |
| - (map (fn [[name var]] (vector name (meta var))) sci-ns)))))) |
| 1380 | + (map (fn [[name var]] (vector name (meta var))) sci-ns)))))) |
1379 | 1381 |
|
1380 | 1382 | (deftest vswap-test
|
1381 | 1383 | (is (= 2 (sci/eval-string
|
|
1425 | 1427 |
|
1426 | 1428 | (deftest var-name-test
|
1427 | 1429 | (testing "var name strings match their namespace and symbol"
|
1428 |
| - (is (empty? (sci/eval-string " |
| 1430 | + (is (empty? (sci/eval-string " |
1429 | 1431 | (require '[clojure.string :as str])
|
1430 | 1432 | (let [ns-maps (->> (all-ns)
|
1431 | 1433 | (map (fn [nmspc] [(ns-name nmspc) (ns-publics nmspc)]))
|
|
1437 | 1439 | var-meta-ns-name ((fnil ns-name (create-ns \"missing-ns\")) var-meta-ns)]]
|
1438 | 1440 | ; build a seq of maps containing the ns/symbol from the ns and the ns/symbol from the var's metadata
|
1439 | 1441 | {:actual-ns ns-nm :actual-ns-symbol sym :var-meta-ns var-meta-ns-name :var-meta-name var-meta-name})
|
1440 |
| - ; remove the protocol/interface-ish vars whose metas don't really match |
| 1442 | + ; remove the protocol/interface-ish vars whose metas don't really match |
1441 | 1443 | (remove (fn [{:keys [var-meta-name]}]
|
1442 | 1444 | (str/starts-with? (name var-meta-name) \"cljs.core.\")))
|
1443 | 1445 | (filter (complement #(and (= (:actual-ns %) (:var-meta-ns %)) (= (:actual-ns-symbol %) (:var-meta-name %)))))))")))))
|
|
0 commit comments