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-13 14:50:50 +01:00
|
|
|
def test_len
|
2020-03-22 14:58:19 +01:00
|
|
|
assert_equal 20 , all.length , all_str
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_load_name
|
2020-03-25 11:43:57 +01:00
|
|
|
assert_load 1, Symbol , "id_symbol_"
|
|
|
|
assert_equal "name" , risc(1).constant.to_s
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_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
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_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
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_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
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_start_label
|
2020-03-25 11:43:57 +01:00
|
|
|
assert_label 5 , "resolve_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_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
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_check_nil
|
2020-03-14 11:47:29 +01:00
|
|
|
assert_operator 7, :- , "id_nilclass_" , "id_cacheentry_.cached_type.methods" , "op_-_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_nil_branch
|
2020-03-08 16:31:39 +01:00
|
|
|
assert_zero 8, "exit_label_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_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
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_check_name
|
2020-03-25 11:43:57 +01:00
|
|
|
assert_operator 10, :- , "id_cacheentry_.cached_type.methods.name" , "id_symbol_" , "op_-_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_nil_branch
|
2020-03-25 11:43:57 +01:00
|
|
|
assert_zero 11, "ok_resolve_name_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_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
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_trans
|
|
|
|
assert_transfer 13 , "id_cacheentry_.cached_type.methods.next" , "id_cacheentry_.cached_type.methods"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_continue_while
|
2020-03-25 11:43:57 +01:00
|
|
|
assert_branch 14, "resolve_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_goto_exit
|
2020-03-25 11:43:57 +01:00
|
|
|
assert_label 15, "exit_resolve_name_"
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_move_name
|
2020-03-25 11:43:57 +01:00
|
|
|
assert_transfer 16, "id_symbol_" , :r1
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_sys
|
2020-03-22 14:58:19 +01:00
|
|
|
assert_syscall 17, :died
|
2019-09-17 19:18:00 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_label
|
2020-03-25 11:43:57 +01:00
|
|
|
assert_label 18, "ok_resolve_name_"
|
2020-03-13 14:50:50 +01:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_method
|
2020-03-22 14:58:19 +01:00
|
|
|
assert_reg_to_slot 19 , "id_cacheentry_.cached_type.methods" , "id_cacheentry_" , 2
|
2019-09-17 09:18:45 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|