moonscript/spec/compiler_spec.moon

37 lines
799 B
Plaintext
Raw Normal View History

2016-11-23 07:50:48 +00:00
import Block from require "moonscript.compile"
import ref from require "spec.factory"
-- no transform step
class SimpleBlock extends Block
new: (...) =>
super ...
@transform = {
value: (...) -> ...
statement: (...) -> ...
}
value = require "moonscript.compile.value"
describe "moonscript.compile", ->
compile_node = (node) ->
block = SimpleBlock!
block\add block\value node
lines = block._lines\flatten!
lines[#lines] = nil if lines[#lines] == "\n"
table.concat lines
-- compiling lua ast
describe "value", ->
for {name, node, expected} in *{
{
"ref"
-> {"ref", "hello_world"}
"hello_world"
}
}
it "compiles #{name}", ->
node = node!
assert.same expected, compile_node(node)