This commit is contained in:
leaf corcoran 2016-11-23 08:42:24 -08:00
parent e75fceff68
commit b367f7ed51

View File

@ -30,12 +30,30 @@ describe "moonscript.compile", ->
"hello_world"
}
{
"number"
-> {"number", "14"}
"14"
}
{
"minus"
-> {"minus", ref!}
"-val"
}
{
"explist"
-> { "explist", ref("a"), ref("b"), ref("c")}
"a, b, c"
}
{
"exp"
-> {"exp", ref("a"), "+", ref("b"), "!=", ref("c")}
"a + b ~= c"
}
{
"parens"
-> { "parens", ref! }
@ -61,6 +79,48 @@ describe "moonscript.compile", ->
"[==[Hello's world]==]"
}
{
"self"
-> {"self", ref!}
"self.val"
}
{
"self_class"
-> {"self_class", ref!}
"self.__class.val"
}
{
"self_class_colon"
-> {"self_class_colon", ref!}
"self.__class:val"
}
{
"not"
-> {"not", ref!}
"not val"
}
{
"length"
-> {"length", ref!}
"#val"
}
{
"length"
-> {"length", ref!}
"#val"
}
{
"bitnot"
-> {"bitnot", ref!}
"~val"
}
{
"chain (single)"
-> {"chain", ref!}
@ -89,16 +149,32 @@ describe "moonscript.compile", ->
{
"chain"
-> {
"chain"
ref!
{"dot", "one"}
{"index", str!}
{"colon", "two"}
{"call", { ref("arg") }}
}
"chain"
ref!
{"dot", "one"}
{"index", str!}
{"colon", "two"}
{"call", { ref("arg") }}
}
'val.one["dogzone"]:two(arg)'
}
{
"chain (self receiver)"
-> {
"chain"
{"self", ref!}
{"call", {ref "arg"} }
}
"self:val(arg)"
}
{
"fndef (empty)"
-> {"fndef", {}, {}, "slim", {}}
"function() end"
}
}
it "compiles #{name}", ->
node = node!