2019-09-17 09:18:45 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-03 19:55:41 +02:00
|
|
|
module SlotMachine
|
|
|
|
class TestResolveMethod < SlotMachineInstructionTest
|
2019-09-17 09:18:45 +02:00
|
|
|
include Parfait::MethodHelper
|
|
|
|
|
|
|
|
def instruction
|
|
|
|
method = make_method
|
|
|
|
cache_entry = Parfait::CacheEntry.new(method.frame_type, method)
|
|
|
|
ResolveMethod.new( "method" , :name , cache_entry )
|
|
|
|
end
|
2020-03-08 17:48:39 +01:00
|
|
|
def est_len
|
2019-09-17 19:18:00 +02:00
|
|
|
assert_equal 19 , all.length , all_str
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_1_load_name
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_load 1, Parfait::Word , "id_word_"
|
|
|
|
assert_equal "name" , risc(1).constant.to_string
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_2_load_cache
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_load 2, Parfait::CacheEntry , "id_cacheentry_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_3_get_cache_type
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_slot_to_reg 3 , "id_cacheentry_" , 1 , "id_cacheentry_.cached_type"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_4_get_type_methods
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_slot_to_reg 4 , "id_cacheentry_.cached_type" , 4 , "id_cacheentry_.cached_type.methods"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_5_start_label
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_label 5 , "while_start_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_6_load_nil
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_load 6, Parfait::NilClass , "id_nilclass_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_7_check_nil
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_operator 7, :- , "id_nilclass_" , "id_cacheentry_.cached_type.methods"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_8_nil_branch
|
2020-03-08 16:31:39 +01:00
|
|
|
assert_zero 8, "exit_label_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_9_get_method_name
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_slot_to_reg 9, "id_cacheentry_.cached_type.methods" , 6 , "id_cacheentry_.cached_type.methods.name"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_10_check_name
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_operator 10, :- , "id_cacheentry_.cached_type.methods.name" , "id_word_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_11_nil_branch
|
2020-03-08 16:31:39 +01:00
|
|
|
assert_zero 11, "ok_label_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_12_get_next_method
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_slot_to_reg 12, "id_cacheentry_.cached_type.methods" , 2 , "id_cacheentry_.cached_type.methods.next_callable"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_13_continue_while
|
2020-03-08 16:31:39 +01:00
|
|
|
assert_branch 13, "while_start_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
def test_14_goto_exit
|
2020-03-08 16:31:39 +01:00
|
|
|
assert_label 14, "exit_label_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2019-09-17 19:18:00 +02:00
|
|
|
def test_15_move_name
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_transfer 15, "id_word_" , :r1
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2019-09-17 19:18:00 +02:00
|
|
|
def test_16_die
|
2020-03-08 16:31:39 +01:00
|
|
|
assert_syscall 16, :died
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2019-09-17 19:18:00 +02:00
|
|
|
def test_17_label
|
2020-03-08 16:31:39 +01:00
|
|
|
assert_label 17, "ok_label_"
|
2019-09-17 19:18:00 +02:00
|
|
|
end
|
|
|
|
def test_18_load_method
|
2020-03-08 17:48:39 +01:00
|
|
|
assert_reg_to_slot 18 , "id_cacheentry_.cached_type.methods.next_callable" , "id_cacheentry_" , 2
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|