Start to transform SL into SM

This commit is contained in:
2019-10-07 20:14:40 +03:00
parent 8cac5c064d
commit 308670b90c
7 changed files with 69 additions and 25 deletions

View File

@ -0,0 +1,16 @@
require_relative "helper"
module SlotLanguage
class TestLoadMaker < MiniTest::Test
include SlotToHelper
def setup
super
left = SlotMaker.new(:hi )
right = SlotMaker.new(:hi )
@slot = LoadMaker.new( left,right ).to_slot(@compiler)
end
def test_to_slot
assert_equal SlotMachine::SlotLoad , @slot.class
end
end
end

View File

@ -7,11 +7,18 @@ module SlotLanguage
super
@slot = MacroMaker.load_string( mini_file ).to_slot(@compiler)
end
def test_to_slot
assert @slot.is_a?(SlotMachine::Instruction) , @slot.class
def test_label
assert_equal SlotMachine::Label , @slot.class
end
def test_assign
assert_equal SlotMachine::SlotLoad , @slot.next.class
assert_equal :message , @slot.next.left.known_object
assert_equal [:a] , @slot.next.left.slots
assert_equal :message , @slot.next.right.known_object
assert_equal [:b] , @slot.next.right.slots
end
def test_length
assert_equal 1 , @slot.length
assert_equal 2 , @slot.length
end
end

View File

@ -2,12 +2,13 @@ require_relative "helper"
module SlotLanguage
class TestSlotMaker < MiniTest::Test
include SlotHelper
def test_label
label = compile("while_label")
assert_equal SlotMachine::Label , label.class
assert_equal :while_label , label.name
include SlotToHelper
def setup
super
@maker = SlotMaker.new(:hi )
end
def test_slot
@maker.slot_def(@compiler)
end
end
end