Change Mom to SlotMachine
rather large commit, but essentially a simple rename Rationale in docs and blogs
This commit is contained in:
@ -2,7 +2,7 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestClassDef < MiniTest::Test
|
||||
include Mom
|
||||
include SlotMachine
|
||||
include VoolCompile
|
||||
|
||||
def class_main
|
||||
@ -20,8 +20,8 @@ module Vool
|
||||
|
||||
def setup
|
||||
source = "class Integer<Data4;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_compiler_name(:main).mom_instructions.next
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(source)
|
||||
@ins = ret.compilers.find_compiler_name(:main).slot_instructions.next
|
||||
end
|
||||
def test_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
||||
@ -29,10 +29,10 @@ module Vool
|
||||
end
|
||||
|
||||
def test_any
|
||||
assert_equal Mom::MessageSetup , @ins.class
|
||||
assert_equal SlotMachine::MessageSetup , @ins.class
|
||||
end
|
||||
def test_no_arg
|
||||
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
|
||||
assert_equal SlotMachine::ArgumentTransfer, @ins.next(1).class
|
||||
assert_equal 0, @ins.next(1).arguments.length
|
||||
end
|
||||
def test_call_two
|
||||
|
@ -2,7 +2,7 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestClassInstance < MiniTest::Test
|
||||
include Mom
|
||||
include SlotMachine
|
||||
include VoolCompile
|
||||
|
||||
def class_main
|
||||
@ -19,10 +19,10 @@ module Vool
|
||||
end
|
||||
|
||||
def setup
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(class_main)
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(class_main)
|
||||
@compiler = ret.compilers.find_compiler_name(:some_inst)
|
||||
@main = ret.compilers.find_compiler_name(:main)
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
def test_class_inst
|
||||
space_class = Parfait.object_space.get_class
|
||||
@ -31,7 +31,7 @@ module Vool
|
||||
assert names.index_of(:inst) , names
|
||||
end
|
||||
def test_compiler
|
||||
assert_equal Mom::MethodCompiler, @compiler.class
|
||||
assert_equal SlotMachine::MethodCompiler, @compiler.class
|
||||
assert_equal Parfait::Type, @compiler.callable.self_type.class
|
||||
assert_equal 6, @compiler.callable.self_type.names.index_of(:inst) , @compiler.callable.self_type.names
|
||||
end
|
||||
@ -40,10 +40,10 @@ module Vool
|
||||
end
|
||||
def test_main_array
|
||||
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, ReturnJump ,
|
||||
Label, ReturnSequence, Label] , @main.mom_instructions.next
|
||||
Label, ReturnSequence, Label] , @main.slot_instructions.next
|
||||
end
|
||||
def test_main_args
|
||||
args = @main.mom_instructions.next(2)
|
||||
args = @main.slot_instructions.next(2)
|
||||
assert_equal Parfait::Class , args.receiver.known_object.class
|
||||
assert_equal :Space , args.receiver.known_object.name
|
||||
assert_equal :some_inst , args.receiver.known_object.type.method_names.first
|
||||
|
@ -2,7 +2,7 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestClassSendInherited < MiniTest::Test
|
||||
include Mom
|
||||
include SlotMachine
|
||||
include VoolCompile
|
||||
|
||||
def class_main
|
||||
@ -21,15 +21,15 @@ module Vool
|
||||
end
|
||||
|
||||
def setup
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(class_main)
|
||||
@ins = ret.compilers.find_compiler_name(:main).mom_instructions.next
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(class_main)
|
||||
@ins = ret.compilers.find_compiler_name(:main).slot_instructions.next
|
||||
end
|
||||
def test_array
|
||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
||||
ReturnJump,Label, ReturnSequence , Label] , @ins
|
||||
end
|
||||
def test_receiver
|
||||
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
|
||||
assert_equal SlotMachine::ArgumentTransfer, @ins.next(1).class
|
||||
assert_equal 0, @ins.next(1).arguments.length
|
||||
assert_equal SlotDefinition, @ins.next(1).receiver.class
|
||||
assert_equal Parfait::Class, @ins.next(1).receiver.known_object.class
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestSendClassMom < MiniTest::Test
|
||||
class TestSendClassSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def class_main
|
||||
@ -21,8 +21,8 @@ module Vool
|
||||
|
||||
def setup
|
||||
source = "class Integer < Data4;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_compiler_name(:main).mom_instructions.next
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(source)
|
||||
@ins = ret.compilers.find_compiler_name(:main).slot_instructions.next
|
||||
end
|
||||
|
||||
def test_array
|
||||
|
@ -1,14 +1,14 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module VoolBlocks
|
||||
class TestAssignMom < MiniTest::Test
|
||||
class TestAssignSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@ins = compile_main_block( "local = 5" )
|
||||
end
|
||||
def test_block_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||
end
|
||||
def test_slot_is_set
|
||||
assert @ins.left
|
||||
@ -23,17 +23,17 @@ module VoolBlocks
|
||||
assert @ins.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
||||
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
|
||||
end
|
||||
end
|
||||
|
||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
||||
class TestAssignSlotMachineInstanceToLocal < MiniTest::Test
|
||||
include VoolCompile
|
||||
def setup
|
||||
@ins = compile_main_block( "local = @a" , "@a = 5") #second arg in method scope
|
||||
end
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||
end
|
||||
def test_slots_left
|
||||
assert_equal [:local1] , @ins.left.slots
|
||||
@ -51,7 +51,7 @@ module VoolBlocks
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||
end
|
||||
def test_slot_is_set
|
||||
assert @ins.left
|
||||
@ -61,19 +61,19 @@ module VoolBlocks
|
||||
end
|
||||
end
|
||||
|
||||
class TestAssignMomToInstance < MiniTest::Test
|
||||
class TestAssignSlotMachineToInstance < MiniTest::Test
|
||||
include VoolCompile
|
||||
def setup
|
||||
end
|
||||
def test_assigns_const
|
||||
@ins = compile_main_block( "@a = 5")
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
|
||||
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class , @ins
|
||||
end
|
||||
def test_assigns_move
|
||||
@ins = compile_main_block( "@a = arg")
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::SlotDefinition , @ins.right.class , @ins
|
||||
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||
assert_equal SlotMachine::SlotDefinition , @ins.right.class , @ins
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module VoolBlocks
|
||||
class TestClassAssignMom < MiniTest::Test
|
||||
class TestClassAssignSlotMachine < MiniTest::Test
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ -14,7 +14,7 @@ module VoolBlocks
|
||||
vool = Ruby::RubyCompiler.compile( as_class_method(source) ).to_vool
|
||||
vool.to_parfait
|
||||
begin
|
||||
vool.to_mom(nil)
|
||||
vool.to_slot(nil)
|
||||
rescue => err
|
||||
assert err.message.include?("Blocks") , err.message
|
||||
end
|
||||
@ -22,7 +22,7 @@ module VoolBlocks
|
||||
def test_assign_compiles
|
||||
vool = Ruby::RubyCompiler.compile( as_class_method("val = 0") ).to_vool
|
||||
vool.to_parfait
|
||||
assert_equal Mom::MomCollection , vool.to_mom(nil).class
|
||||
assert_equal SlotMachine::SlotCollection , vool.to_slot(nil).class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module VoolBlocks
|
||||
class TestConditionIfMom < MiniTest::Test
|
||||
class TestConditionIfSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module VoolBlocks
|
||||
class TestSimpleWhileMom < MiniTest::Test
|
||||
class TestSimpleWhileSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
|
@ -4,11 +4,11 @@ module Vool
|
||||
# relies on @ins and receiver_type method
|
||||
module SimpleSendHarness
|
||||
include VoolCompile
|
||||
include Mom
|
||||
include SlotMachine
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( send_method , "Integer.div4;Object.get")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_first_not_array
|
||||
|
@ -1,12 +1,12 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Vool
|
||||
class TestSendCachedSimpleMom < MiniTest::Test
|
||||
class TestSendCachedSimpleSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "5.div8")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
def test_check_type
|
||||
assert_equal NotSameCheck , @ins.class , @ins
|
||||
|
@ -1,12 +1,12 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestSendArgsSendMom < MiniTest::Test
|
||||
class TestSendArgsSendSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "a = main(4.div4);return a" , "Integer.div4")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_array
|
||||
|
@ -1,12 +1,12 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Vool
|
||||
class TestSendCachedSimpleMom < MiniTest::Test
|
||||
class TestSendCachedSimpleSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "a = 5; a.div4;return ")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
def test_check_type
|
||||
assert_equal NotSameCheck , @ins.next(1).class , @ins
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestSendSelfMom < MiniTest::Test
|
||||
class TestSendSelfSlotMachine < MiniTest::Test
|
||||
include SimpleSendHarness
|
||||
|
||||
def send_method
|
||||
@ -23,7 +23,7 @@ module Vool
|
||||
assert_equal :get_internal_word, @ins.next(2).method.name
|
||||
end
|
||||
end
|
||||
class TestSendSelfImplicitMom < TestSendSelfMom
|
||||
class TestSendSelfImplicitSlotMachine < TestSendSelfSlotMachine
|
||||
|
||||
def send_method
|
||||
"get_internal_word(0)"
|
||||
|
@ -1,14 +1,14 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestSendSimpleMom < MiniTest::Test
|
||||
class TestSendSimpleSlotMachine < MiniTest::Test
|
||||
include SimpleSendHarness
|
||||
|
||||
def send_method
|
||||
"5.div4;return"
|
||||
end
|
||||
def receiver
|
||||
[Mom::IntegerConstant , 5]
|
||||
[SlotMachine::IntegerConstant , 5]
|
||||
end
|
||||
def test_call_has_right_method
|
||||
assert_equal :div4, @ins.next(2).method.name
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestSendSimpleArgsMom < MiniTest::Test
|
||||
class TestSendSimpleArgsSlotMachine < MiniTest::Test
|
||||
include SimpleSendHarness
|
||||
|
||||
def send_method
|
||||
@ -9,14 +9,14 @@ module Vool
|
||||
end
|
||||
|
||||
def receiver
|
||||
[Mom::IntegerConstant , 5]
|
||||
[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 Mom::IntegerConstant, @ins.next(1).arguments[1].right.known_object.class
|
||||
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
|
||||
|
@ -1,16 +1,16 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestAssignMom < MiniTest::Test
|
||||
class TestAssignSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "local = 5;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||
end
|
||||
def test_slot_is_set
|
||||
assert @ins.left
|
||||
@ -25,19 +25,19 @@ module Vool
|
||||
assert @ins.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
||||
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
|
||||
end
|
||||
end
|
||||
|
||||
#otherwise as above, but assigning instance, so should get a SlotLoad
|
||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
||||
class TestAssignSlotMachineInstanceToLocal < MiniTest::Test
|
||||
include VoolCompile
|
||||
def setup
|
||||
@compiler = compile_main( "@a = 5 ; local = @a;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.next.class , @ins
|
||||
assert_equal SlotMachine::SlotLoad , @ins.next.class , @ins
|
||||
end
|
||||
end
|
||||
|
||||
@ -47,11 +47,11 @@ module Vool
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "arg = 5;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||
end
|
||||
def test_slot_is_set
|
||||
assert @ins.left
|
||||
@ -64,22 +64,22 @@ module Vool
|
||||
end
|
||||
end
|
||||
|
||||
class TestAssignMomToInstance < MiniTest::Test
|
||||
class TestAssignSlotMachineToInstance < MiniTest::Test
|
||||
include VoolCompile
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
end
|
||||
def test_assigns_const
|
||||
@compiler = compile_main( "@a = 5;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
|
||||
@ins = @compiler.slot_instructions.next
|
||||
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class , @ins
|
||||
end
|
||||
def test_assigns_move
|
||||
@compiler = compile_main( "@a = arg;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::SlotDefinition , @ins.right.class , @ins
|
||||
@ins = @compiler.slot_instructions.next
|
||||
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||
assert_equal SlotMachine::SlotDefinition , @ins.right.class , @ins
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -11,10 +11,10 @@ module Vool
|
||||
def as_ruby
|
||||
@ruby = Ruby::RubyCompiler.compile(@code)
|
||||
end
|
||||
def as_mom
|
||||
def as_slot
|
||||
vool = as_ruby.to_vool
|
||||
vool.to_parfait
|
||||
vool.to_mom(nil)
|
||||
vool.to_slot(nil)
|
||||
end
|
||||
def test_boot
|
||||
assert_equal String , @code.class
|
||||
@ -36,17 +36,17 @@ module Vool
|
||||
assert_equal Vool::ReturnStatement , vool.body.first.body.class
|
||||
assert_equal Vool::MacroExpression , vool.body.first.body.return_value.class
|
||||
end
|
||||
def test_mom_basic
|
||||
mom = as_mom
|
||||
assert_equal Mom::MomCollection , mom.class
|
||||
assert_equal Mom::MethodCompiler , mom.method_compilers.class
|
||||
def test_slot_basic
|
||||
mom = as_slot
|
||||
assert_equal SlotMachine::SlotCollection , mom.class
|
||||
assert_equal SlotMachine::MethodCompiler , mom.method_compilers.class
|
||||
end
|
||||
def test_mom_instructions
|
||||
mom_compiler = as_mom.method_compilers
|
||||
assert_equal Mom::Label , mom_compiler.mom_instructions.class
|
||||
assert_equal Mom::IntOperator , mom_compiler.mom_instructions.next.class
|
||||
assert_equal Mom::SlotLoad , mom_compiler.mom_instructions.next(2).class
|
||||
assert_equal Mom::ReturnJump , mom_compiler.mom_instructions.next(3).class
|
||||
def test_slot_instructions
|
||||
mom_compiler = as_slot.method_compilers
|
||||
assert_equal SlotMachine::Label , mom_compiler.slot_instructions.class
|
||||
assert_equal SlotMachine::IntOperator , mom_compiler.slot_instructions.next.class
|
||||
assert_equal SlotMachine::SlotLoad , mom_compiler.slot_instructions.next(2).class
|
||||
assert_equal SlotMachine::ReturnJump , mom_compiler.slot_instructions.next(3).class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end; return")
|
||||
@ins = @compiler.mom_instructions
|
||||
@ins = @compiler.slot_instructions
|
||||
end
|
||||
|
||||
def test_label
|
||||
|
@ -33,15 +33,15 @@ module Vool
|
||||
m = clazz.single_class.instance_type.get_method(:meth)
|
||||
assert m , "no type method :meth"
|
||||
end
|
||||
def as_mom
|
||||
def as_slot
|
||||
@clazz.to_parfait
|
||||
@clazz.to_mom(nil)
|
||||
@clazz.to_slot(nil)
|
||||
end
|
||||
def test_mom
|
||||
assert_equal :meth , as_mom.method_compilers.callable.name
|
||||
def test_slot
|
||||
assert_equal :meth , as_slot.method_compilers.callable.name
|
||||
end
|
||||
def test_mom_frame
|
||||
callable = as_mom.method_compilers.callable
|
||||
def test_slot_frame
|
||||
callable = as_slot.method_compilers.callable
|
||||
assert callable.frame_type.names.last.to_s.start_with?("tmp_") , "no tmp_ variable #{callable.frame_type.names}"
|
||||
end
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "if(@a) ; @a = 5 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_condition_compiles_to_check
|
||||
|
@ -7,7 +7,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "unless(@a) ; @a = 5 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_condition_compiles_to_check
|
||||
|
@ -2,12 +2,12 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestSimpleIfMom < MiniTest::Test
|
||||
class TestSimpleIfSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_condition_compiles_to_check
|
||||
|
@ -1,12 +1,12 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestConditionIfMom < MiniTest::Test
|
||||
class TestConditionIfSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return" , "Integer.div4")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_condition
|
||||
|
@ -1,12 +1,12 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestIvarMom < MiniTest::Test
|
||||
class TestIvarSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "@a = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_array
|
||||
@ -26,7 +26,7 @@ module Vool
|
||||
end
|
||||
def test_slot_assigns_something
|
||||
assert @ins.right
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
||||
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,19 +1,19 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestLocalMom < MiniTest::Test
|
||||
class TestLocalSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "a = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_compiles_not_array
|
||||
assert Array != @ins.class , @ins
|
||||
end
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||
end
|
||||
def test_slot_is_set
|
||||
assert @ins.left
|
||||
@ -28,21 +28,21 @@ module Vool
|
||||
assert @ins.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
||||
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
|
||||
end
|
||||
end
|
||||
|
||||
class TestArgMom < MiniTest::Test
|
||||
class TestArgSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_main( "arg = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||
end
|
||||
def test_slot_is_set
|
||||
assert @ins.left
|
||||
@ -57,7 +57,7 @@ module Vool
|
||||
assert @ins.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
||||
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
require_relative "helper"
|
||||
module Mom
|
||||
module SlotMachine
|
||||
class PlusEquals < Instruction
|
||||
attr_reader :a , :b
|
||||
def initialize(source , arg , b)
|
||||
@ -14,16 +14,16 @@ module Mom
|
||||
end
|
||||
|
||||
module Vool
|
||||
class TestMacroMom < MiniTest::Test
|
||||
class TestMacroSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "X.plus_equals(arg,1)")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
assert_equal Mom::PlusEquals , @ins.class , @ins
|
||||
assert_equal SlotMachine::PlusEquals , @ins.class , @ins
|
||||
end
|
||||
def test_arg1
|
||||
assert_equal Vool::LocalVariable , @ins.a.class
|
||||
|
@ -1,12 +1,12 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestReturnMom < MiniTest::Test
|
||||
class TestReturnSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "return 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
@ -28,7 +28,7 @@ module Vool
|
||||
assert @ins.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
||||
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
|
||||
end
|
||||
def test_second_is_return
|
||||
assert_equal ReturnJump, @ins.next(1).class
|
||||
@ -37,12 +37,12 @@ module Vool
|
||||
check_array [SlotLoad, ReturnJump, Label, ReturnSequence, Label], @ins
|
||||
end
|
||||
end
|
||||
class TestReturnSendMom < MiniTest::Test
|
||||
class TestReturnSendSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "return 5.div4" , "Integer.div4" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_return_is_last
|
||||
|
@ -1,12 +1,12 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestSimpleWhileMom < MiniTest::Test
|
||||
class TestSimpleWhileSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "while(@a) ; @a = 5 ; end;return")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_compiles_as_while
|
||||
|
@ -2,12 +2,12 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestWhileConditionMom < MiniTest::Test
|
||||
class TestWhileConditionSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return" , "Integer.div4")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_condition_compiles_to_check
|
||||
|
@ -1,12 +1,12 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestYieldArgsSendMom < MiniTest::Test
|
||||
class TestYieldArgsSendSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "return yield(1)" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
|
||||
def test_array
|
||||
@ -65,12 +65,12 @@ module Vool
|
||||
assert_equal ReturnJump, @ins.next(6).class
|
||||
end
|
||||
end
|
||||
class TestYieldNoArgsSendMom < MiniTest::Test
|
||||
class TestYieldNoArgsSendSlotMachine < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@compiler = compile_main( "return yield(some.extra.calls)" )
|
||||
@ins = @compiler.mom_instructions.next
|
||||
@ins = @compiler.slot_instructions.next
|
||||
end
|
||||
def test_check_label
|
||||
assert_equal NotSameCheck, @ins.class
|
||||
|
Reference in New Issue
Block a user