Fix comparison macro

which leaves a definite need for instruction level testing
This commit is contained in:
2020-03-03 22:35:23 +02:00
parent 2af953e1d2
commit 3688c967d3
5 changed files with 34 additions and 19 deletions

View File

@ -5,9 +5,9 @@ module Risc
def setup
Parfait.boot!(Parfait.default_test_options)
@r0 = RegisterValue.new(:message , :Message)
@r1 = RegisterValue.new(:id_1234 , :Space)
@compiler = Risc.test_compiler
@r0 = RegisterValue.new(:message , :Message).set_compiler(@compiler)
@r1 = RegisterValue.new(:id_1234 , :Space).set_compiler(@compiler)
end
def test_resolves_index_ok
@ -18,8 +18,10 @@ module Risc
end
def test_reduce_int
ins = @r0.reduce_int
assert_equal SlotToReg , ins.class
assert_equal Parfait::Integer.integer_index , ins.index
assert_equal RegisterValue , ins.class
assert_equal SlotToReg , @compiler.current.class
assert_equal Parfait::Integer.integer_index , @compiler.current.index
assert_equal :message , ins.symbol
end
def test_get_new_left_0
assert_equal RegisterValue , @r0.get_new_left(:caller , @compiler).class

View File

@ -14,22 +14,23 @@ module SlotMachine
assert_equal Risc::MethodCompiler , @method.to_risc.class
end
def test_risc_length
assert_equal 26 , @method.to_risc.risc_instructions.length
assert_equal 25 , @method.to_risc.risc_instructions.length
end
#TODO, check the actual instructions, at least by class
end
class TestIntComp2Risc < BootTest
def setup
@method = get_compiler("Integer",:gt)
@method = get_compiler("Integer",:ge)
end
def test_slot_length
assert_equal :> , @method.callable.name
assert_equal :>= , @method.callable.name
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class
end
def test_risc_length
assert_equal 26 , @method.to_risc.risc_instructions.length
assert_equal 24 , @method.to_risc.risc_instructions.length
end
end
end