fix allocate tests

as allocate got one smaller
This commit is contained in:
Torsten 2020-03-09 19:22:24 +02:00
parent 8abcaa330b
commit 7d8ef8ef64
4 changed files with 81 additions and 78 deletions

View File

@ -14,54 +14,55 @@ module SlotMachine
assert_equal Risc::MethodCompiler , @method.to_risc.class
end
def test_risc_length
assert_equal 69 , @method.to_risc.risc_instructions.length
assert_equal 68 , @method.to_risc.risc_instructions.length
end
def test_allocate
assert_allocate
end
def test_return
assert_return(61)
assert_return(60)
end
def test_all
assert_slot_to_reg 23 , "message" , 2 , "message.receiver"
assert_slot_to_reg 24 , "message.receiver" , 2 , "message.receiver.data_1"
assert_transfer 25 , "message.receiver.data_1" , "integer_1"
assert_transfer 26 , "message.receiver.data_1" , "integer_reg"
assert_data 27 , 1
assert_operator 28 , :>> , :integer_1 , :integer_const
assert_data 29 , 2
assert_operator 30 , :>> , :integer_reg , :integer_const
assert_operator 31 , :+ , :integer_reg , :integer_1
assert_data 32 , 4
assert_transfer 33 , :integer_reg , :integer_1
assert_operator 34 , :>> , :integer_reg , :integer_1
assert_operator 35 , :+ , :integer_reg , :integer_1
assert_data 36 , 8
assert_transfer 37 , :integer_reg , :integer_1
assert_operator 38 , :>> , :integer_1 , :integer_const
assert_operator 39 , :+ , :integer_reg , :integer_1
assert_data 40 , 16
assert_transfer 41 , :integer_reg , :integer_1
assert_operator 42 , :>> , :integer_1 , :integer_const
assert_operator 43 , :+ , :integer_reg , :integer_1
assert_data 44 , 3
assert_operator 45 , :>> , :integer_reg , :integer_const
assert_data 46 , 10
assert_transfer 47 , :integer_reg , :integer_1
assert_operator 48 , :* , :integer_1 , :integer_const
assert_operator 49 , :- , "message.receiver.data_1" , :integer_1
assert_transfer 50 , "message.receiver.data_1" , :integer_1
assert_data 51 , 6
assert_operator 52 , :+ , :integer_1 , :integer_const
assert_data 53 , 4
assert_operator 54 , :>> , :integer_1 , :integer_const
assert_operator 55 , :+ , :integer_reg , :integer_1
assert_reg_to_slot 56 , :integer_reg , "id_factory_.next_object" , 2
assert_reg_to_slot 57 , "id_factory_.next_object" , :message , 5
assert_slot_to_reg 58 ,:message , 5 , "message.return_value"
assert_reg_to_slot 59 , "message.return_value" , :message , 5
assert_branch 60 , "return_label"
assert_label 61 , "return_label"
a = Risc.allocate_length
assert_slot_to_reg a + 1 , "message" , 2 , "message.receiver"
assert_slot_to_reg a + 2 , "message.receiver" , 2 , "message.receiver.data_1"
assert_transfer a + 3 , "message.receiver.data_1" , "integer_1"
assert_transfer a + 4 , "message.receiver.data_1" , "integer_reg"
assert_data a + 5 , 1
assert_operator a + 6 , :>> , :integer_1 , :integer_const
assert_data a + 7 , 2
assert_operator a + 8 , :>> , :integer_reg , :integer_const
assert_operator a + 9 , :+ , :integer_reg , :integer_1
assert_data a + 10 , 4
assert_transfer a + 11 , :integer_reg , :integer_1
assert_operator a + 12 , :>> , :integer_reg , :integer_1
assert_operator a + 13 , :+ , :integer_reg , :integer_1
assert_data a + 14 , 8
assert_transfer a + 15 , :integer_reg , :integer_1
assert_operator a + 16 , :>> , :integer_1 , :integer_const
assert_operator a + 17 , :+ , :integer_reg , :integer_1
assert_data a + 18 , 16
assert_transfer a + 19 , :integer_reg , :integer_1
assert_operator a + 20 , :>> , :integer_1 , :integer_const
assert_operator a + 21 , :+ , :integer_reg , :integer_1
assert_data a + 22 , 3
assert_operator a + 23 , :>> , :integer_reg , :integer_const
assert_data a + 24 , 10
assert_transfer a + 25 , :integer_reg , :integer_1
assert_operator a + 26 , :* , :integer_1 , :integer_const
assert_operator a + 27 , :- , "message.receiver.data_1" , :integer_1
assert_transfer a + 28 , "message.receiver.data_1" , :integer_1
assert_data a + 29 , 6
assert_operator a + 30 , :+ , :integer_1 , :integer_const
assert_data a + 31 , 4
assert_operator a + 32 , :>> , :integer_1 , :integer_const
assert_operator a + 33 , :+ , :integer_reg , :integer_1
assert_reg_to_slot a + 34 , :integer_reg , "id_factory_.next_object" , 2
assert_reg_to_slot a + 35 , "id_factory_.next_object" , :message , 5
assert_slot_to_reg a + 36 ,:message , 5 , "message.return_value"
assert_reg_to_slot a + 37 , "message.return_value" , :message , 5
assert_branch a + 38 , "return_label"
assert_label a + 39 , "return_label"
end
end
end

View File

