fix get_internal_byte

improved operators and tests
some logic errors still
This commit is contained in:
2020-03-09 12:47:12 +02:00
parent a70f63e7bb
commit fb4fa598f2
9 changed files with 46 additions and 45 deletions

View File

@ -2,6 +2,7 @@ require_relative "../helper"
module Risc
class TestRegisterSlot1 < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = Risc.test_compiler
@ -73,6 +74,7 @@ module Risc
end
end
class TestRegisterSlot4 < MiniTest::Test
include HasCompiler
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = Risc.test_compiler
@ -85,14 +87,12 @@ module Risc
assert_equal NilClass , @compiler.risc_instructions.next(3).class
end
def test_slot_to
slot = @compiler.risc_instructions.next(1)
assert_slot_to_reg slot , :message, 1, :"message.next_message"
assert slot.register.compiler
assert_slot_to_reg 1 , :message, 1, :"message.next_message"
assert risc(1).register.compiler
end
def test_reg_to
reg = @compiler.risc_instructions.next(2)
assert_reg_to_slot reg , :message, :"message.next_message" , 4
assert reg.register.compiler
assert_reg_to_slot 2 , :message, :"message.next_message" , 4
assert risc(2).register.compiler
end
end
end

View File

@ -59,22 +59,22 @@ module Risc
assert_operator ret , :<< , :message , "id_.type"
end
def test_byte_to_reg
instr = @r0 <= @r1[1]
instr = @r0 <= @r1[@r0]
assert_equal ByteToReg , instr.class
assert_equal @r1 , instr.array
assert_equal @r0 , instr.register
assert_equal 1 , instr.index
assert_equal @r0 , instr.index
end
def test_slot_to_reg
instr = @r0 << @r2[:next_object]
assert_slot_to_reg instr , "id_" , 2 , :message
end
def test_reg_to_byte
instr = @r1[1] <= @r0
instr = @r1[@r0] <= @r0
assert_equal RegToByte , instr.class
assert_equal @r1 , instr.array
assert_equal @r0 , instr.register
assert_equal 1 , instr.index
assert_equal @r0 , instr.index
end
end
end