Skip to content

Commit be77679

Browse files
committed
Test this.evaluate and this.compile on objects
This worked already; just for better coverage examples.
1 parent 1f52d52 commit be77679

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test.ls

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ test "macro env can create sexpr AST nodes equivalently to quoting" ->
646646
(m)"""
647647
with-quote `@equals` with-construct
648648

649-
test "macros can evaluate arguments to JS and convert them back again" ->
649+
test "macros can evaluate number arguments to JS and convert them back again" ->
650650
esl """
651651
(macro incrementedTimesTwo (lambda (x)
652652
(var y (+ 1 ((. this evaluate) x)))
@@ -656,6 +656,15 @@ test "macros can evaluate arguments to JS and convert them back again" ->
656656
"""
657657
..`@equals` "6 * 2;"
658658

659+
test "macros can evaluate macro-calling arguments to objects" ->
660+
esl """
661+
(macro printObject (lambda (objDefinition)
662+
(= obj ((. this evaluate) objDefinition))
663+
(return ((. this atom) ((. obj toString))))))
664+
(printObject (object a 1))
665+
"""
666+
..`@equals` "1;"
667+
659668
test "macros can unquote arrays into quasiquoted lists (non-splicing)" ->
660669
esl "(macro what (lambda (x)
661670
(return `(,x))))
@@ -1045,8 +1054,9 @@ test "macro can compile and return parameter as estree" ->
10451054
(that 3)
10461055
(that "hi")
10471056
(that (c))
1057+
(that (object a b))
10481058
'''
1049-
..`@equals` "3;\n'hi';\nc();"
1059+
..`@equals` "3;\n'hi';\nc();\n({ a: b });"
10501060
10511061
test "multiple invocations of the compiler are separate" ->
10521062
esl "(macro what (lambda () (return 'hi)))"

0 commit comments

Comments
 (0)