@ -15,24 +15,25 @@ module SlotMachine
assert_equal :div4 , @method.callable.name
end
def test_risc_length
assert_equal 40 , @method.to_risc.risc_instructions.length
assert_equal 39 , @method.to_risc.risc_instructions.length
end
def test_allocate
assert_allocate
end
def test_return
assert_return(32)
assert_return(31)
end
def test_all
assert_slot_to_reg 23 , :message , 2 , "message.receiver"
assert_slot_to_reg 24 , "message.receiver" , 2 , "message.receiver.data_1"
assert_data 25 , 2
assert_operator 26 , :>> , "message.receiver.data_1" , :integer_1
assert_reg_to_slot 27 ,"message.receiver.data_1" , "id_factory_.next_object" , 2
assert_reg_to_slot 28 ,"id_factory_.next_object" , :message , 5
assert_slot_to_reg 29 , :message , 5 , "message.return_value"
assert_reg_to_slot 30 , "message.return_value" , :message , 5
assert_branch 31 , "return_label"
a = Risc.allocate_length
assert_slot_to_reg a + 1 , :message , 2 , "message.receiver"
assert_slot_to_reg a + 2 , "message.receiver" , 2 , "message.receiver.data_1"
assert_data a + 3 , 2
assert_operator a + 4 , :>> , "message.receiver.data_1" , :integer_1
assert_reg_to_slot a + 5 ,"message.receiver.data_1" , "id_factory_.next_object" , 2
assert_reg_to_slot a + 6 ,"id_factory_.next_object" , :message , 5
assert_slot_to_reg a + 7 , :message , 5 , "message.return_value"
assert_reg_to_slot a + 8 , "message.return_value" , :message , 5
assert_branch a + 9 , "return_label"
end
end
end

View File

@ -15,24 +15,25 @@ module SlotMachine
assert_equal Risc::MethodCompiler , @method.to_risc.class
end
def test_risc_length
assert_equal 39 , @method.to_risc.risc_instructions.length
assert_equal 38 , @method.to_risc.risc_instructions.length
end
def test_allocate
assert_allocate
end
def test_all
assert_reg_to_slot 23 , "id_factory_.next_object" , :message , 5
assert_transfer 24 , :message , :saved_message
assert_slot_to_reg 25 ,:message , 5 , :message
assert_slot_to_reg 26 ,:message , 2 , "message.data_1"
assert_syscall 27 , :exit
assert_slot_to_reg 28 ,:message , 5 , "message.return_value"
assert_reg_to_slot 29 , "message.return_value" , :message , 5
assert_branch 30 , "return_label"
assert_label 31 , "return_label"
a = Risc.allocate_length
assert_reg_to_slot a + 1 , "id_factory_.next_object" , :message , 5
assert_transfer a + 2 , :message , :saved_message
assert_slot_to_reg a + 3 ,:message , 5 , :message
assert_slot_to_reg a + 4 ,:message , 2 , "message.data_1"
assert_syscall a + 5 , :exit
assert_slot_to_reg a + 6 ,:message , 5 , "message.return_value"
assert_reg_to_slot a + 7 , "message.return_value" , :message , 5
assert_branch a + 8 , "return_label"
assert_label a + 9 , "return_label"
end
def test_return
assert_return(31)
assert_return(30)
end
end
end

View File

@ -15,32 +15,32 @@ module SlotMachine
assert_equal Risc::MethodCompiler , @method.to_risc.class
end
def test_risc_length
assert_equal 40 , @method.to_risc.risc_instructions.length
assert_equal 39 , @method.to_risc.risc_instructions.length
end
def test_allocate
assert_allocate
end
def test_all
assert_slot_to_reg 23 ,:message , 2 , "message.receiver"
assert_slot_to_reg 24 ,:message , 9 , "message.arg1"
assert_slot_to_reg 25 ,"message.arg1" , 2 , "message.arg1.data_1"
assert_slot_to_reg 22 ,:message , 2 , "message.receiver"
assert_slot_to_reg 23 ,:message , 9 , "message.arg1"
assert_slot_to_reg 24 ,"message.arg1" , 2 , "message.arg1.data_1"
assert_equal Risc::ByteToReg , risc(26).class
assert_equal :"message.receiver" , risc(26).array.symbol
assert_equal :"message.receiver" , risc(26).register.symbol
assert_equal :"message.arg1.data_1" , risc(26).index.symbol
assert_equal Risc::ByteToReg , risc(25).class
assert_equal :"message.receiver" , risc(25).array.symbol
assert_equal :"message.receiver" , risc(25).register.symbol
assert_equal :"message.arg1.data_1" , risc(25).index.symbol
assert_reg_to_slot 27 , "message.receiver" , "id_factory_.next_object" , 2
assert_reg_to_slot 28 , "id_factory_.next_object" , :message , 5
assert_slot_to_reg 29 ,:message , 5 , "message.return_value"
assert_reg_to_slot 30 , "message.return_value" , :message , 5
assert_reg_to_slot 26 , "message.receiver" , "id_factory_.next_object" , 2
assert_reg_to_slot 27 , "id_factory_.next_object" , :message , 5
assert_slot_to_reg 28 ,:message , 5 , "message.return_value"
assert_reg_to_slot 29 , "message.return_value" , :message , 5
assert_branch 31 , "return_label"
assert_label 32 , "return_label"
assert_branch 30 , "return_label"
assert_label 31 , "return_label"
end
def test_return
assert_return(32)
assert_return(31)
end
end
end