Skip to content

Commit f1c729d

Browse files
authored
ClojureCLR GitHub Actions Test Runner Workflow (#101)
* Add cljr Instructions * Add ClojureCLR GitHub Actions Workflow * Bump ClojureCLR * Fix syntax + bump * Remove redundant deps.edn * Update README * Fix cljr tests * Add deps.edn back
1 parent a54a567 commit f1c729d

File tree

4 files changed

+75
-51
lines changed

4 files changed

+75
-51
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ jobs:
4141
key: cljdeps-${{ env.CACHE_VERSION }}-${{ hashFiles('project.clj') }}-${{ hashFiles('deps.edn') }}-${{ hashFiles('bb.edn') }}
4242
restore-keys: cljdeps-${{ env.CACHE_VERSION }}-
4343

44+
- name: Prepare dotnet
45+
uses: xt0rted/setup-dotnet@v1.5.0
46+
47+
- name: Install ClojureCLR
48+
run: |
49+
dotnet tool install --global Clojure.Main --version 1.12.2
50+
dotnet tool install --global Clojure.Cljr --version 0.1.0-alpha6
51+
4452
- name: Prepare node
4553
uses: actions/setup-node@v4
4654
with:
@@ -61,5 +69,8 @@ jobs:
6169
- name: Run Clojure tests
6270
run: lein test
6371

72+
- name: Run ClojureCLR Tests
73+
run: cljr -X:test
74+
6475
- name: Run babashka tests
6576
run: bb test-bb

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ Once tests are compiled they can be ran with:
5252
node target/js/node-tests.js
5353
```
5454

55+
## Running the ClojureCLR tests
56+
57+
### Pre-requisites
58+
- [dotnet](https://dotnet.microsoft.com/en-us/download)
59+
- `ClojureCLR`: `dotnet tool install --global Clojure.Main --version 1.12.2`
60+
- `cljr`: `dotnet tool install --global Clojure.Cljr --version 0.1.0-alpha6`
61+
62+
```bash
63+
cljr -X:test
64+
```
65+
5566
### Automated test running during development
5667

5768
If you want to autorun the tests during development run the following:

test/clojure/core_test/merge.cljc

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,34 +45,36 @@
4545
{:b "b"}))))
4646

4747
(testing "vectors in position 2+ are treated as map-entries, per `conj`"
48-
(is (thrown? #?(:cljs :default, :clj java.lang.IllegalArgumentException, :clr Exception)
49-
(merge {} [])))
50-
(is (thrown? #?(:cljs :default, :clj java.lang.IllegalArgumentException, :clr Exception)
51-
(merge {} [:foo])))
48+
#?(:cljs (is (thrown? js/Error (merge {} [])))
49+
:clj (is (thrown? java.lang.IllegalArgumentException (merge {} [])))
50+
:default (is (thrown? Exception (merge {} []))))
51+
#?(:cljs (is (thrown? js/Error (merge {} [:foo])))
52+
:clj (is (thrown? java.lang.IllegalArgumentException (merge {} [:foo])))
53+
:default (is (thrown? Exception (merge {} [:foo]))))
5254
(is (= {:foo "foo"} (merge {} [:foo "foo"])))
5355
(is (= {"x" 1} (merge {} ["x" 1])))
5456
(is (= {'x 10, 'y 10} (merge {'x 10} ['y 10])))
5557
(testing "In CLJS (unlike other dialects) vectors with >2 arguments are treated as map-entries (where the latter values are ignored)"
5658
#?(:cljs (is (= {:foo :bar} (merge {} [:foo :bar :baz]))),
57-
:clj (is (thrown? java.lang.IllegalArgumentException (merge {} [:foo :bar :baz]))),
58-
:clr (is (thrown? Exception (merge {} [:foo :bar :baz])))))
59+
:clj (is (thrown? java.lang.IllegalArgumentException (merge {} [:foo :bar :baz]))),
60+
:clr (is (thrown? Exception (merge {} [:foo :bar :baz])))))
5961

6062
(is (= {:foo "foo", :bar "bar"} (merge {} [:foo "foo"] [:bar "bar"])))
6163
(is (= {'x 10, 'y 10, 'z 10} (merge {'x 10} ['y 10] ['z 10])))
6264
(testing "In CLJS (unlike other dialects) vectors with >2 arguments are treated as map-entries (where the latter values are ignored)"
6365
#?(:cljs (is (= {:foo :bar} (merge {} [:foo :bar :baz :bar]))),
64-
:clj (is (thrown? java.lang.IllegalArgumentException (merge {} [:foo :bar :baz :bar]))),
65-
:clr (is (thrown? Exception (merge {} [:foo :bar :baz :bar]))))))
66+
:clj (is (thrown? java.lang.IllegalArgumentException (merge {} [:foo :bar :baz :bar]))),
67+
:clr (is (thrown? Exception (merge {} [:foo :bar :baz :bar]))))))
6668

6769
(testing "atomic values in position 2+ throw"
68-
(is (thrown? #?(:cljs :default, :clj Exception, :clr Exception)
69-
(merge {} 1)))
70-
(is (thrown? #?(:cljs :default, :clj Exception, :clr Exception)
71-
(merge {} 1 2)))
72-
(is (thrown? #?(:cljs :default, :clj Exception, :clr Exception)
73-
(merge {} :foo)))
74-
(is (thrown? #?(:cljs :default, :clj Exception, :clr Exception)
75-
(merge {} "str"))))
70+
#?@(:cljs [(is (thrown? js/Error (merge {} 1)))
71+
(is (thrown? js/Error (merge {} 1 2)))
72+
(is (thrown? js/Error (merge {} :foo)))
73+
(is (thrown? js/Error (merge {} "str")))]
74+
:default [(is (thrown? Exception (merge {} 1)))
75+
(is (thrown? Exception (merge {} 1 2)))
76+
(is (thrown? Exception (merge {} :foo)))
77+
(is (thrown? Exception (merge {} "str")))]))
7678

7779
(testing "undefined `merge` behavior on non-maps"
7880
;; Behavior for non-map input is undefined. We intentionally do not test
@@ -83,15 +85,15 @@
8385
(is (any? (merge (first {:a "a"}) {:b "b"} {:c "c"})))
8486
(is (= [:foo] (merge [:foo])))
8587
(is (= :foo (merge :foo)))
86-
(is (thrown? #?(:cljs :default, :clj Exception, :clr Exception)
87-
(merge :foo :bar)))
88-
(is (thrown? #?(:cljs :default, :clj Exception, :clr Exception)
89-
(merge 100 :foo)))
90-
(is (thrown? #?(:cljs :default, :clj Exception, :clr Exception)
91-
(merge "str" :foo)))
92-
(is (thrown? #?(:cljs :default, :clj Exception, :clr Exception)
93-
(merge nil (range))))
94-
(is (thrown? #?(:cljs :default, :clj Exception, :clr Exception)
95-
(merge {} '(1 2))))
96-
(is (thrown? #?(:cljs :default, :clj Exception, :clr Exception)
97-
(merge {} 1 2)))))))
88+
#?@(:cljs [(is (thrown? js/Error (merge :foo :bar)))
89+
(is (thrown? js/Error (merge 100 :foo)))
90+
(is (thrown? js/Error (merge "str" :foo)))
91+
(is (thrown? js/Error (merge nil (range))))
92+
(is (thrown? js/Error (merge {} '(1 2))))
93+
(is (thrown? js/Error (merge {} 1 2)))]
94+
:default [(is (thrown? Exception (merge :foo :bar)))
95+
(is (thrown? Exception (merge 100 :foo)))
96+
(is (thrown? Exception (merge "str" :foo)))
97+
(is (thrown? Exception (merge nil (range))))
98+
(is (thrown? Exception (merge {} '(1 2))))
99+
(is (thrown? Exception (merge {} 1 2)))])))))

test/clojure/core_test/val.cljc

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(ns clojure.core-test.val
2-
(:require [clojure.test :as t :refer [deftest testing is are]]
2+
(:require [clojure.test :as t :refer [deftest testing is]]
33
[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]]))
44

55
(when-var-exists val
@@ -9,29 +9,29 @@
99
(is (= :v (val (first {:k :v, :one :two}))))
1010
;; Note: the following may be built on shaky ground, per Rich:
1111
;; https://groups.google.com/g/clojure/c/FVcrbHJpCW4/m/Fh7NsX_Yb7sJ
12-
(is (= 'v (val #?(:cljs (cljs.core/MapEntry. 'k 'v nil)
13-
:clj (clojure.lang.MapEntry/create 'k 'v)))))
12+
(is (= 'v (val #?(:cljs (cljs.core/MapEntry. 'k 'v nil)
13+
:default (clojure.lang.MapEntry/create 'k 'v)))))
1414
(is (= :b (val (first (sorted-map :a :b)))))
1515
(is (= :b (val (first (hash-map :a :b)))))
1616
(is (= :b (val (first (array-map :a :b))))))
1717
(testing "`val` throws on lots of things"
18-
(is (thrown? #?(:cljs :default, :clj Exception, :cljr Exception)
19-
(val nil)))
20-
(is (thrown? #?(:cljs :default, :clj Exception, :cljr Exception)
21-
(val 0)))
22-
(is (thrown? #?(:cljs :default, :clj Exception, :cljr Exception)
23-
(val '())))
24-
(is (thrown? #?(:cljs :default, :clj Exception, :cljr Exception)
25-
(val '(1 2))))
26-
(is (thrown? #?(:cljs :default, :clj Exception, :cljr Exception)
27-
(val {})))
28-
(is (thrown? #?(:cljs :default, :clj Exception, :cljr Exception)
29-
(val {1 2})))
30-
(is (thrown? #?(:cljs :default, :clj Exception, :cljr Exception)
31-
(val [])))
32-
(is (thrown? #?(:cljs :default, :clj Exception, :cljr Exception)
33-
(val [1 2])))
34-
(is (thrown? #?(:cljs :default, :clj Exception, :cljr Exception)
35-
(val #{})))
36-
(is (thrown? #?(:cljs :default, :clj Exception, :cljr Exception)
37-
(val #{1 2}))))))
18+
#?@(:cljs [(is (thrown? js/Error (val nil)))
19+
(is (thrown? js/Error (val 0)))
20+
(is (thrown? js/Error (val '())))
21+
(is (thrown? js/Error (val '(1 2))))
22+
(is (thrown? js/Error (val {})))
23+
(is (thrown? js/Error (val {1 2})))
24+
(is (thrown? js/Error (val [])))
25+
(is (thrown? js/Error (val [1 2])))
26+
(is (thrown? js/Error (val #{})))
27+
(is (thrown? js/Error (val #{1 2})))]
28+
:default [(is (thrown? Exception (val nil)))
29+
(is (thrown? Exception (val 0)))
30+
(is (thrown? Exception (val '())))
31+
(is (thrown? Exception (val '(1 2))))
32+
(is (thrown? Exception (val {})))
33+
(is (thrown? Exception (val {1 2})))
34+
(is (thrown? Exception (val [])))
35+
(is (thrown? Exception (val [1 2])))
36+
(is (thrown? Exception (val #{})))
37+
(is (thrown? Exception (val #{1 2})))]))))

0 commit comments

Comments
 (0)