Rename Vool to Sol
Simple is really the descriptive name for the layer Sure, it is "virtual" but that is not as important as the fact that it is simple (or simplified) Also objct (based really) is better, since orientated implies it is a little like that, but only orientated, not really it. Sol only has objects, nothing else Just cause i was renaming anyway
This commit is contained in:
46
test/sol/send/helper.rb
Normal file
46
test/sol/send/helper.rb
Normal file
@ -0,0 +1,46 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Sol
|
||||
# relies on @ins and receiver_type method
|
||||
module SimpleSendHarness
|
||||
include SolCompile
|
||||
include SlotMachine
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( send_method , "Integer.div4;Object.get")
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_first_not_array
|
||||
assert Array != @ins.class , @ins
|
||||
end
|
||||
def test_class_compiles
|
||||
assert_equal 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 ArgumentTransfer, @ins.next(1).class
|
||||
end
|
||||
def test_receiver_move
|
||||
assert_equal SlotDefinition, @ins.next.receiver.class
|
||||
end
|
||||
def test_receiver
|
||||
type , value = receiver
|
||||
assert_equal type, @ins.next.receiver.known_object.class
|
||||
assert_equal value, @ins.next.receiver.known_object.value
|
||||
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_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall,
|
||||
SlotLoad, ReturnJump, Label, ReturnSequence ,
|
||||
Label] , @ins
|
||||
end
|
||||
end
|
||||
end
|
28
test/sol/send/test_not_found.rb
Normal file
28
test/sol/send/test_not_found.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Sol
|
||||
class TestSendCachedSimpleSlotMachine < MiniTest::Test
|
||||
include SolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "5.div8")
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
def test_check_type
|
||||
assert_equal NotSameCheck , @ins.class , @ins
|
||||
end
|
||||
def test_check_resolve_call
|
||||
assert_equal ResolveMethod , @ins.next(2).class , @ins
|
||||
end
|
||||
def test_dynamic_call_last
|
||||
assert_equal DynamicCall , @ins.next(6).class , @ins
|
||||
end
|
||||
|
||||
def test_array
|
||||
check_array [NotSameCheck, SlotLoad, ResolveMethod, Label, MessageSetup ,
|
||||
ArgumentTransfer, DynamicCall, SlotLoad, ReturnJump,
|
||||
Label, ReturnSequence, Label] , @ins
|
||||
end
|
||||
|
||||
end
|
||||
end
|
27
test/sol/send/test_send_args_send.rb
Normal file
27
test/sol/send/test_send_args_send.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Sol
|
||||
class TestSendArgsSendSlotMachine < MiniTest::Test
|
||||
include SolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "a = main(4.div4);return a" , "Integer.div4")
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_array
|
||||
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, MessageSetup ,
|
||||
ArgumentTransfer, SimpleCall, SlotLoad ,SlotLoad, ReturnJump,
|
||||
Label, ReturnSequence , Label] , @ins
|
||||
end
|
||||
|
||||
def test_one_call
|
||||
assert_equal SimpleCall, @ins.next(2).class
|
||||
assert_equal :div4 , @ins.next(2).method.name
|
||||
end
|
||||
def test_two_call
|
||||
assert_equal SimpleCall, @ins.next(6).class
|
||||
assert_equal :main, @ins.next(6).method.name
|
||||
end
|
||||
end
|
||||
end
|
35
test/sol/send/test_send_cached_simple.rb
Normal file
35
test/sol/send/test_send_cached_simple.rb
Normal file
@ -0,0 +1,35 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Sol
|
||||
class TestSendCachedSimpleSlotMachine < MiniTest::Test
|
||||
include SolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "a = 5; a.div4;return ")
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
def test_check_type
|
||||
assert_equal NotSameCheck , @ins.next(1).class , @ins
|
||||
end
|
||||
def test_type_update
|
||||
load = @ins.next(2)
|
||||
assert_equal :message , load.right.known_object , load
|
||||
assert_equal :local1 , load.right.slots[0] , load
|
||||
assert_equal :type , load.right.slots[1] , load
|
||||
end
|
||||
def test_check_resolve_call
|
||||
assert_equal ResolveMethod , @ins.next(3).class , @ins
|
||||
end
|
||||
def test_dynamic_call_last
|
||||
assert_equal DynamicCall , @ins.next(7).class , @ins
|
||||
end
|
||||
|
||||
def test_array
|
||||
check_array [SlotLoad, NotSameCheck, SlotLoad, ResolveMethod ,
|
||||
Label, MessageSetup, ArgumentTransfer, DynamicCall,
|
||||
SlotLoad, ReturnJump, Label ,
|
||||
ReturnSequence, Label] , @ins
|
||||
end
|
||||
|
||||
end
|
||||
end
|
32
test/sol/send/test_send_self.rb
Normal file
32
test/sol/send/test_send_self.rb
Normal file
@ -0,0 +1,32 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Sol
|
||||
class TestSendSelfSlotMachine < MiniTest::Test
|
||||
include SimpleSendHarness
|
||||
|
||||
def send_method
|
||||
"self.get_internal_word(0);return"
|
||||
end
|
||||
def test_receiver
|
||||
assert_equal SlotDefinition, @ins.next.receiver.class
|
||||
end
|
||||
def test_arg_one
|
||||
assert_equal SlotLoad, @ins.next(1).arguments[0].class
|
||||
end
|
||||
def test_call_two
|
||||
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
|
||||
end
|
||||
class TestSendSelfImplicitSlotMachine < TestSendSelfSlotMachine
|
||||
|
||||
def send_method
|
||||
"get_internal_word(0)"
|
||||
end
|
||||
end
|
||||
end
|
18
test/sol/send/test_send_simple.rb
Normal file
18
test/sol/send/test_send_simple.rb
Normal file
@ -0,0 +1,18 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Sol
|
||||
class TestSendSimpleSlotMachine < MiniTest::Test
|
||||
include SimpleSendHarness
|
||||
|
||||
def send_method
|
||||
"5.div4;return"
|
||||
end
|
||||
def receiver
|
||||
[SlotMachine::IntegerConstant , 5]
|
||||
end
|
||||
def test_call_has_right_method
|
||||
assert_equal :div4, @ins.next(2).method.name
|
||||
end
|
||||
|
||||
end
|
||||
end
|
27
test/sol/send/test_send_simple_args.rb
Normal file
27
test/sol/send/test_send_simple_args.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Sol
|
||||
class TestSendSimpleArgsSlotMachine < MiniTest::Test
|
||||
include SimpleSendHarness
|
||||
|
||||
def send_method
|
||||
"5.div4(1,2);return"
|
||||
end
|
||||
|
||||
def receiver
|
||||
[SlotMachine::IntegerConstant , 5]
|
||||
end
|
||||
def test_args_two_move
|
||||
assert_equal :next_message, @ins.next(1).arguments[1].left.slots[0]
|
||||
assert_equal :arg2, @ins.next(1).arguments[1].left.slots[1]
|
||||
end
|
||||
def test_args_two_str
|
||||
assert_equal SlotMachine::IntegerConstant, @ins.next(1).arguments[1].right.known_object.class
|
||||
assert_equal 2, @ins.next(1).arguments[1].right.known_object.value
|
||||
end
|
||||
def test_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall, SlotLoad, ReturnJump,
|
||||
Label, ReturnSequence , Label] , @ins
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user