Skip to content

Commit a43531a

Browse files
author
dnolen
committed
start adding cljs.js tests
1 parent e494046 commit a43531a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/test/cljs/self_host/test.cljs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
(ns self-host.test
2+
(:require [cljs.test :as test
3+
:refer-macros [run-tests deftest testing is async]]
4+
[cljs.js :as cljs]))
5+
6+
(defn latch [m f]
7+
(let [r (atom 0)]
8+
(add-watch r :latch
9+
(fn [_ _ o n]
10+
(when (== n m) (f))))
11+
r))
12+
13+
(defn inc! [r]
14+
(swap! r inc))
15+
16+
(def st (cljs/empty-state))
17+
18+
(deftest test-compile-str
19+
(async done
20+
(let [l (latch 1 done)]
21+
(cljs/compile-str st "(+ 1 1)"
22+
(fn [{:keys [error value]}]
23+
(is (nil? error))
24+
(is (= value "(1 + 1);\n"))
25+
(inc! l))))))

0 commit comments

Comments
 (0)