rubyx/test/slot_machine/compiler/test_goto.rb
Torsten Rüger 8df2e4bf08 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.
2020-02-19 02:19:14 +07:00

37 lines
1017 B
Ruby

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