move slot out of instruction dir

since it is not an instruction, just a helper
also doing this before rewriting slot recursively
This commit is contained in:
2020-02-15 14:52:44 +07:00
parent 24ceb20281
commit 6aa6b32c50
10 changed files with 5 additions and 5 deletions

View File

@ -1,53 +0,0 @@
require_relative "helper"
module SlotMachine
class TestSlotConstant < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = Risc::FakeCompiler.new
@definition = Slot.for(StringConstant.new("hi") , [])
@register = @definition.to_register(@compiler , InstructionMock.new)
@instruction = @compiler.instructions.first
end
def test_def_class
assert_equal Risc::LoadConstant , @instruction.class
end
def test_def_register
assert_equal :r1 , @instruction.register.symbol
end
def test_def_const
assert_equal "hi" , @instruction.constant.to_string
end
def test_to_s
assert_equal "[StringConstant]" , @definition.to_s
end
end
class TestSlotConstantType < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = Risc::FakeCompiler.new
@definition = Slot.for(StringConstant.new("hi") , [:type])
@register = @definition.to_register(@compiler , InstructionMock.new)
@instruction = @compiler.instructions.first
end
def test_def_class
assert_equal Risc::LoadConstant , @instruction.class
end
def test_def_register
assert_equal :r1 , @instruction.register.symbol
end
def test_def_const
assert_equal "hi" , @instruction.constant.to_string
end
def test_to_s
assert_equal "[StringConstant, type]" , @definition.to_s
end
def test_def_register2
assert_equal :r1 , @compiler.instructions[1].register.symbol
end
def test_def_next_index
assert_equal 0 , @compiler.instructions[1].index
end
end
end

View File

@ -1,23 +0,0 @@
require_relative "helper"
module SlotMachine
class TestSlotBasics < MiniTest::Test
def slot(slot = :caller)
MessageSlot.new(slot)
end
def test_create_ok1
assert_equal :message , slot.known_object
end
def test_create_ok2
assert_equal Array , slot.slots.class
assert_equal :caller , slot.slots.first
end
def test_to_s
assert_equal "[message, caller]" , slot.to_s
end
def test_create_fail_none
assert_raises {slot(nil)}
end
end
end

View File

@ -1,23 +0,0 @@
require_relative "helper"
module SlotMachine
class TestSlotBasics < MiniTest::Test
def slot(slot = :caller)
MessageSlot.new(slot)
end
def test_create_ok1
assert_equal :message , slot.known_object
end
def test_create_ok2
assert_equal Array , slot.slots.class
assert_equal :caller , slot.slots.first
end
def test_to_s
assert_equal "[message, caller]" , slot.to_s
end
def test_create_fail_none
assert_raises {slot(nil)}
end
end
end

View File

@ -1,28 +0,0 @@
require_relative "helper"
module SlotMachine
class TestSlotKnown1 < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = Risc::FakeCompiler.new
@definition = MessageSlot.new( :caller)
@register = @definition.to_register(@compiler , "fake source")
@instruction = @compiler.instructions.first
end
def test_def_class
assert_equal Risc::SlotToReg , @instruction.class
end
def test_def_next_class
assert_equal NilClass , @instruction.next.class
end
def test_def_array #from message r0
assert_equal :r0 , @instruction.array.symbol
end
def test_def_register # to next free register r1
assert_equal :r1 , @register.symbol
end
def test_def_index # at caller index 6
assert_equal 6 , @instruction.index
end
end
end