fix test ripples and minor parfait naming
Parfait ruby and boot names desynced, fixed that
This commit is contained in:
parent
ae35fed0ab
commit
7377522417
@ -37,7 +37,7 @@ module Parfait
|
|||||||
def get_instance_method( fname )
|
def get_instance_method( fname )
|
||||||
raise "get_instance_method #{fname}.#{fname.class}" unless fname.is_a?(Symbol)
|
raise "get_instance_method #{fname}.#{fname.class}" unless fname.is_a?(Symbol)
|
||||||
#if we had a hash this would be easier. Detect or find would help too
|
#if we had a hash this would be easier. Detect or find would help too
|
||||||
self.methods.find {|m| m.name == fname }
|
self.instance_methods.find {|m| m.name == fname }
|
||||||
end
|
end
|
||||||
|
|
||||||
# get the method and if not found, try superclasses. raise error if not found
|
# get the method and if not found, try superclasses. raise error if not found
|
||||||
|
@ -24,7 +24,7 @@ module Parfait
|
|||||||
super()
|
super()
|
||||||
@name = name
|
@name = name
|
||||||
@super_class_name = superclass
|
@super_class_name = superclass
|
||||||
@methods = {}
|
@instance_methods = List.new
|
||||||
set_instance_type( instance_type )
|
set_instance_type( instance_type )
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -44,11 +44,11 @@ module Parfait
|
|||||||
|
|
||||||
def add_method(method)
|
def add_method(method)
|
||||||
raise "Must be untyped method #{method}" unless method.is_a? Parfait::VoolMethod
|
raise "Must be untyped method #{method}" unless method.is_a? Parfait::VoolMethod
|
||||||
@methods[method.name] = method
|
@instance_methods.push(method)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_method(name)
|
def get_method(name)
|
||||||
@methods[name]
|
@instance_methods.find{|m| m.name == name }
|
||||||
end
|
end
|
||||||
|
|
||||||
# adding an instance changes the instance_type to include that variable
|
# adding an instance changes the instance_type to include that variable
|
||||||
|
@ -10,7 +10,7 @@ module Parfait
|
|||||||
# as it changes during the course of it's life. Types do not change. Objects have
|
# as it changes during the course of it's life. Types do not change. Objects have
|
||||||
# type, and so only indirectly a class.
|
# type, and so only indirectly a class.
|
||||||
#
|
#
|
||||||
class VoolMethod
|
class VoolMethod < Object
|
||||||
|
|
||||||
attr_reader :name , :args_type , :frame_type , :source
|
attr_reader :name , :args_type , :frame_type , :source
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ module Parfait
|
|||||||
def test_to_hash
|
def test_to_hash
|
||||||
hash = @first.to_hash
|
hash = @first.to_hash
|
||||||
assert_equal hash[:type] , :Type
|
assert_equal hash[:type] , :Type
|
||||||
assert_equal 2 , hash.length
|
assert_equal 3 , hash.length
|
||||||
end
|
end
|
||||||
def test_add_is_different
|
def test_add_is_different
|
||||||
type = @first.add_instance_variable :random , :Integer
|
type = @first.add_instance_variable :random , :Integer
|
||||||
|
@ -45,7 +45,7 @@ module Risc
|
|||||||
ret = main_ticks(63)
|
ret = main_ticks(63)
|
||||||
assert_equal FunctionReturn , ret.class
|
assert_equal FunctionReturn , ret.class
|
||||||
assert_equal :r1 , ret.register.symbol
|
assert_equal :r1 , ret.register.symbol
|
||||||
assert_equal 20580 , @interpreter.get_register(ret.register)
|
assert_equal 20996 , @interpreter.get_register(ret.register)
|
||||||
end
|
end
|
||||||
def test_sys
|
def test_sys
|
||||||
sys = main_ticks(68)
|
sys = main_ticks(68)
|
||||||
|
@ -52,7 +52,7 @@ module Risc
|
|||||||
end
|
end
|
||||||
def test_pc1
|
def test_pc1
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
assert_equal 20344 , @interpreter.pc
|
assert_equal 20728 , @interpreter.pc
|
||||||
end
|
end
|
||||||
def test_tick2
|
def test_tick2
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
@ -66,7 +66,7 @@ module Risc
|
|||||||
def test_pc2
|
def test_pc2
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
assert_equal 20348 , @interpreter.pc
|
assert_equal 20732 , @interpreter.pc
|
||||||
end
|
end
|
||||||
def test_tick_14_jump
|
def test_tick_14_jump
|
||||||
14.times {@interpreter.tick}
|
14.times {@interpreter.tick}
|
||||||
|
@ -57,7 +57,7 @@ module Risc
|
|||||||
assert_equal 0 , Position.get(@machine.cpu_init).at
|
assert_equal 0 , Position.get(@machine.cpu_init).at
|
||||||
end
|
end
|
||||||
def test_cpu_at
|
def test_cpu_at
|
||||||
assert_equal "0x5eb4" , Position.get(@machine.cpu_init.first).to_s
|
assert_equal "0x6034" , Position.get(@machine.cpu_init.first).to_s
|
||||||
end
|
end
|
||||||
def test_cpu_label
|
def test_cpu_label
|
||||||
assert_equal Position , Position.get(@machine.cpu_init.first).class
|
assert_equal Position , Position.get(@machine.cpu_init.first).class
|
||||||
|
@ -29,7 +29,7 @@ module Risc
|
|||||||
end
|
end
|
||||||
def test_list5
|
def test_list5
|
||||||
list = Parfait.new_list([1,2,3,4,5])
|
list = Parfait.new_list([1,2,3,4,5])
|
||||||
assert_equal 32 , list.padded_length
|
assert_equal 64 , list.padded_length
|
||||||
end
|
end
|
||||||
def test_type
|
def test_type
|
||||||
type = Parfait::Type.for_hash Parfait.object_space.get_class_by_name(:Object) , {}
|
type = Parfait::Type.for_hash Parfait.object_space.get_class_by_name(:Object) , {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user