diff --git a/fitnesse/FitNesseRoot/RecentChanges.wiki b/fitnesse/FitNesseRoot/RecentChanges.wiki index a1f9e15..4c7f915 100644 --- a/fitnesse/FitNesseRoot/RecentChanges.wiki +++ b/fitnesse/FitNesseRoot/RecentChanges.wiki @@ -1,3 +1,5 @@ +|TranscendentalLisp.Macros||10:10:15 Mon, Mar 13, 2017| +|TranscendentalLisp.MacroTests||10:07:00 Mon, Mar 13, 2017| |TranscendentalLisp.FinanceUnitTests||11:07:42 Thu, Mar 09, 2017| |TranscendentalLisp.LangUnitTests||11:04:17 Thu, Mar 09, 2017| |TranscendentalLisp.LexicalClosures||16:39:59 Tue, Mar 07, 2017| diff --git a/fitnesse/FitNesseRoot/TranscendentalLisp/Macros.wiki b/fitnesse/FitNesseRoot/TranscendentalLisp/Macros.wiki new file mode 100644 index 0000000..437a350 --- /dev/null +++ b/fitnesse/FitNesseRoot/TranscendentalLisp/Macros.wiki @@ -0,0 +1,12 @@ +--- +Test +--- +A simple macro example. + +| script | lisp interpreter fixture | +| check | evaluate text | (load "lisp/macro/nif.lisp") | T | +| check | evaluate text | (nif 10 'p 'z 'n) | P | +| check | evaluate text | (nif 0 'p 'z 'n) | Z | +| check | evaluate text | (nif -2 'p 'z 'n) | N | +| check | evaluate text | (nif (- 10 9) 'p 'z 'n) | P | + diff --git a/lisp/macro/nif.lisp b/lisp/macro/nif.lisp new file mode 100644 index 0000000..e508f0a --- /dev/null +++ b/lisp/macro/nif.lisp @@ -0,0 +1,9 @@ +(defun plusp (n) (> n 0)) +(defun zerop (n) (= n 0)) + +(defmacro nif (expr pos zero neg) + (let ((g (gensym))) + `(let ((,g ,expr)) + (cond ((plusp ,g) ,pos) + ((zerop ,g) ,zero) + (t ,neg))))) diff --git a/test/function/builtin/EVALTester.java b/test/function/builtin/EVALTester.java index ec6b9ff..445abe5 100644 --- a/test/function/builtin/EVALTester.java +++ b/test/function/builtin/EVALTester.java @@ -162,4 +162,11 @@ public class EVALTester { assertSExpressionsMatch(parseString("((1 2 3))"), evaluateString(input)); } + @Test + public void evalNestedBackquotesInList() { + String input = "`(,`(1 ,`2 ,@`(3)))"; + + assertSExpressionsMatch(parseString("((1 2 3))"), evaluateString(input)); + } + }