Skip to content

Commit e407bec

Browse files
authored
Merge pull request #42 from borkdude/bb-support
Add babashka support
2 parents a259a8c + e8041cf commit e407bec

4 files changed

Lines changed: 31 additions & 13 deletions

File tree

.github/workflows/build.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
uses: DeLaGuardo/setup-clojure@13.0
2727
with:
2828
lein: 2.9.1
29+
bb: latest
2930

3031
- uses: actions/setup-node@v4
3132
with:
@@ -36,3 +37,9 @@ jobs:
3637

3738
- name: Run node tests
3839
run: lein doo node once
40+
41+
- name: Run babashka tests
42+
run: |
43+
# This installs a bb dev build. Once bb is released, we can remove this and run bb test:bb instead
44+
bash <(curl https://raw.githubusercontent.com/babashka/babashka/master/install) --dev-build --dir .
45+
./bb test:bb

bb.edn

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{:tasks
2+
{test:bb {:extra-paths ["src" "test"]
3+
:extra-deps {io.github.cognitect-labs/test-runner
4+
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}
5+
org.clojure/test.check {:mvn/version "1.1.1"}}
6+
:task cognitect.test-runner/-main}}}

src/editscript/diff/a_star.cljc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@
3535
;; Java's native hash is too slow,
3636
;; overriding hashCode significantly speeds things up
3737
Object
38-
(hashCode [_] (coord-hash a b))
38+
#?@(:clj [(hashCode [_] (coord-hash a b))])
3939
(equals [_ that]
4040
(and (= (i/get-order a) (i/get-order (.-a ^Coord that)))
4141
(= (i/get-order b) (i/get-order (.-b ^Coord that)))))
4242
(toString [_]
4343
(str "[" (i/get-value a) "," (i/get-value b) "]"))
4444

45-
Comparable
46-
(compareTo [this that]
47-
(- (.hashCode this) (.hashCode that))))
45+
#?@(:bb []
46+
:clj [Comparable
47+
(compareTo [this that]
48+
(- (.hashCode this) (.hashCode that)))]))
4849
:cljr
4950
(deftype Coord [^Node a
5051
^Node b]

src/editscript/util/pairing.cljc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
;;
1010

1111
(ns ^:no-doc editscript.util.pairing
12-
#?(:clj
12+
#?(:bb (:require [clojure.data.priority-map])
13+
:clj
1314
(:import [clojure.lang IPersistentStack IPersistentMap IPersistentCollection]
1415
[java.io Writer])
1516
:cljr
@@ -68,7 +69,8 @@
6869
(set-right b nil)
6970
(merge-nodes (merge-nodes a b) (two-pass n)))))
7071

71-
#?(:clj
72+
#?(:bb nil
73+
:clj
7274
(deftype PriorityMap [^:unsynchronized-mutable ^HeapNode heap
7375
^:unsynchronized-mutable map]
7476
IPersistentCollection
@@ -175,13 +177,15 @@
175177
(set! heap n)
176178
this))))
177179

178-
(defn priority-map
179-
"A priority queue that also functions as a map.
180+
#?(:bb (def priority-map clojure.data.priority-map/priority-map)
181+
:default
182+
(defn priority-map
183+
"A priority queue that also functions as a map.
180184
Backed by a pairing heap implementation, and a regular map.
181185
NB. We do not implement `decrease-key` for the pairing heap,
182186
instead just insert the item again with a new priority."
183-
([]
184-
(->PriorityMap nil {}))
185-
([& keyvals]
186-
{:pre [(even? (count keyvals))]}
187-
(reduce conj (priority-map) (partition 2 keyvals))))
187+
([]
188+
(->PriorityMap nil {}))
189+
([& keyvals]
190+
{:pre [(even? (count keyvals))]}
191+
(reduce conj (priority-map) (partition 2 keyvals)))))

0 commit comments

Comments
 (0)