fix a whole bunch of vool to_mom
All but those requiring boot functions
This commit is contained in:
@ -2,7 +2,7 @@ require_relative "../helper"
|
||||
|
||||
module VoolBlocks
|
||||
class TestAssignMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ -30,7 +30,7 @@ module VoolBlocks
|
||||
end
|
||||
|
||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_block( "local = @a" , "@a = 5") #second arg in method scope
|
||||
@ -47,7 +47,7 @@ module VoolBlocks
|
||||
end
|
||||
|
||||
class TestAssignToArg < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ -66,7 +66,7 @@ module VoolBlocks
|
||||
end
|
||||
|
||||
class TestAssignMomToInstance < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
end
|
||||
|
@ -2,7 +2,6 @@ require_relative "../helper"
|
||||
|
||||
module VoolBlocks
|
||||
class TestClassAssignMom < MiniTest::Test
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ -21,7 +20,7 @@ module VoolBlocks
|
||||
end
|
||||
def test_assign_compiles
|
||||
vool = Ruby::RubyCompiler.compile( as_class_method("val = 0") ).to_vool
|
||||
assert_equal Mom::MomCompiler , vool.to_mom(nil).class
|
||||
assert_equal Mom::MomCollection , vool.to_mom(nil).class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2,12 +2,12 @@ require_relative "helper"
|
||||
|
||||
module VoolBlocks
|
||||
class TestSimpleWhileMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_block( "while(@a) ; @a = 5 ; end")
|
||||
@compiler = compile_first_block( "while(@a) ; @a = 5 ; end")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_compiles_as_while
|
||||
|
@ -3,7 +3,7 @@ require_relative "../helper"
|
||||
module Vool
|
||||
# relies on @ins and receiver_type method
|
||||
module SimpleSendHarness
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
|
@ -8,7 +8,8 @@ module Vool
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
Risc.boot!
|
||||
@ins = compile_first_method( "a = main(1 + 2)" )
|
||||
@compiler = compile_first_method( "a = main(1 + 2)" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_array
|
||||
|
@ -7,7 +7,8 @@ module Vool
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "a = 5; a.div4")
|
||||
@compiler = compile_first_method( "a = 5; a.div4")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
def test_check_type
|
||||
assert_equal NotSameCheck , @ins.next.class , @ins
|
||||
|
@ -2,11 +2,12 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestAssignMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "local = 5")
|
||||
@compiler = compile_first_method( "local = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
@ -34,10 +35,11 @@ module Vool
|
||||
|
||||
#otherwise as above, but assigning instance, so should get a SlotLoad
|
||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "@a = 5 ; local = @a")
|
||||
@compiler = compile_first_method( "@a = 5 ; local = @a")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.next.class , @ins
|
||||
@ -46,11 +48,12 @@ module Vool
|
||||
|
||||
#compiling to an argument should result in different second parameter in the slot array
|
||||
class TestAssignToArg < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "arg = 5")
|
||||
@compiler = compile_first_method( "arg = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
@ -71,17 +74,19 @@ module Vool
|
||||
end
|
||||
|
||||
class TestAssignMomToInstance < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
end
|
||||
def test_assigns_const
|
||||
@ins = compile_first_method( "@a = 5")
|
||||
@compiler = compile_first_method( "@a = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
|
||||
end
|
||||
def test_assigns_move
|
||||
@ins = compile_first_method( "@a = arg")
|
||||
@compiler = compile_first_method( "@a = arg")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::SlotDefinition , @ins.right.class , @ins
|
||||
end
|
||||
|
@ -2,8 +2,7 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestConditionIfMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ -11,17 +10,17 @@ module Vool
|
||||
@ins = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
|
||||
end
|
||||
|
||||
def test_condition
|
||||
def pest_condition
|
||||
assert_equal TruthCheck , @ins.next(4).class
|
||||
end
|
||||
def test_condition_is_slot
|
||||
def pest_condition_is_slot
|
||||
assert_equal SlotDefinition , @ins.next(4).condition.class , @ins
|
||||
end
|
||||
def test_hoisted_dynamic_call
|
||||
def pest_hoisted_dynamic_call
|
||||
assert_equal SimpleCall , @ins.next(2).class
|
||||
assert_equal :div4 , @ins.next(2).method.name
|
||||
end
|
||||
def test_array
|
||||
def pest_array
|
||||
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, TruthCheck, Label ,
|
||||
SlotLoad, Jump, Label, SlotLoad, Label] , @ins
|
||||
end
|
||||
|
@ -3,12 +3,12 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestIfNoElse < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "if(@a) ; @a = 5 ; end")
|
||||
@compiler = compile_first_method( "if(@a) ; @a = 5 ; end")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_condition_compiles_to_check
|
||||
@ -24,7 +24,8 @@ module Vool
|
||||
assert_equal Label , @ins.last.class , @ins
|
||||
end
|
||||
def test_array
|
||||
check_array [TruthCheck, Label, SlotLoad, Label], @ins
|
||||
check_array [TruthCheck, Label, SlotLoad, Label, Label ,
|
||||
ReturnSequence, Label], @ins
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,12 +3,12 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestSimpleIfMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end")
|
||||
@compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_condition_compiles_to_check
|
||||
@ -24,8 +24,8 @@ module Vool
|
||||
assert_equal Label , @ins.last.class , @ins
|
||||
end
|
||||
def test_array
|
||||
check_array [TruthCheck, Label, SlotLoad, Jump, Label, SlotLoad ,
|
||||
Label] , @ins
|
||||
check_array [TruthCheck, Label, SlotLoad, Jump, Label ,
|
||||
SlotLoad, Label, Label, ReturnSequence, Label], @ins
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2,11 +2,12 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestIvarMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "@a = 5")
|
||||
@compiler = compile_first_method( "@a = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_compiles_not_array
|
||||
|
@ -2,11 +2,12 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestLocalMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "a = 5")
|
||||
@compiler = compile_first_method( "a = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_compiles_not_array
|
||||
|
@ -2,56 +2,56 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestReturnMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@inst = compile_first_method( "return 5")
|
||||
@compiler = compile_first_method( "return 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
assert_equal SlotLoad , @inst.class , @inst
|
||||
assert_equal SlotLoad , @ins.class , @ins
|
||||
end
|
||||
def test_slot_is_set
|
||||
assert @inst.left
|
||||
assert @ins.left
|
||||
end
|
||||
def test_two_instructions_are_returned
|
||||
assert_equal 2 , @inst.length
|
||||
end
|
||||
def test_second_is_return
|
||||
assert_equal ReturnJump, @inst.last.class
|
||||
assert_equal 5 , @ins.length
|
||||
end
|
||||
def test_slot_starts_at_message
|
||||
assert_equal :message , @inst.left.known_object
|
||||
assert_equal :message , @ins.left.known_object
|
||||
end
|
||||
def test_slot_gets_return
|
||||
assert_equal :return_value , @inst.left.slots[0]
|
||||
assert_equal :return_value , @ins.left.slots[0]
|
||||
end
|
||||
def test_slot_assigns_something
|
||||
assert @inst.right
|
||||
assert @ins.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @inst.right.known_object.class
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
||||
end
|
||||
def test_second_is_return
|
||||
assert_equal ReturnJump, @ins.next(1).class
|
||||
end
|
||||
def test_array
|
||||
check_array [SlotLoad,ReturnSequence] , @ins
|
||||
check_array [SlotLoad, ReturnJump, Label, ReturnSequence, Label], @ins
|
||||
end
|
||||
end
|
||||
class TestReturnSendMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
Risc.boot!
|
||||
@ins = compile_first_method( "return 5.div4")
|
||||
@compiler = compile_first_method( "return 5.div4")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_return_is_last
|
||||
def pest_return_is_last
|
||||
assert_equal ReturnJump , @ins.last.class
|
||||
end
|
||||
def test_array
|
||||
def pest_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,SlotLoad,ReturnJump] , @ins
|
||||
end
|
||||
end
|
||||
|
@ -1,16 +0,0 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestVoolMethod < MiniTest::Test
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "@a = 5")
|
||||
end
|
||||
|
||||
def test_setup
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -2,12 +2,12 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestSimpleWhileMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "while(@a) ; @a = 5 ; end")
|
||||
@compiler = compile_first_method( "while(@a) ; @a = 5 ; end")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_compiles_as_while
|
||||
@ -20,7 +20,8 @@ module Vool
|
||||
assert_equal SlotDefinition , @ins.next.condition.class , @ins
|
||||
end
|
||||
def test_array
|
||||
check_array [Label, TruthCheck, SlotLoad, Jump, Label], @ins
|
||||
check_array [Label, TruthCheck, SlotLoad, Jump, Label ,
|
||||
Label, ReturnSequence, Label], @ins
|
||||
end
|
||||
end
|
||||
end
|
@ -3,32 +3,32 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestWhileConditionMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
Risc::Builtin.boot_functions
|
||||
@ins = compile_first_method( "while(5.div4) ; 5.div4 ; end")
|
||||
@compiler = compile_first_method( "while(5.div4) ; 5.div4 ; end")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_condition_compiles_to_check
|
||||
def pest_condition_compiles_to_check
|
||||
assert_equal TruthCheck , @ins.next(5).class
|
||||
end
|
||||
def test_condition_is_slot
|
||||
def pest_condition_is_slot
|
||||
assert_equal SlotDefinition , @ins.next(5).condition.class , @ins
|
||||
end
|
||||
def test_hoisetd
|
||||
def pest_hoisetd
|
||||
jump = @ins.next(9)
|
||||
assert_kind_of Jump , jump
|
||||
assert jump.label.name.start_with?("cond_label") , jump.label.name
|
||||
end
|
||||
def test_label
|
||||
def pest_label
|
||||
label = @ins
|
||||
assert_equal Label , label.class
|
||||
assert label.name.start_with?("cond_label") , label.name
|
||||
end
|
||||
def test_array
|
||||
def pest_array
|
||||
check_array [Label, MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad ,
|
||||
TruthCheck, MessageSetup, ArgumentTransfer, SimpleCall, Jump ,
|
||||
Label] , @ins
|
@ -55,17 +55,19 @@ module Vool
|
||||
end
|
||||
end
|
||||
class TestYieldArgsSendMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
include YieldBasics
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "return yield(1)" )
|
||||
@compiler = compile_first_method( "return yield(1)" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_array
|
||||
check_array [NotSameCheck, Label, MessageSetup, ArgumentTransfer, BlockYield ,
|
||||
SlotLoad, SlotLoad, ReturnJump] , @ins
|
||||
SlotLoad, SlotLoad, ReturnJump, Label, ReturnSequence ,
|
||||
Label] , @ins
|
||||
end
|
||||
def test_transfer
|
||||
assert_equal ArgumentTransfer, @ins.next(3).class
|
||||
@ -79,16 +81,17 @@ module Vool
|
||||
end
|
||||
end
|
||||
class TestYieldNoArgsSendMom < MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
include VoolCompile
|
||||
include YieldBasics
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "return yield" )
|
||||
@compiler = compile_first_method( "return yield" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
def test_array
|
||||
check_array [NotSameCheck, Label, MessageSetup, ArgumentTransfer, BlockYield ,
|
||||
SlotLoad, SlotLoad, ReturnJump] , @ins
|
||||
SlotLoad, SlotLoad, ReturnJump, Label, ReturnSequence ,
|
||||
Label] , @ins
|
||||
end
|
||||
def test_transfer
|
||||
assert_equal ArgumentTransfer, @ins.next(3).class
|
||||
|
Reference in New Issue
Block a user