From 0f1287b7601d2d49a2a12271534c329a05ee43b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madeleine=20Sydney=20=C5=9Alaga?= Date: Wed, 16 Sep 2026 06:23:45 -0600 Subject: [PATCH] tests --- deps.edn | 5 +++-- src/expand.clj | 16 ++-------------- test/expand_test.clj | 9 +++++++++ tests.edn | 1 + 4 files changed, 15 insertions(+), 16 deletions(-) create mode 100644 tests.edn diff --git a/deps.edn b/deps.edn index 9d16f1e..45bd11e 100644 --- a/deps.edn +++ b/deps.edn @@ -9,5 +9,6 @@ io.github.msyds/spec-dict {:git/sha "531d629b7f05f37232261cf9e8927a4b5915714f"}} :paths ["src" "resources" "test"] - :test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}} - :main-opts ["-m" "kaocha.runner"]}} + :aliases + {:test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}} + :main-opts ["-m" "kaocha.runner"]}}} diff --git a/src/expand.clj b/src/expand.clj index 22d90c4..a4c7b5d 100644 --- a/src/expand.clj +++ b/src/expand.clj @@ -86,6 +86,8 @@ (swap! symtable-ref #(assoc-in % [sym scopes] bind)) {bind denot})) +(declare expand) + (defmethod expand-primitive 'lambda [datum _ env symtable-ref scopes] (let [[_ formals & body] datum @@ -98,20 +100,6 @@ (for [e body] (expand e env* symtable-ref scopes*))))) -(comment (assert (lookup ['lambda #{}] - scheme-base-env - (symtable-for-env scheme-base-env)))) - -(comment - (nearest ['x #{0 1 2}] - #{#{0} - #{0 1} - #{0 3}})) - -(comment - (expand 'x) - (expand '(lambda (x) x))) - (defn expand ([datum] (expand diff --git a/test/expand_test.clj b/test/expand_test.clj index 04db231..495c157 100644 --- a/test/expand_test.clj +++ b/test/expand_test.clj @@ -9,6 +9,15 @@ (t/deftest symtable-for-env-test (t/is (s/valid? ::sut/symtable (sut/symtable-for-env sut/scheme-base-env)))) +(t/deftest nearest-test + (t/is (= [:primitive 'lambda] + (sut/lookup ['lambda #{}] + sut/scheme-base-env + (sut/symtable-for-env sut/scheme-base-env)))) + (t/is (= [#{0 1}] + (sut/nearest ['x #{0 1 2}] + [#{0} #{0 1} #{0 3}])))) + (t/deftest expand-test (t/testing "unbound symbol" (t/is (thrown? Exception (sut/expand 'x)))) diff --git a/tests.edn b/tests.edn new file mode 100644 index 0000000..9d8d845 --- /dev/null +++ b/tests.edn @@ -0,0 +1 @@ +#kaocha/v1 {}