Quasiquote reader macros
This commit is contained in:
@@ -15,8 +15,11 @@ class ReaderMacroTestCase extends Test {
|
||||
}
|
||||
|
||||
function testMultipleInitiators() {
|
||||
Assert.equals("a", ReaderMacroTestCase.str1);
|
||||
Assert.equals("b", ReaderMacroTestCase.str2);
|
||||
Assert.equals("c", ReaderMacroTestCase.str3);
|
||||
Assert.equals("b", ReaderMacroTestCase.str1);
|
||||
Assert.equals("c", ReaderMacroTestCase.str2);
|
||||
}
|
||||
|
||||
function testQuasiquoteMacro() {
|
||||
_testQuasiquoteMacro();
|
||||
}
|
||||
}
|
||||
|
@@ -12,9 +12,17 @@
|
||||
|
||||
(defvar mySum (pluppers fluffers buffers))
|
||||
|
||||
// Read a b c directly as strings
|
||||
(defreadermacro ["a" "b" "c"] [stream] #|ReaderExp.StrExp(stream.expect("a, b, or c", function () stream.takeChars(1)))|#)
|
||||
// Read b c directly as strings
|
||||
(defreadermacro ["b" "c"] [stream] #|ReaderExp.StrExp(stream.expect("b, or c", function () stream.takeChars(1)))|#)
|
||||
|
||||
(defvar str1 a)
|
||||
(defvar str2 b)
|
||||
(defvar str3 c)
|
||||
(defvar str1 b)
|
||||
(defvar str2 c)
|
||||
|
||||
// rassert asserts the next expression without parens
|
||||
(defreadermacro "rassert" [stream] `(assert ,(read stream)))
|
||||
|
||||
(defun _testQuasiquoteMacro []
|
||||
rassert [5]
|
||||
rassert b
|
||||
rassert fluffers
|
||||
(Assert.pass))
|
Reference in New Issue
Block a user