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" "hello_world"
} }
{
"number"
-> {"number", "14"}
"14"
}
{
"minus"
-> {"minus", ref!}
"-val"
}
{ {
"explist" "explist"
-> { "explist", ref("a"), ref("b"), ref("c")} -> { "explist", ref("a"), ref("b"), ref("c")}
"a, b, c" "a, b, c"
} }
{
"exp"
-> {"exp", ref("a"), "+", ref("b"), "!=", ref("c")}
"a + b ~= c"
}
{ {
"parens" "parens"
-> { "parens", ref! } -> { "parens", ref! }
@ -61,6 +79,48 @@ describe "moonscript.compile", ->
"[==[Hello's world]==]" "[==[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 (single)"
-> {"chain", ref!} -> {"chain", ref!}
@ -89,16 +149,32 @@ describe "moonscript.compile", ->
{ {
"chain" "chain"
-> { -> {
"chain" "chain"
ref! ref!
{"dot", "one"} {"dot", "one"}
{"index", str!} {"index", str!}
{"colon", "two"} {"colon", "two"}
{"call", { ref("arg") }} {"call", { ref("arg") }}
} }
'val.one["dogzone"]:two(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}", -> it "compiles #{name}", ->
node = node! node = node!