From db558564254f22b90ce69dbf452f733c6dbf37c3 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 17 Apr 2026 20:49:07 +0200 Subject: [PATCH 1/3] Use real cljs.test now that squint 0.11.187 ships it Drops the stub macros and requires cljs.test directly under both targets. Adds (t/run-tests) at the end so the squint binary runs the suite. --- package.json | 2 +- .../clojure_mode_tests/macros.cljc | 83 ------------------- test/nextjournal/clojure_mode_tests.cljc | 11 ++- yarn.lock | 18 ++-- 4 files changed, 15 insertions(+), 99 deletions(-) delete mode 100644 src-squint/nextjournal/clojure_mode_tests/macros.cljc diff --git a/package.json b/package.json index 3447caa..63b4589 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@lezer/lr": "^1.0.0", "@nextjournal/lezer-clojure": "1.0.0", "markdown-it-footnote": "^3.0.3", - "squint-cljs": "0.8.129", + "squint-cljs": "0.11.187", "w3c-keyname": "^2.2.4" }, "comments": { diff --git a/src-squint/nextjournal/clojure_mode_tests/macros.cljc b/src-squint/nextjournal/clojure_mode_tests/macros.cljc deleted file mode 100644 index 1a1ab3c..0000000 --- a/src-squint/nextjournal/clojure_mode_tests/macros.cljc +++ /dev/null @@ -1,83 +0,0 @@ -(ns nextjournal.clojure-mode-tests.macros - (:require [clojure.walk :as walk])) - -(defmacro deftest [var-name & body] - `(do - (~'js* "// ~{}\n" ~var-name) - ~@body)) - -(defmacro testing [_str & body] - `(do ~@body)) - -(defn apply-template - "For use in macros. argv is an argument list, as in defn. expr is - a quoted expression using the symbols in argv. values is a sequence - of values to be used for the arguments. - - apply-template will recursively replace argument symbols in expr - with their corresponding values, returning a modified expr. - - Example: (apply-template '[x] '(+ x x) '[2]) - ;=> (+ 2 2)" - [argv expr values] - (assert (vector? argv)) - (assert (every? symbol? argv)) - (walk/postwalk-replace (zipmap argv values) expr)) - -(defmacro do-template - "Repeatedly copies expr (in a do block) for each group of arguments - in values. values are automatically partitioned by the number of - arguments in argv, an argument vector as in defn. - - Example: (macroexpand '(do-template [x y] (+ y x) 2 4 3 5)) - ;=> (do (+ 4 2) (+ 5 3))" - [argv expr & values] - (let [c (count argv)] - `(do ~@(map (fn [a] (apply-template argv expr a)) - (partition c values))))) - -(defn ->assert [expr] - (walk/postwalk (fn [expr] - (if (and (seq? expr) - (= '= (first expr))) - (list* 'assert.equal (rest expr)) - expr)) expr)) - -(defmacro are - "Checks multiple assertions with a template expression. - See clojure.template/do-template for an explanation of - templates. - - Example: (are [x y] (= x y) - 2 (+ 1 1) - 4 (* 2 2)) - Expands to: - (do (is (= 2 (+ 1 1))) - (is (= 4 (* 2 2)))) - - Note: This breaks some reporting features, such as line numbers." - {:added "1.1"} - [argv expr & args] - (if (or - ;; (are [] true) is meaningless but ok - (and (empty? argv) (empty? args)) - ;; Catch wrong number of args - (and (pos? (count argv)) - (pos? (count args)) - (zero? (mod (count args) (count argv))))) - (let [processed (map (fn [a] - (apply-template argv (->assert expr) a)) - (partition (count argv) args))] - #_(println "======") - #_(println args) - #_(println processed) - `(do ~@processed)) - #?(:clj (throw (IllegalArgumentException. "The number of args doesn't match are's argv.")) - :cljs (throw (js/Error "The number of args doesn't match are's argv."))))) - -(defmacro is - [expr & _] - (if (and (seq? expr) - (= '= (first expr))) - (list* 'assert.equal (rest expr)) - expr)) diff --git a/test/nextjournal/clojure_mode_tests.cljc b/test/nextjournal/clojure_mode_tests.cljc index f1006f9..f4ee3d9 100644 --- a/test/nextjournal/clojure_mode_tests.cljc +++ b/test/nextjournal/clojure_mode_tests.cljc @@ -1,6 +1,5 @@ (ns nextjournal.clojure-mode-tests - (:require #?@(:squint [] - :cljs [[cljs.test :refer [are testing deftest is]]]) + (:require [cljs.test :as t :refer [are testing deftest is]] [nextjournal.clojure-mode :as cm-clojure] [nextjournal.clojure-mode.util :as util] [nextjournal.clojure-mode.test-utils :as test-utils] @@ -10,9 +9,7 @@ [nextjournal.clojure-mode.extensions.eval-region :as eval-region] [nextjournal.scratch] #?@(:squint [] - :cljs [[nextjournal.livedoc :as livedoc]]) - #?(:squint ["assert" :as assert])) - #?(:squint (:require-macros [nextjournal.clojure-mode-tests.macros :refer [deftest are testing is]]))) + :cljs [[nextjournal.livedoc :as livedoc]]))) (def extensions (.concat cm-clojure/default-extensions (eval-region/extension #js {})) @@ -65,7 +62,7 @@ )) - (deftest close-brackets + (deftest close-brackets-test (testing "handle-open" (are [input insert expected] (= (apply-f #(close-brackets/handle-open % insert) input) @@ -343,4 +340,6 @@ (is (= "{:a 1}" (->> (eval-region/top-level-node state) (util/range-str state))))))) +#?(:squint (t/run-tests)) + #_(prn (eval-region/cursor-node-string (test-utils/make-state extensions "(+ (+ 1 2)| 2 3)"))) diff --git a/yarn.lock b/yarn.lock index 8c00201..2e07673 100644 --- a/yarn.lock +++ b/yarn.lock @@ -443,10 +443,10 @@ builtin-status-codes@^3.0.0: resolved "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz" integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug= -chokidar@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-4.0.1.tgz#4a6dff66798fb0f72a94f616abbd7e1a19f31d41" - integrity sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA== +chokidar@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-4.0.3.tgz#7be37a4c03c9aee1ecfe862a4a23b2c70c205d30" + integrity sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA== dependencies: readdirp "^4.0.1" @@ -1103,12 +1103,12 @@ source-map@^0.5.6: resolved "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= -squint-cljs@0.8.129: - version "0.8.129" - resolved "https://registry.yarnpkg.com/squint-cljs/-/squint-cljs-0.8.129.tgz#04a3f1ca899e6fb7e2ba30b882efb791741caff0" - integrity sha512-cgTKzOorBX2wuli+6BNnioPYslAqyGP+C4W5W/B2ddlBXCTUPfc9nCrxkz5hP1vOt6bPJNZDdKjcXkfRlO62/g== +squint-cljs@0.11.187: + version "0.11.187" + resolved "https://registry.yarnpkg.com/squint-cljs/-/squint-cljs-0.11.187.tgz#6bfa181ca0f9d392224d7397361fbafd0ac2ec50" + integrity sha512-nSx9MfbvbyRgunal/FV4yDHN/bjxRbK8lvY9sErp2Yqsok52nOS/5wWjBSpGNSnjxGAznxy1/NXyWPToHrYjzg== dependencies: - chokidar "^4.0.1" + chokidar "^4.0.3" stream-browserify@^2.0.1: version "2.0.2" From d4c4c09fe3adff3b8f56ab92215d9702ee1168ff Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 17 Apr 2026 20:52:59 +0200 Subject: [PATCH 2/3] Drop empty src-squint from squint paths --- squint.edn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/squint.edn b/squint.edn index 54ea925..93e9229 100644 --- a/squint.edn +++ b/squint.edn @@ -1,3 +1,3 @@ -{:paths ["src-shared" "src-squint" "test" +{:paths ["src-shared" "test" "node_modules/@squint-cljs/macros/src"] :output-dir "dist"} From c74e9b679502e9aa8567e81b047a558382167dda Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sat, 18 Apr 2026 23:24:18 +0200 Subject: [PATCH 3/3] bump squint --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 63b4589..09cfac0 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@lezer/lr": "^1.0.0", "@nextjournal/lezer-clojure": "1.0.0", "markdown-it-footnote": "^3.0.3", - "squint-cljs": "0.11.187", + "squint-cljs": "0.11.188", "w3c-keyname": "^2.2.4" }, "comments": {