parent
0ebb8e31c6
commit
461a6933c6
@ -40,7 +40,7 @@ module Vool
|
||||
class ModuleName < Expression
|
||||
include Named
|
||||
def ct_type
|
||||
get_named_class.instance_type
|
||||
get_named_class.meta_class.instance_type
|
||||
end
|
||||
def slot_definition(_)
|
||||
return Mom::SlotDefinition.new( get_named_class, [])
|
||||
|
44
test/vool/class_send/helper.rb
Normal file
44
test/vool/class_send/helper.rb
Normal file
@ -0,0 +1,44 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Vool
|
||||
# relies on @ins and receiver_type method
|
||||
|
||||
module ClassHarness
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
Risc::Builtin.boot_functions
|
||||
@ins = compile_first_method( send_method )
|
||||
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 3 , @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 [Mom::MessageSetup,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
|
||||
end
|
||||
end
|
||||
|
||||
end
|
44
test/vool/class_send/test_class_def.rb
Normal file
44
test/vool/class_send/test_class_def.rb
Normal file
@ -0,0 +1,44 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestClassDef < MiniTest::Test
|
||||
include Mom
|
||||
def class_main
|
||||
<<-eos
|
||||
class Space
|
||||
def self.one_plus()
|
||||
return 1 + 1
|
||||
end
|
||||
def main(arg)
|
||||
return Space.one_plus
|
||||
end
|
||||
end
|
||||
eos
|
||||
end
|
||||
|
||||
def setup
|
||||
statements = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_vool(class_main)
|
||||
assert_equal Vool::ClassStatement, statements.class
|
||||
ret = statements.to_mom(nil)
|
||||
assert_equal Parfait::Class , statements.clazz.class , statements
|
||||
@method = statements.clazz.get_method(:main)
|
||||
assert_equal Parfait::VoolMethod , @method.class
|
||||
assert_equal Mom::MomCompiler , ret.class
|
||||
compiler = ret.method_compilers.find{|c| c.get_method.name == :main }
|
||||
assert_equal Risc::MethodCompiler , compiler.class
|
||||
@ins = @method.source.to_mom( compiler )
|
||||
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
|
||||
end
|
||||
def test_call_two
|
||||
assert_equal SimpleCall, @ins.next(2).class
|
||||
end
|
||||
end
|
||||
end
|
13
test/vool/class_send/test_harness.rb
Normal file
13
test/vool/class_send/test_harness.rb
Normal file
@ -0,0 +1,13 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class ClassSendHarness < MiniTest::Test
|
||||
include MomCompile
|
||||
include ClassHarness
|
||||
|
||||
def send_method
|
||||
"Object.get_internal_word(0)"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -2,14 +2,17 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestSendClassMom < MiniTest::Test
|
||||
include SimpleSendHarness
|
||||
include ClassHarness
|
||||
include Mom
|
||||
|
||||
def send_method
|
||||
"Object.get_internal_word(0)"
|
||||
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_arg_one
|
||||
assert_equal SlotLoad, @ins.next(1).arguments[0].class
|
Loading…
x
Reference in New Issue
Block a user