some class send test changes
also ivar, which is still wip
This commit is contained in:
@ -1,44 +1 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Vool
|
||||
# relies on @ins and receiver_type method
|
||||
|
||||
module ClassHarness
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( send_method , "Object.get" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_first_not_array
|
||||
assert Array != @ins.class , @ins
|
||||
end
|
||||
def test_class_compiles
|
||||
assert_equal Mom::MessageSetup , @ins.class , @ins
|
||||
end
|
||||
def test_two_instructions_are_returned
|
||||
assert_equal 8 , @ins.length , @ins
|
||||
end
|
||||
def test_receiver_move_class
|
||||
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
|
||||
end
|
||||
def test_receiver_move
|
||||
assert_equal Mom::SlotDefinition, @ins.next.receiver.class
|
||||
end
|
||||
def test_receiver
|
||||
assert_equal Parfait::Class, @ins.next.receiver.known_object.class
|
||||
end
|
||||
def test_call_is
|
||||
assert_equal Mom::SimpleCall, @ins.next(2).class
|
||||
end
|
||||
def test_call_has_method
|
||||
assert_equal Parfait::CallableMethod, @ins.next(2).method.class
|
||||
end
|
||||
def test_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
||||
ReturnJump,Label, ReturnSequence , Label] , @ins
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -3,6 +3,8 @@ require_relative "helper"
|
||||
module Vool
|
||||
class TestClassDef < MiniTest::Test
|
||||
include Mom
|
||||
include VoolCompile
|
||||
|
||||
def class_main
|
||||
<<-eos
|
||||
class Space
|
||||
@ -21,11 +23,14 @@ module Vool
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(source)
|
||||
@ins = ret.compilers.find{|c|c.callable.name==:main}.mom_instructions.next
|
||||
end
|
||||
def test_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
||||
ReturnJump,Label, ReturnSequence , Label] , @ins
|
||||
end
|
||||
|
||||
def test_any
|
||||
assert_equal Mom::MessageSetup , @ins.class
|
||||
end
|
||||
|
||||
def test_no_arg
|
||||
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
|
||||
assert_equal 0, @ins.next(1).arguments.length
|
||||
|
41
test/vool/class_send/test_class_instance.rb
Normal file
41
test/vool/class_send/test_class_instance.rb
Normal file
@ -0,0 +1,41 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestClassInstance < MiniTest::Test
|
||||
include Mom
|
||||
include VoolCompile
|
||||
|
||||
def class_main
|
||||
<<-eos
|
||||
class Space
|
||||
def self.some_inst
|
||||
return @inst
|
||||
end
|
||||
def main(arg)
|
||||
return Space.one_plus
|
||||
end
|
||||
end
|
||||
eos
|
||||
end
|
||||
|
||||
def setup
|
||||
source = "class Integer;def +(other);X.int_operator(:+);end;end;" + class_main
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(source)
|
||||
@ins = ret.compilers.find{|c|c.callable.name==:some_inst}.mom_instructions.next
|
||||
end
|
||||
def test_array
|
||||
check_array [SlotLoad, ReturnJump, Label, ReturnSequence, Label] , @ins
|
||||
end
|
||||
def test_load_inst
|
||||
assert_equal SlotLoad, @ins.class
|
||||
end
|
||||
def test_left
|
||||
assert_equal SlotDefinition , @ins.left.class
|
||||
assert_equal [:return_value] , @ins.left.slots
|
||||
end
|
||||
def test_right
|
||||
assert_equal SlotDefinition , @ins.right.class
|
||||
assert_equal [:receiver , :inst] , @ins.right.slots
|
||||
end
|
||||
end
|
||||
end
|
@ -1,12 +0,0 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class ClassSendHarness < MiniTest::Test
|
||||
include ClassHarness
|
||||
|
||||
def send_method
|
||||
"Object.get_internal_word(0)"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -2,27 +2,41 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestSendClassMom < MiniTest::Test
|
||||
include ClassHarness
|
||||
include VoolCompile
|
||||
|
||||
def send_method
|
||||
"Object.get_internal_word(0)"
|
||||
def setup
|
||||
@compiler = compile_main( "Object.get_internal_word(0)" , "Object.get" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
||||
ReturnJump,Label, ReturnSequence , Label] , @ins
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
assert_equal MessageSetup , @ins.class , @ins
|
||||
end
|
||||
def test_receiver
|
||||
assert_equal SlotDefinition, @ins.next.receiver.class
|
||||
assert_equal Parfait::Class, @ins.next.receiver.known_object.class
|
||||
assert_equal :Object , @ins.next.receiver.known_object.name
|
||||
end
|
||||
def test_receiver_move
|
||||
assert_equal SlotDefinition, @ins.next.receiver.class
|
||||
end
|
||||
def test_receiver
|
||||
assert_equal Parfait::Class, @ins.next.receiver.known_object.class
|
||||
end
|
||||
def test_arg_one
|
||||
assert_equal SlotLoad, @ins.next(1).arguments[0].class
|
||||
end
|
||||
def test_call_two
|
||||
def test_receiver_move_class
|
||||
assert_equal ArgumentTransfer, @ins.next(1).class
|
||||
end
|
||||
def test_call_is
|
||||
assert_equal SimpleCall, @ins.next(2).class
|
||||
end
|
||||
def test_call_has_method
|
||||
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
|
||||
end
|
||||
def test_call_has_right_receiver
|
||||
|
Reference in New Issue
Block a user