Continue testing mom instructions

especially with the custom asserts, gadda say
mesa lika disa
This commit is contained in:
2019-09-15 18:31:10 +03:00
parent 6f108f67d7
commit 5ab021de5a
8 changed files with 73 additions and 7 deletions

View File

@ -12,7 +12,7 @@ module Mom
def setup
Parfait.boot!(Parfait.default_test_options)
@instruction = instruction
@compiler = Risc::MethodCompiler.new(FakeCallable.new , Label.new("source","start"))
@compiler = Risc::MethodCompiler.new(Risc::FakeCallable.new , Label.new("source","start"))
@instruction.to_risc(@compiler)
@risc = @compiler.risc_instructions
end

View File

@ -0,0 +1,29 @@
require_relative "helper"
module Mom
class TestArgumentTransfer < MomInstructionTest
def instruction
receiver = SlotDefinition.new(:message , [:receiver])
arg = SlotLoad.new("test", [:message, :caller] , [:message,:type] )
ArgumentTransfer.new("" , receiver ,[arg])
end
def test_len
assert_equal 6 , all.length , all_str
end
def test_1_slot
assert_slot_to_reg risc(1) ,:r0 , 2 , :r2
end
def test_2_slot
assert_slot_to_reg risc(2) ,:r0 , 1 , :r3
end
def test_3_reg
assert_reg_to_slot risc(3) , :r2 , :r3 , 2
end
def test_4_slot
assert_slot_to_reg risc(4) ,:r0 , 0 , :r2
end
def test_5_reg
assert_reg_to_slot risc(5) , :r2 , :r0 , 6
end
end
end

View File

@ -0,0 +1,35 @@
require_relative "helper"
module Mom
class TesBlockYield < MomInstructionTest
def instruction
BlockYield.new("source",1)
end
def test_len
assert_equal 8 , all.length , all_str
end
def test_1_slot
assert_slot_to_reg risc(1) ,:r0 , 1 , :r1
end
def test_2_load
assert_load risc(2) , Risc::Label , :r2
assert_label risc(2).constant , "continue_"
end
def test_3_reg
assert_reg_to_slot risc(3) , :r2 , :r1 , 4
end
def test_4_slot
assert_slot_to_reg risc(4) ,:r0 , 9 , :r3
end
def test_5_slot
assert_slot_to_reg risc(5) ,:r0 , 1 , :r0
end
def test_6_jump
assert_equal Risc::DynamicJump , risc(6).class
assert_equal :r3 , risc(6).register.symbol
end
def test_7_label
assert_label risc(7) , "continue_"
end
end
end

View File

@ -10,6 +10,7 @@ module Mom
end
def test_1_load
assert_load risc(1) , Risc::Label , :r1
assert_label risc(1).constant , "continue_"
end
def test_2_slot
assert_slot_to_reg risc(2) ,:r0 , 1 , :r2

View File

@ -8,7 +8,7 @@ module Mom
class TestCallableCompiler < MiniTest::Test
def setup
@compiler = FakeCallableCompiler.new(FakeCallable.new)
@compiler = FakeCallableCompiler.new(Risc::FakeCallable.new)
end
def test_ok
assert @compiler