More instruction tests
This commit is contained in:
parent
b46512a1b8
commit
830fe2ab2b
15
test/mom/instruction/test_jump.rb
Normal file
15
test/mom/instruction/test_jump.rb
Normal file
@ -0,0 +1,15 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestJump < MomInstructionTest
|
||||
def instruction
|
||||
Jump.new( Label.new("ok" , "target"))
|
||||
end
|
||||
def test_len
|
||||
assert_equal 2 , all.length , all_str
|
||||
end
|
||||
def test_1_slot
|
||||
assert_branch risc(1) , "target"
|
||||
end
|
||||
end
|
||||
end
|
46
test/mom/instruction/test_message_setup.rb
Normal file
46
test/mom/instruction/test_message_setup.rb
Normal file
@ -0,0 +1,46 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestMessageSetupInt < MomInstructionTest
|
||||
def instruction
|
||||
MessageSetup.new( 1 )
|
||||
end
|
||||
def test_len
|
||||
assert_equal 4 , all.length , all_str
|
||||
end
|
||||
def test_1_slot
|
||||
assert_slot_to_reg risc(1) ,:r0 , 9 , :r1
|
||||
end
|
||||
def test_2_slot
|
||||
assert_slot_to_reg risc(2) ,:r0 , 1 , :r2
|
||||
end
|
||||
end
|
||||
def test_3_reg
|
||||
assert_reg_to_slot risc(3) , :r1 , :r2 , 4
|
||||
end
|
||||
class TestMessageSetupCache < MomInstructionTest
|
||||
include Parfait::MethodHelper
|
||||
|
||||
def instruction
|
||||
method = make_method
|
||||
cache_entry = Parfait::CacheEntry.new(method.frame_type, method)
|
||||
MessageSetup.new( cache_entry )
|
||||
end
|
||||
def test_len
|
||||
assert_equal 5 , all.length , all_str
|
||||
end
|
||||
def test_1_load
|
||||
assert_load risc(1) , Parfait::CacheEntry , :r1
|
||||
end
|
||||
def test_2_slot
|
||||
assert_slot_to_reg risc(2) ,:r1 , 2 , :r2
|
||||
end
|
||||
def test_3_slot
|
||||
assert_slot_to_reg risc(3) ,:r0 , 1 , :r3
|
||||
end
|
||||
def test_4_reg
|
||||
assert_reg_to_slot risc(4) , :r2 , :r3 , 7
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -16,14 +16,10 @@ module Mom
|
||||
assert_slot_to_reg risc(2) ,:r0 , 6 , :r4
|
||||
end
|
||||
def test_3_op
|
||||
assert_equal Risc::OperatorInstruction , risc(3).class
|
||||
assert_equal :r2 , risc(3).left.symbol
|
||||
assert_equal :r4 , risc(3).right.symbol
|
||||
assert_equal :- , risc(3).operator
|
||||
assert_operator risc(3) , :-, :r2 , :r4
|
||||
end
|
||||
def test_4_zero
|
||||
assert_equal Risc::IsZero , risc(4).class
|
||||
assert_label risc(4).label , "target"
|
||||
assert_zero risc(4) , "target"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user