Skip to content

Commit b367f7e

Browse files
committed
more ast
1 parent e75fcef commit b367f7e

File tree

1 file changed

+83
-7
lines changed

1 file changed

+83
-7
lines changed

spec/compiler_spec.moon

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,30 @@ describe "moonscript.compile", ->
3030
"hello_world"
3131
}
3232

33+
{
34+
"number"
35+
-> {"number", "14"}
36+
"14"
37+
}
38+
39+
{
40+
"minus"
41+
-> {"minus", ref!}
42+
"-val"
43+
}
44+
3345
{
3446
"explist"
3547
-> { "explist", ref("a"), ref("b"), ref("c")}
3648
"a, b, c"
3749
}
3850

51+
{
52+
"exp"
53+
-> {"exp", ref("a"), "+", ref("b"), "!=", ref("c")}
54+
"a + b ~= c"
55+
}
56+
3957
{
4058
"parens"
4159
-> { "parens", ref! }
@@ -61,6 +79,48 @@ describe "moonscript.compile", ->
6179
"[==[Hello's world]==]"
6280
}
6381

82+
{
83+
"self"
84+
-> {"self", ref!}
85+
"self.val"
86+
}
87+
88+
{
89+
"self_class"
90+
-> {"self_class", ref!}
91+
"self.__class.val"
92+
}
93+
94+
{
95+
"self_class_colon"
96+
-> {"self_class_colon", ref!}
97+
"self.__class:val"
98+
}
99+
100+
{
101+
"not"
102+
-> {"not", ref!}
103+
"not val"
104+
}
105+
106+
{
107+
"length"
108+
-> {"length", ref!}
109+
"#val"
110+
}
111+
112+
{
113+
"length"
114+
-> {"length", ref!}
115+
"#val"
116+
}
117+
118+
{
119+
"bitnot"
120+
-> {"bitnot", ref!}
121+
"~val"
122+
}
123+
64124
{
65125
"chain (single)"
66126
-> {"chain", ref!}
@@ -89,16 +149,32 @@ describe "moonscript.compile", ->
89149
{
90150
"chain"
91151
-> {
92-
"chain"
93-
ref!
94-
{"dot", "one"}
95-
{"index", str!}
96-
{"colon", "two"}
97-
{"call", { ref("arg") }}
98-
}
152+
"chain"
153+
ref!
154+
{"dot", "one"}
155+
{"index", str!}
156+
{"colon", "two"}
157+
{"call", { ref("arg") }}
158+
}
99159
'val.one["dogzone"]:two(arg)'
100160
}
101161

162+
{
163+
"chain (self receiver)"
164+
-> {
165+
"chain"
166+
{"self", ref!}
167+
{"call", {ref "arg"} }
168+
}
169+
"self:val(arg)"
170+
}
171+
172+
{
173+
"fndef (empty)"
174+
-> {"fndef", {}, {}, "slim", {}}
175+
"function() end"
176+
}
177+
102178
}
103179
it "compiles #{name}", ->
104180
node = node!

0 commit comments

Comments
 (0)