if and goto for slot_language

This commit is contained in:
2019-10-05 14:49:45 +03:00
parent 9885841eb4
commit 2c7944af85
5 changed files with 59 additions and 11 deletions

View File

@ -6,7 +6,7 @@ module SlotLanguage
SlotCompiler.compile(input)
end
def compile_class(input)
compile.class
compile(input).class
end
end
end

View File

@ -19,7 +19,15 @@ module SlotLanguage
assert_equal :while_label , label.name
end
def test_slot_load
compile("a = @b")
assert_equal Sol::LocalAssignment , compile_class("a = @b")
end
def test_goto
assert_equal SlotMachine::Jump , compile_class("goto(exit_label)")
end
def test_if
check = compile("goto(exit_label) if(a == b)")
assert_equal CheckMaker , check.class
assert_equal SlotMachine::Jump , check.goto.class
end
end
end