rename typed_method to callable_method
seems to make the essence clearer also extracted base class
This commit is contained in:
@ -18,7 +18,7 @@ module Arm
|
||||
assert_equal :r1 , @codes.left
|
||||
end
|
||||
def test_slot_right
|
||||
assert_equal 16 , @codes.right
|
||||
assert_equal 8 , @codes.right
|
||||
end
|
||||
def test_next_from
|
||||
assert_equal :r1 , @codes.next.from.symbol
|
||||
|
@ -21,7 +21,7 @@ module Risc
|
||||
end
|
||||
def test_load_method
|
||||
method = @produced
|
||||
assert_load( method, Parfait::TypedMethod ,:r1)
|
||||
assert_load( method, Parfait::CallableMethod ,:r1)
|
||||
assert_equal :div4 , method.constant.name
|
||||
end
|
||||
def test_load_space
|
||||
@ -43,7 +43,7 @@ module Risc
|
||||
|
||||
def test_get_args_type #from method in r1
|
||||
sl = @produced.next( 5 )
|
||||
assert_slot_to_reg( sl , :r1 , 5 , :r4 )
|
||||
assert_slot_to_reg( sl , :r1 , 3 , :r4 )
|
||||
end
|
||||
def test_get_args #from message
|
||||
sl = @produced.next( 6 )
|
||||
@ -56,7 +56,7 @@ module Risc
|
||||
|
||||
def test_get_frame_type #from method in r1
|
||||
sl = @produced.next( 8 )
|
||||
assert_slot_to_reg( sl , :r1 , 7 , :r4 )
|
||||
assert_slot_to_reg( sl , :r1 , 5 , :r4 )
|
||||
end
|
||||
def test_get_frame #from message
|
||||
sl = @produced.next( 9 )
|
||||
|
@ -8,7 +8,7 @@ module Parfait
|
||||
@obj = Parfait.object_space.get_class_by_name(:Object).instance_type
|
||||
@args = Parfait::Type.for_hash( @obj.object_class , { bar: :Integer , foo: :Type})
|
||||
@frame = Parfait::Type.for_hash( @obj.object_class , { local_bar: :Integer , local_foo: :Type})
|
||||
@method = Parfait::TypedMethod.new( @obj , :meth , @args , @frame)
|
||||
@method = Parfait::CallableMethod.new( @obj , :meth , @args , @frame)
|
||||
end
|
||||
|
||||
def test_method_name
|
||||
@ -99,7 +99,7 @@ module Parfait
|
||||
assert_equal @method , @method
|
||||
end
|
||||
def test_not_equal
|
||||
method = Parfait::TypedMethod.new( @obj , :other , @args , @frame)
|
||||
method = Parfait::CallableMethod.new( @obj , :other , @args , @frame)
|
||||
assert @method != method
|
||||
end
|
||||
end
|
@ -4,9 +4,10 @@ module Parfait
|
||||
class TestSpace < ParfaitTest
|
||||
|
||||
def classes
|
||||
[:Word,:List,:Message,:Integer,:ReturnAddress,:DataObject,:Data4,:Data8,
|
||||
:TrueClass,:FalseClass,:NilClass,:Object,:BinaryCode,:Space,:NamedList,
|
||||
:Type,:Class,:Dictionary,:CacheEntry,:TypedMethod,:VoolMethod]
|
||||
[:BinaryCode,:CacheEntry,:Callable,:CallableMethod,:Class,
|
||||
:DataObject,:Data4,:Data8,:Data16,:Dictionary,:Integer,:FalseClass,
|
||||
:List,:Message,:NamedList,:NilClass,:Object,:ReturnAddress,
|
||||
:Space,:TrueClass,:Type,:VoolMethod,:Word]
|
||||
end
|
||||
|
||||
def test_space_length
|
||||
|
@ -22,13 +22,13 @@ module Parfait
|
||||
end
|
||||
|
||||
def test_name
|
||||
assert_equal "Word_Type" , @types.values.first.name
|
||||
assert_equal "BinaryCode_Type" , @types.values.first.name
|
||||
end
|
||||
|
||||
def test_to_hash
|
||||
hash = @first.to_hash
|
||||
assert_equal hash[:type] , :Type
|
||||
assert_equal 3 , hash.length
|
||||
assert_equal 2 , hash.length
|
||||
end
|
||||
def test_add_is_different
|
||||
type = @first.add_instance_variable :random , :Integer
|
||||
|
@ -14,7 +14,7 @@ module Parfait
|
||||
end
|
||||
def foo_method( for_class = :Try)
|
||||
args = Parfait::Type.for_hash( @try_class , { bar: :Integer})
|
||||
::Parfait::TypedMethod.new( @space.get_class_by_name(for_class).instance_type , :foo , args,empty_frame)
|
||||
::Parfait::CallableMethod.new( @space.get_class_by_name(for_class).instance_type , :foo , args,empty_frame)
|
||||
end
|
||||
def add_foo_to( clazz = :Try )
|
||||
foo = foo_method( clazz )
|
||||
@ -50,7 +50,7 @@ module Parfait
|
||||
end
|
||||
def test_method_get
|
||||
add_foo_to
|
||||
assert_equal Parfait::TypedMethod , @try_type.get_method(:foo).class
|
||||
assert_equal Parfait::CallableMethod , @try_type.get_method(:foo).class
|
||||
end
|
||||
def test_method_get_nothere
|
||||
assert_nil @try_type.get_method(:foo)
|
||||
|
@ -45,7 +45,7 @@ module Risc
|
||||
ret = main_ticks(63)
|
||||
assert_equal FunctionReturn , ret.class
|
||||
assert_equal :r1 , ret.register.symbol
|
||||
assert_equal 21924 , @interpreter.get_register(ret.register)
|
||||
assert_equal 21476 , @interpreter.get_register(ret.register)
|
||||
end
|
||||
def test_sys
|
||||
sys = main_ticks(68)
|
||||
|
@ -92,7 +92,7 @@ module Risc
|
||||
assert_equal @label , ret.label
|
||||
end
|
||||
def test_minus
|
||||
op = @builder.build {space - typed_method}
|
||||
op = @builder.build {space - callable_method}
|
||||
assert_equal OperatorInstruction , op.class
|
||||
assert_equal :- , op.operator
|
||||
assert_equal :Space , op.left.type
|
||||
|
@ -54,7 +54,7 @@ module Risc
|
||||
end
|
||||
def test_pc1
|
||||
@interpreter.tick
|
||||
assert_equal 21432 , @interpreter.pc
|
||||
assert_equal 21048 , @interpreter.pc
|
||||
end
|
||||
def test_tick2
|
||||
@interpreter.tick
|
||||
@ -68,7 +68,7 @@ module Risc
|
||||
def test_pc2
|
||||
@interpreter.tick
|
||||
@interpreter.tick
|
||||
assert_equal 21436 , @interpreter.pc
|
||||
assert_equal 21052 , @interpreter.pc
|
||||
end
|
||||
def test_tick_14_jump
|
||||
14.times {@interpreter.tick}
|
||||
|
@ -25,7 +25,7 @@ module Risc
|
||||
assert_equal 0 , Position.get(@linker.cpu_init).at
|
||||
end
|
||||
def test_cpu_at
|
||||
assert_equal "0x626c" , Position.get(@linker.cpu_init.first).to_s
|
||||
assert_equal "0x60ec" , Position.get(@linker.cpu_init.first).to_s
|
||||
end
|
||||
def test_cpu_label
|
||||
assert_equal Position , Position.get(@linker.cpu_init.first).class
|
||||
|
@ -59,14 +59,14 @@ module Risc
|
||||
assert_equal Parfait::Class , vool.body.first.clazz.class
|
||||
end
|
||||
|
||||
def test_typed_method_instance_type
|
||||
def test_callable_method_instance_type
|
||||
in_test_vool("def meth; @ivar = 5; @ibar = 4;end")
|
||||
test = Parfait.object_space.get_class_by_name(:Test)
|
||||
method = test.instance_type.get_method(:meth)
|
||||
assert_equal 1, method.self_type.variable_index(:ivar)
|
||||
assert_equal 2, method.self_type.variable_index(:ibar)
|
||||
end
|
||||
def test_typed_method_has_one_local
|
||||
def test_callable_method_has_one_local
|
||||
in_test_vool("def meth; local = 5 ; a = 6;end")
|
||||
test = Parfait.object_space.get_class_by_name(:Test)
|
||||
method = test.get_method(:meth)
|
||||
|
@ -35,7 +35,7 @@ module Vool
|
||||
assert_equal Mom::SimpleCall, @ins.next(2).class
|
||||
end
|
||||
def test_call_has_method
|
||||
assert_equal Parfait::TypedMethod, @ins.next(2).method.class
|
||||
assert_equal Parfait::CallableMethod, @ins.next(2).method.class
|
||||
end
|
||||
def test_array
|
||||
check_array [Mom::MessageSetup,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
|
||||
|
@ -18,7 +18,7 @@ module Vool
|
||||
assert_equal SimpleCall, @ins.next(2).class
|
||||
end
|
||||
def test_call_has_method
|
||||
assert_equal Parfait::TypedMethod, @ins.next(2).method.class
|
||||
assert_equal Parfait::CallableMethod, @ins.next(2).method.class
|
||||
end
|
||||
def test_call_has_right_method
|
||||
assert_equal :get_internal_word, @ins.next(2).method.name
|
||||
|
Reference in New Issue
Block a user