mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
37 lines
799 B
Plaintext
37 lines
799 B
Plaintext
|
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)
|
||
|
|
||
|
|