more slot tests, also in separate files
This commit is contained in:
parent
36e59ebdea
commit
9597fc5756
@ -17,38 +17,4 @@ module Mom
|
||||
assert_raises {slot(nil)}
|
||||
end
|
||||
end
|
||||
class TestSlotDefinitionConstant < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@compiler = CompilerMock.new
|
||||
@definition = SlotDefinition.new(StringConstant.new("hi") , [])
|
||||
@instruction = @definition.to_register(@compiler , InstructionMock.new)
|
||||
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
|
||||
end
|
||||
class TestSlotDefinitionKnown1 < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@compiler = CompilerMock.new
|
||||
@definition = SlotDefinition.new(:message , :caller)
|
||||
@instruction = @definition.to_register(@compiler , InstructionMock.new)
|
||||
end
|
||||
def test_def_class
|
||||
assert_equal Risc::SlotToReg , @instruction.class
|
||||
end
|
||||
def test_def_array
|
||||
assert_equal :r0 , @instruction.array.symbol
|
||||
end
|
||||
def test_def_register
|
||||
assert_equal :r1 , @instruction.register.symbol
|
||||
end
|
||||
end
|
||||
end
|
||||
|
22
test/mom/instruction/test_slot_definition1.rb
Normal file
22
test/mom/instruction/test_slot_definition1.rb
Normal file
@ -0,0 +1,22 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
|
||||
class TestSlotDefinitionConstant < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@compiler = CompilerMock.new
|
||||
@definition = SlotDefinition.new(StringConstant.new("hi") , [])
|
||||
@instruction = @definition.to_register(@compiler , InstructionMock.new)
|
||||
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
|
||||
end
|
||||
end
|
27
test/mom/instruction/test_slot_definition2.rb
Normal file
27
test/mom/instruction/test_slot_definition2.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestSlotDefinitionKnown1 < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@compiler = CompilerMock.new
|
||||
@definition = SlotDefinition.new(:message , :caller)
|
||||
@instruction = @definition.to_register(@compiler , InstructionMock.new)
|
||||
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 , @instruction.register.symbol
|
||||
end
|
||||
def test_def_index # at caller index 6
|
||||
assert_equal 6 , @instruction.index
|
||||
end
|
||||
end
|
||||
end
|
27
test/mom/instruction/test_slot_definition3.rb
Normal file
27
test/mom/instruction/test_slot_definition3.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestSlotDefinitionKnown2 < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@compiler = CompilerMock.new
|
||||
@definition = SlotDefinition.new(:message , [:caller , :type])
|
||||
@instruction = @definition.to_register(@compiler , InstructionMock.new)
|
||||
end
|
||||
def test_def_next_class
|
||||
assert_equal Risc::SlotToReg , @instruction.next.class
|
||||
end
|
||||
def test_def_next_next_class
|
||||
assert_equal NilClass , @instruction.next.next.class
|
||||
end
|
||||
def test_def_next_index
|
||||
assert_equal 0 , @instruction.next.index
|
||||
end
|
||||
def test_def_next_register
|
||||
assert_equal :r1 , @instruction.next.register.symbol
|
||||
end
|
||||
def test_def_next_array
|
||||
assert_equal :r1 , @instruction.next.array.symbol
|
||||
end
|
||||
end
|
||||
end
|
@ -18,38 +18,4 @@ module Mom
|
||||
assert_raises {@load.to_risc(CompilerMock.new)}
|
||||
end
|
||||
end
|
||||
class TestSlotLoadFunction < MiniTest::Test
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@load = SlotLoad.new( [:message, :caller] , [:message,:type] )
|
||||
@compiler = CompilerMock.new
|
||||
@instruction = @load.to_risc(@compiler)
|
||||
end
|
||||
|
||||
def test_ins_class
|
||||
assert_equal Risc::SlotToReg , @instruction.class
|
||||
end
|
||||
def test_ins_next_class
|
||||
assert_equal Risc::RegToSlot , @instruction.next.class
|
||||
end
|
||||
def test_ins_arr
|
||||
assert_equal :r0 , @instruction.array.symbol
|
||||
end
|
||||
def test_ins_reg
|
||||
assert_equal :r1 , @instruction.register.symbol
|
||||
end
|
||||
def test_ins_index
|
||||
assert_equal 0 , @instruction.index
|
||||
end
|
||||
def test_ins_next_reg
|
||||
assert_equal :r1 , @instruction.next.register.symbol
|
||||
end
|
||||
def test_ins_next_arr
|
||||
assert_equal :r0 , @instruction.next.array.symbol
|
||||
end
|
||||
def test_ins_next_index
|
||||
assert_equal 6 , @instruction.next.index
|
||||
end
|
||||
end
|
||||
end
|
||||
|
38
test/mom/instruction/test_slot_load1.rb
Normal file
38
test/mom/instruction/test_slot_load1.rb
Normal file
@ -0,0 +1,38 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestSlotLoad1 < MiniTest::Test
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@load = SlotLoad.new( [:message, :caller] , [:message,:type] )
|
||||
@compiler = CompilerMock.new
|
||||
@instruction = @load.to_risc(@compiler)
|
||||
end
|
||||
|
||||
def test_ins_class
|
||||
assert_equal Risc::SlotToReg , @instruction.class
|
||||
end
|
||||
def test_ins_next_class
|
||||
assert_equal Risc::RegToSlot , @instruction.next.class
|
||||
end
|
||||
def test_ins_arr
|
||||
assert_equal :r0 , @instruction.array.symbol
|
||||
end
|
||||
def test_ins_reg
|
||||
assert_equal :r1 , @instruction.register.symbol
|
||||
end
|
||||
def test_ins_index
|
||||
assert_equal 0 , @instruction.index
|
||||
end
|
||||
def test_ins_next_reg
|
||||
assert_equal :r1 , @instruction.next.register.symbol
|
||||
end
|
||||
def test_ins_next_arr
|
||||
assert_equal :r0 , @instruction.next.array.symbol
|
||||
end
|
||||
def test_ins_next_index
|
||||
assert_equal 6 , @instruction.next.index
|
||||
end
|
||||
end
|
||||
end
|
40
test/mom/instruction/test_slot_load2.rb
Normal file
40
test/mom/instruction/test_slot_load2.rb
Normal file
@ -0,0 +1,40 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestSlotLoad2 < MiniTest::Test
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@load = SlotLoad.new( [:message, :caller] , [:message, :caller , :type] )
|
||||
@compiler = CompilerMock.new
|
||||
@instruction = @load.to_risc(@compiler)
|
||||
end
|
||||
|
||||
def test_ins_next_class
|
||||
assert_equal Risc::SlotToReg , @instruction.next.class
|
||||
end
|
||||
def test_ins_next_next_class
|
||||
assert_equal Risc::RegToSlot , @instruction.next.next.class
|
||||
end
|
||||
|
||||
def test_ins_next_reg
|
||||
assert_equal :r1 , @instruction.next.register.symbol
|
||||
end
|
||||
def test_ins_next_arr
|
||||
assert_equal :r1 , @instruction.next.array.symbol
|
||||
end
|
||||
def test_ins_next_index
|
||||
assert_equal 0 , @instruction.next.index
|
||||
end
|
||||
|
||||
def test_ins_next_next_reg
|
||||
assert_equal :r1 , @instruction.next.next.register.symbol
|
||||
end
|
||||
def test_ins_next_next_arr
|
||||
assert_equal :r0 , @instruction.next.next.array.symbol
|
||||
end
|
||||
def test_ins_next_next_index
|
||||
assert_equal 6 , @instruction.next.next.index
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user