SlotLanguage reborn in the Machine
Just added the compiler, that can parse Slot directly into SlotMachine code (no language layer in between) Still unclear wheather the Maker is a thing, but since it was in the Language layer i did not remove it (yet) Otherwise just the compiler and all the tests, moved from the slot_language.
This commit is contained in:
36
test/slot_machine/compiler/test_goto.rb
Normal file
36
test/slot_machine/compiler/test_goto.rb
Normal file
@ -0,0 +1,36 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module SlotMachine
|
||||
class TestGoto < MiniTest::Test
|
||||
include SlotHelper
|
||||
|
||||
def test_goto_class
|
||||
assert_equal Jump , compile_class("goto(exit_label)")
|
||||
end
|
||||
def test_goto_label
|
||||
goto = compile("goto(exit_label)")
|
||||
assert_equal Jump , goto.class
|
||||
assert_equal :exit_label , goto.label.name
|
||||
end
|
||||
|
||||
def test_label
|
||||
label = compile("while_label")
|
||||
assert_equal SlotMachine::Label , label.class
|
||||
assert_equal :while_label , label.name
|
||||
end
|
||||
|
||||
def test_2_label
|
||||
labels = compile("exit_label;exit_label")
|
||||
assert_equal :exit_label , labels.name
|
||||
assert_equal :exit_label , labels.next.name
|
||||
assert_equal labels.object_id , labels.next.object_id
|
||||
end
|
||||
|
||||
def test_goto_with_label
|
||||
gotos = compile("exit_label;goto(exit_label)")
|
||||
assert_equal :exit_label , gotos.name
|
||||
assert_equal :exit_label , gotos.next.label.name
|
||||
assert_equal gotos.object_id , gotos.next.label.object_id
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user