fix bug in slot_load and definition
move parfait helper for reuse
This commit is contained in:
@ -11,12 +11,14 @@ module Mom
|
||||
@instructions = @compiler.instructions
|
||||
end
|
||||
|
||||
def test_ins_next_class
|
||||
def test_ins_next_classes
|
||||
assert_equal Risc::SlotToReg , @instructions[0].class
|
||||
assert_equal Risc::SlotToReg , @instructions[1].class
|
||||
assert_equal Risc::SlotToReg , @instructions[2].class
|
||||
end
|
||||
def test_ins_next_next_class
|
||||
assert_equal Risc::RegToSlot , @instructions[3].class
|
||||
assert_equal NilClass , @instructions[4].class
|
||||
end
|
||||
|
||||
def test_ins_next_reg
|
||||
|
50
test/mom/instruction/test_slot_load3.rb
Normal file
50
test/mom/instruction/test_slot_load3.rb
Normal file
@ -0,0 +1,50 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestSlotLoad3 < Parfait::ParfaitTest
|
||||
|
||||
def setup
|
||||
super
|
||||
method = make_method
|
||||
@compiler = Risc::FakeCompiler.new
|
||||
@cache_entry = Parfait::CacheEntry.new(method.frame_type, method)
|
||||
load = SlotLoad.new( [@cache_entry , :cached_type] , [:message, :type] )
|
||||
load.to_risc(@compiler)
|
||||
@instructions = @compiler.instructions
|
||||
end
|
||||
def test_ins_next_class
|
||||
assert_equal Risc::SlotToReg , @instructions[0].class
|
||||
assert_equal Risc::LoadConstant, @instructions[1].class
|
||||
end
|
||||
|
||||
def test_ins_next_class
|
||||
assert_equal Risc::RegToSlot , @instructions[2].class
|
||||
assert_equal NilClass , @instructions[3].class
|
||||
end
|
||||
def test_ins_load
|
||||
assert_equal :r1 , @instructions[1].register.symbol
|
||||
assert_equal Parfait::CacheEntry , @instructions[1].constant.class
|
||||
end
|
||||
|
||||
def test_ins_next_reg
|
||||
assert_equal :r1 , @instructions[0].register.symbol
|
||||
end
|
||||
def test_ins_next_arr
|
||||
assert_equal :r0 , @instructions[0].array.symbol
|
||||
end
|
||||
def test_ins_next_index
|
||||
assert_equal 0 , @instructions[0].index
|
||||
end
|
||||
|
||||
def test_ins_next_2_reg
|
||||
assert_equal :r1 , @instructions[2].register.symbol
|
||||
end
|
||||
def test_ins_next_2_arr
|
||||
assert_equal :r1 , @instructions[2].array.symbol
|
||||
end
|
||||
def test_ins_next_2_index
|
||||
assert_equal 1 , @instructions[2].index
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user