2019-09-17 09:18:45 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Mom
|
|
|
|
class TestResolveMethod < MomInstructionTest
|
|
|
|
include Parfait::MethodHelper
|
|
|
|
|
|
|
|
def instruction
|
|
|
|
method = make_method
|
|
|
|
cache_entry = Parfait::CacheEntry.new(method.frame_type, method)
|
|
|
|
ResolveMethod.new( "method" , :name , cache_entry )
|
|
|
|
end
|
|
|
|
def test_len
|
2019-09-17 15:08:49 +02:00
|
|
|
assert_equal 18 , all.length , all_str
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_1_load_name
|
|
|
|
assert_load risc(1) , Symbol , :r1
|
|
|
|
assert_equal :name , risc(1).constant
|
|
|
|
end
|
|
|
|
def test_2_load_cache
|
|
|
|
assert_load risc(2) , Parfait::CacheEntry , :r2
|
|
|
|
end
|
|
|
|
def test_3_get_cache_type
|
|
|
|
assert_slot_to_reg risc(3) ,:r2 , 1 , :r3
|
|
|
|
end
|
|
|
|
def test_4_get_type_methods
|
|
|
|
assert_slot_to_reg risc(4) ,:r3 , 4 , :r4
|
|
|
|
end
|
|
|
|
def test_5_start_label
|
|
|
|
assert_label risc(5) , "while_start_"
|
|
|
|
end
|
|
|
|
def test_6_load_nil
|
|
|
|
assert_load risc(6) , Parfait::NilClass , :r5
|
|
|
|
end
|
|
|
|
def test_7_check_nil
|
|
|
|
assert_operator risc(7) , :- , :r5 , :r4
|
|
|
|
end
|
|
|
|
def test_8_nil_branch
|
|
|
|
assert_zero risc(8) , "exit_label_"
|
|
|
|
end
|
|
|
|
def test_9_get_method_name
|
|
|
|
assert_slot_to_reg risc(9) ,:r4 , 6 , :r6
|
|
|
|
end
|
2019-09-17 15:08:49 +02:00
|
|
|
# Syscall, Label, RegToSlot,] #20
|
2019-09-17 09:18:45 +02:00
|
|
|
def test_10_check_name
|
|
|
|
assert_operator risc(10) , :- , :r6 , :r1
|
|
|
|
end
|
|
|
|
def test_11_nil_branch
|
|
|
|
assert_zero risc(11) , "ok_label_"
|
|
|
|
end
|
|
|
|
def test_12_get_next_method
|
|
|
|
assert_slot_to_reg risc(12) ,:r4 , 2 , :r4
|
|
|
|
end
|
|
|
|
def test_13_continue_while
|
|
|
|
assert_branch risc(13) , "while_start_"
|
|
|
|
end
|
|
|
|
def test_14_goto_exit
|
|
|
|
assert_label risc(14) , "exit_label_"
|
|
|
|
end
|
2019-09-17 15:08:49 +02:00
|
|
|
def test_15_die
|
|
|
|
assert_syscall risc(15) , :died
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2019-09-17 15:08:49 +02:00
|
|
|
def test_16_label
|
|
|
|
assert_label risc(16) , "ok_label_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2019-09-17 15:08:49 +02:00
|
|
|
def test_17_load_method
|
|
|
|
assert_reg_to_slot risc(17) , :r4 , :r2 , 2
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|