Working assignment, reader macros, mexpr interpretation.

This commit is contained in:
Simon Brooke 2023-03-26 16:04:22 +01:00
parent b5e418118b
commit 6a8417a367
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
23 changed files with 227 additions and 135 deletions

View file

@ -0,0 +1,11 @@
(ns beowulf.reader-macro-test
(:require [clojure.test :refer [deftest is testing]]
[beowulf.read :refer [gsp]]
[beowulf.reader.macros :refer [expand-macros]]))
(deftest macro-expansion
(testing "Expanding DEFUN"
(let [expected "(SET (QUOTE FACT) (LAMBDA (X) (COND ((ZEROP X) 1) (T (TIMES X (FACT (SUB1 X)))))))"
source "(DEFUN FACT (X) (COND ((ZEROP X) 1) (T (TIMES X (FACT (SUB1 X))))))"
actual (print-str (gsp source))]
(is (= actual expected)))))

View file

@ -114,6 +114,6 @@
(deftest list-tests
(testing "Reading arbitrarily structured lists"
(let [expected "(DEFUN FACT (X) (COND ((ZEROP X) 1) (T (TIMES X (FACT (SUB1 X))))))"
(let [expected "(SET (QUOTE FACT) (LAMBDA (X) (COND ((ZEROP X) 1) (T (TIMES X (FACT (SUB1 X)))))))"
actual (print-str (gsp expected))]
(is (= actual expected)))))