diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a11e951..eca78be 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -53,3 +53,5 @@ jobs: - run: npm install - run: npx shadow-cljs compile test && node out/test.js + + - run: bb test/run.bb diff --git a/Justfile b/Justfile index 7ff5d8b..7e149e7 100644 --- a/Justfile +++ b/Justfile @@ -1,3 +1,6 @@ +test-bb: + bb test/run.bb + npm: npm install @@ -8,7 +11,7 @@ test-clj: clojure -A:dev -X cognitect.test-runner.api/test clojure -X:dev user/xr! '{:path "check"}' -test: test-cljs test-clj +test: test-bb test-cljs test-clj bench: clojure -X:dev user/xr! '{:path "bench"}' diff --git a/bb.edn b/bb.edn new file mode 100644 index 0000000..482d906 --- /dev/null +++ b/bb.edn @@ -0,0 +1,2 @@ +{:deps {org.clojure/test.check {:mvn/version "1.1.1"} + com.widdindustries/time-literals {:mvn/version "0.1.10"}}} diff --git a/test/me/flowthing/pp_cpp_test.bb b/test/me/flowthing/pp_cpp_test.bb new file mode 100644 index 0000000..662e674 --- /dev/null +++ b/test/me/flowthing/pp_cpp_test.bb @@ -0,0 +1,4 @@ +(ns me.flowthing.pp-cpp-test) + +;; Dummy namespace to prevent Babashka from running tests that compare +;; the output of clojure.pprint/pprint and me.flowthing.pp/pprint. diff --git a/test/me/flowthing/pp_gen_test.bb b/test/me/flowthing/pp_gen_test.bb new file mode 100644 index 0000000..326f89c --- /dev/null +++ b/test/me/flowthing/pp_gen_test.bb @@ -0,0 +1,4 @@ +(ns me.flowthing.pp-gen-test) + +;; Dummy namespace to prevent Babashka from running Clojure-only +;; generative tests. diff --git a/test/me/flowthing/pp_record_test.bb b/test/me/flowthing/pp_record_test.bb new file mode 100644 index 0000000..7520a7e --- /dev/null +++ b/test/me/flowthing/pp_record_test.bb @@ -0,0 +1,12 @@ +(ns me.flowthing.pp-record-test + (:require [clojure.test :refer [deftest is]] + [me.flowthing.pp.test :refer [pp]])) + +(defrecord R [x]) +(defrecord R?*+! []) + +(deftest print-record + (is (= "#sci.impl.records.SciRecord{:x\n {:a\n 1,\n :b\n 2,\n :c\n 3,\n :d\n 4}}\n" + (pp (->R {:a 1 :b 2 :c 3 :d 4}) :max-width 31))) + (is (= "#sci.impl.records.SciRecord{}\n" + (pp (->R?*+!))))) diff --git a/test/run.bb b/test/run.bb new file mode 100644 index 0000000..6e7d17a --- /dev/null +++ b/test/run.bb @@ -0,0 +1,15 @@ +#!/usr/bin/env bb + +(require '[clojure.test :as t] + '[babashka.classpath :as cp]) + +(cp/add-classpath "src:test") + +(require 'me.flowthing.pp-test) + +(def test-results + (t/run-tests 'me.flowthing.pp-test)) + +(let [{:keys [fail error]} test-results] + (when (pos? (+ fail error)) + (System/exit 1)))