2019-09-21 17:07:58 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-03 23:36:49 +02:00
|
|
|
module Sol
|
2019-09-21 17:07:58 +02:00
|
|
|
class TestClassSendInherited < MiniTest::Test
|
2019-10-03 19:55:41 +02:00
|
|
|
include SlotMachine
|
2019-10-03 23:36:49 +02:00
|
|
|
include SolCompile
|
2019-09-21 17:07:58 +02:00
|
|
|
|
|
|
|
def class_main
|
|
|
|
<<-eos
|
2019-10-01 19:55:05 +02:00
|
|
|
class Object
|
2019-09-21 17:07:58 +02:00
|
|
|
def self.one_plus()
|
2019-10-01 19:55:05 +02:00
|
|
|
return 1
|
2019-09-21 17:07:58 +02:00
|
|
|
end
|
|
|
|
end
|
2019-10-01 19:55:05 +02:00
|
|
|
class Space < Object
|
2019-09-21 17:07:58 +02:00
|
|
|
def main(arg)
|
|
|
|
return Space.one_plus
|
|
|
|
end
|
|
|
|
end
|
|
|
|
eos
|
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
2019-10-03 19:55:41 +02:00
|
|
|
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(class_main)
|
|
|
|
@ins = ret.compilers.find_compiler_name(:main).slot_instructions.next
|
2019-09-21 17:07:58 +02:00
|
|
|
end
|
|
|
|
def test_array
|
|
|
|
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
|
|
|
ReturnJump,Label, ReturnSequence , Label] , @ins
|
|
|
|
end
|
|
|
|
def test_receiver
|
2019-10-03 19:55:41 +02:00
|
|
|
assert_equal SlotMachine::ArgumentTransfer, @ins.next(1).class
|
2019-09-21 17:07:58 +02:00
|
|
|
assert_equal 0, @ins.next(1).arguments.length
|
2020-02-15 15:02:03 +01:00
|
|
|
assert_equal SlottedObject, @ins.next(1).receiver.class
|
2019-09-21 17:07:58 +02:00
|
|
|
assert_equal Parfait::Class, @ins.next(1).receiver.known_object.class
|
|
|
|
assert_equal :Space, @ins.next(1).receiver.known_object.name
|
|
|
|
end
|
|
|
|
def test_call
|
|
|
|
assert_equal SimpleCall, @ins.next(2).class
|
|
|
|
assert_equal :one_plus, @ins.next(2).method.name
|
|
|
|
assert_equal Parfait::Type, @ins.next(2).method.self_type.class
|
2019-09-30 16:09:13 +02:00
|
|
|
assert_equal :"Space.Single", @ins.next(2).method.self_type.object_class.name
|
2019-09-21 17:07:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|