Change Mom to SlotMachine

rather large commit, but essentially a simple rename
Rationale in docs and blogs
This commit is contained in:
2019-10-03 20:55:41 +03:00
parent fd8a3e9cc5
commit c43436f35a
170 changed files with 481 additions and 480 deletions

View File

@ -15,7 +15,7 @@ time comes to move to rubyx, less work.
ruby test/test_all.rb
''''
### Parfait, Risc , Arm , Mom
### Parfait, Risc , Arm , SlotMachine
Follow the directory structure of the source and may be called unit tests

View File

@ -1,24 +0,0 @@
require_relative "helper"
module Vool
class TestClassStatementMom < MiniTest::Test
include MomCompile
def setup
@ret = compile_mom( as_main("return 1"))
end
def test_return_class
assert_equal Mom::MomCollection , @ret.class
end
def test_has_compilers
assert_equal Mom::MethodCompiler , @ret.method_compilers.class
end
def test_constant
assert @ret.method_compilers.add_constant( Parfait::Integer.new(5) )
end
end
end

View File

@ -6,7 +6,7 @@ module Risc
def setup
Parfait.boot!(Parfait.default_test_options)
Risc.boot!
label = Mom::Label.new( "source_name", "return_label")
label = SlotMachine::Label.new( "source_name", "return_label")
@builder = Risc::MethodCompiler.new( FakeCallable.new ,label).builder("source")
@label = Risc.label("source","name")
@start = @builder.compiler.current

View File

@ -5,8 +5,8 @@ module Risc
include Parfait::MethodHelper
def setup
Parfait.boot!(Parfait.default_test_options)
@method = Mom::MomCollection.compiler_for( :Space , :main,{},{}).callable
@compiler = Risc::MethodCompiler.new( @method , Mom::Label.new( "source_name", "return_label"))
@method = SlotMachine::SlotCollection.compiler_for( :Space , :main,{},{}).callable
@compiler = Risc::MethodCompiler.new( @method , SlotMachine::Label.new( "source_name", "return_label"))
@builder = @compiler.builder(@method)
end
def test_inserts_built

View File

@ -7,7 +7,7 @@ module Risc
Parfait.boot!(Parfait.default_test_options)
Risc.boot!
method = FakeCallable.new
@compiler = Risc::MethodCompiler.new( method, Mom::Label.new( "source_name", "return_label") )
@compiler = Risc::MethodCompiler.new( method, SlotMachine::Label.new( "source_name", "return_label") )
@builder = @compiler.builder(method)
end
def test_list

View File

@ -12,7 +12,7 @@ module Risc
def setup
Parfait.boot!({})
label = Mom::Label.new("hi","ho")
label = SlotMachine::Label.new("hi","ho")
@compiler = FakeCallableCompiler.new(FakeCallable.new , label)
end
def test_ok
@ -25,7 +25,7 @@ module Risc
assert_equal Label , @compiler.current.class
assert_equal "ho" , @compiler.current.name
end
def test_mom
def test_slot
assert @compiler.risc_instructions
end
def test_const

View File

@ -7,7 +7,7 @@ module Risc
def setup
code = in_Test("def meth; @ivar = 5;return ;end")
rubyx = RubyX::RubyXCompiler.new(RubyX.default_test_options)
@compiler = rubyx.ruby_to_mom(code).compilers.to_risc
@compiler = rubyx.ruby_to_slot(code).compilers.to_risc
end
def test_compiles_risc
assert_equal Risc::MethodCompiler , @compiler.class

View File

@ -1,11 +1,11 @@
require_relative "helper"
module Risc
class TestMomCompilerTranslate < MiniTest::Test
include MomCompile
class TestSlotMachineCompilerTranslate < MiniTest::Test
include SlotMachineCompile
def setup
@comp = compile_mom( "class Space ; def main(); main{return 'Ho'};return 'Hi'; end; end;")
@comp = compile_slot( "class Space ; def main(); main{return 'Ho'};return 'Hi'; end; end;")
@linker = @comp.to_risc.translate(:interpreter)
end

View File

@ -1,11 +1,11 @@
require_relative "helper"
module Risc
class TestMomCompilerTranslate < MiniTest::Test
include MomCompile
class TestSlotMachineCompilerTranslate < MiniTest::Test
include SlotMachineCompile
def setup
@comp = compile_mom( "class Space ; def main(); main{return 'Ho'};return 'Hi'; end; end;")
@comp = compile_slot( "class Space ; def main(); main{return 'Ho'};return 'Hi'; end; end;")
@linker = @comp.to_risc.translate(:interpreter)
end

View File

@ -9,14 +9,14 @@ module RubyX
options = RubyX.default_test_options.merge(options)
RubyXCompiler.new(options).ruby_to_vool(input)
end
def ruby_to_mom(input , options = {})
def ruby_to_slot(input , options = {})
options = RubyX.default_test_options.merge(options)
RubyXCompiler.new(options).ruby_to_mom(input)
RubyXCompiler.new(options).ruby_to_slot(input)
end
def compile_in_test( input , options = {})
vool = ruby_to_vool(in_Test(input) , options)
vool.to_parfait
vool.to_mom(nil)
vool.to_slot(nil)
itest = Parfait.object_space.get_class_by_name(:Test)
assert itest
itest

View File

@ -10,10 +10,10 @@ On the way there, we start by Testing and moving the old ones. Since we want to
to test some methods even after the move, without parsing/processing the whole of parfait
we have to have a method of "injecting" the single? methods.
## Mom level
## SlotMachine level
There a re two test levels to every method. Mom being the first, where we basically just
see if the right Mom instruction has been generated
There a re two test levels to every method. SlotMachine being the first, where we basically just
see if the right SlotMachine instruction has been generated
## Risc

View File

@ -4,10 +4,10 @@ module RubyX
module MacroHelper
def setup
whole ="class Space;def main(arg);return;end;end;" + source
@mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(whole)
@mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(whole)
@mom.method_compilers
assert_equal Mom::MomCollection , @mom.class
assert_equal Mom::MethodCompiler , compiler.class
assert_equal SlotMachine::SlotCollection , @mom.class
assert_equal SlotMachine::MethodCompiler , compiler.class
end
def compiler
@mom.method_compilers.last_compiler

View File

@ -15,15 +15,15 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal op , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_op
assert_equal Mom::Comparison , compiler.mom_instructions.next.class
assert_equal op , compiler.mom_instructions.next.operator
assert_equal SlotMachine::Comparison , compiler.slot_instructions.next.class
assert_equal op , compiler.slot_instructions.next.operator
end
def test_risc
assert_equal len , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :div10 , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Div10 , compiler.mom_instructions.next.class
assert_equal SlotMachine::Div10 , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 70 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :div4 , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Div4 , compiler.mom_instructions.next.class
assert_equal SlotMachine::Div4 , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 41 , compiler.to_risc.risc_instructions.length

View File

@ -14,15 +14,15 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal op , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_op
assert_equal Mom::IntOperator , compiler.mom_instructions.next.class
assert_equal op , compiler.mom_instructions.next.operator
assert_equal SlotMachine::IntOperator , compiler.slot_instructions.next.class
assert_equal op , compiler.slot_instructions.next.operator
end
def test_risc
assert_equal 42 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :exit , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Exit , compiler.mom_instructions.next.class
assert_equal SlotMachine::Exit , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 40 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :get_internal_word , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::GetInternalWord , compiler.mom_instructions.next.class
assert_equal SlotMachine::GetInternalWord , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 18 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :__init , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Init , compiler.mom_instructions.next.class
assert_equal SlotMachine::Init , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 31 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :method_missing , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::MethodMissing , compiler.mom_instructions.next.class
assert_equal SlotMachine::MethodMissing , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 15 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :set_internal_word , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::SetInternalWord , compiler.mom_instructions.next.class
assert_equal SlotMachine::SetInternalWord , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 19 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :get_internal_byte , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::GetInternalByte , compiler.mom_instructions.next.class
assert_equal SlotMachine::GetInternalByte , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 41 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :putstring , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Putstring , compiler.mom_instructions.next.class
assert_equal SlotMachine::Putstring , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 44 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :set_internal_byte , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::SetInternalByte , compiler.mom_instructions.next.class
assert_equal SlotMachine::SetInternalByte , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 20 , compiler.to_risc.risc_instructions.length

View File

@ -8,7 +8,7 @@ Since we need Parfait in the runtime, we need to parse it and compile it.
And since it is early days, we expect errors at every level during this process, which
means testing every layer for every file.
Rather than create parfait tests for every layer (ie in the vool/mom/risc directories)
Rather than create parfait tests for every layer (ie in the vool/slot_machine/risc directories)
we have one file per parfait file here. Each file tests all layers.
The usual workflow is to start with a new file and create tests for vool, mom, risc,binary

View File

@ -27,9 +27,9 @@ module RubyX
assert_equal :Data4 , vool[2].name
assert_equal :Data8 , vool[3].name
end
def test_mom
mom = @compiler.ruby_to_mom source
assert_equal Mom::MomCollection , mom.class
def test_slot
mom = @compiler.ruby_to_slot source
assert_equal SlotMachine::SlotCollection , mom.class
end
def test_risc
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)

View File

@ -25,12 +25,12 @@ module RubyX
assert_equal :Data4 , vool[2].name
assert_equal :Data8 , vool[3].name
end
def test_mom
def test_slot
vool = @compiler.ruby_to_vool source
vool.to_parfait
#puts vool
mom = vool.to_mom(nil)
assert_equal Mom::MomCollection , mom.class
mom = vool.to_slot(nil)
assert_equal SlotMachine::SlotCollection , mom.class
end
def est_risc
risc = compiler.ruby_to_risc source

View File

@ -18,9 +18,9 @@ module RubyX
assert_equal Vool::ClassExpression , vool.class
assert_equal :Object , vool.name
end
def test_mom
mom = compiler.ruby_to_mom source
assert_equal Mom::MomCollection , mom.class
def test_slot
mom = compiler.ruby_to_slot source
assert_equal SlotMachine::SlotCollection , mom.class
end
def test_risc
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)

View File

@ -1,24 +1,24 @@
require_relative "helper"
module RubyX
class TestRubyXCompilerMom < MiniTest::Test
class TestRubyXCompilerSlotMachine < MiniTest::Test
include ScopeHelper
include RubyXHelper
def test_creates_class_without_deriviation
ruby_to_mom "class Testing ; end"
ruby_to_slot "class Testing ; end"
clazz = Parfait.object_space.get_class_by_name(:Testing)
assert clazz , "No classes created"
assert_equal :Object , clazz.super_class_name
end
def test_creates_class_deriviation
mom = ruby_to_mom "class Testing ; end"
mom = ruby_to_slot "class Testing ; end"
assert mom , "No classes created"
end
def test_creates_class_with_deriviation
ruby_to_mom "class Test2 < List ;end"
ruby_to_slot "class Test2 < List ;end"
clazz = Parfait.object_space.get_class_by_name(:Test2)
assert clazz, "No classes created"
assert_equal :List , clazz.super_class_name

View File

@ -1,13 +1,13 @@
require_relative '../helper'
module Mom
module SlotMachine
class InstructionMock < Instruction
def initialize
super("mocking")
end
end
# Most MomInstructionTests test the risc instructions of the mom instruction
# Most SlotMachineInstructionTests test the risc instructions of the mom instruction
# quite carefully, ie every instruction, every register.
#
# This is done with the assert methods in risc_assert
@ -16,7 +16,7 @@ module Mom
# For working code, one can get a list of those instructions by using the all_str as message
# Most tests will test for length and give the all_str as message to see where it went wrong
# like: assert_equal 8 , all.length , all_str
class MomInstructionTest < MiniTest::Test
class SlotMachineInstructionTest < MiniTest::Test
include Output
def setup
Parfait.boot!(Parfait.default_test_options)

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestArgumentTransfer < MomInstructionTest
module SlotMachine
class TestArgumentTransfer < SlotMachineInstructionTest
def instruction
receiver = SlotDefinition.new(:message , [:receiver])
arg = SlotLoad.new("test", [:message, :caller] , [:message,:type] )

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TesBlockYield < MomInstructionTest
module SlotMachine
class TesBlockYield < SlotMachineInstructionTest
def instruction
BlockYield.new("source",1)
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestDynamicCall < MomInstructionTest
module SlotMachine
class TestDynamicCall < SlotMachineInstructionTest
def instruction
DynamicCall.new(nil,nil)
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestJump < MomInstructionTest
module SlotMachine
class TestJump < SlotMachineInstructionTest
def instruction
Jump.new( Label.new("ok" , "target"))
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestMessageSetupInt < MomInstructionTest
module SlotMachine
class TestMessageSetupInt < SlotMachineInstructionTest
def instruction
MessageSetup.new( 1 )
end
@ -18,7 +18,7 @@ module Mom
assert_reg_to_slot risc(3) , :r1 , :r2 , 7
end
end
class TestMessageSetupCache < MomInstructionTest
class TestMessageSetupCache < SlotMachineInstructionTest
include Parfait::MethodHelper
def instruction

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestNotSameCheck < MomInstructionTest
module SlotMachine
class TestNotSameCheck < SlotMachineInstructionTest
def instruction
target = SlotDefinition.new(:message , :caller)
NotSameCheck.new(target , target , Label.new("ok" , "target"))

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestResolveMethod < MomInstructionTest
module SlotMachine
class TestResolveMethod < SlotMachineInstructionTest
include Parfait::MethodHelper
def instruction

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestReturnJump < MomInstructionTest
module SlotMachine
class TestReturnJump < SlotMachineInstructionTest
def instruction
ReturnJump.new("source",Label.new("ok" , "return"))
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestReturnSequence < MomInstructionTest
module SlotMachine
class TestReturnSequence < SlotMachineInstructionTest
def instruction
ReturnSequence.new("source")
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestSimpleCall < MomInstructionTest
module SlotMachine
class TestSimpleCall < SlotMachineInstructionTest
include Parfait::MethodHelper
def instruction

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotDefinitionBasics < MiniTest::Test
def slot(slot = :caller)

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotDefinitionConstant < MiniTest::Test
def setup

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotDefinitionKnown1 < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotDefinitionKnown2 < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotLoadBasics < MiniTest::Test
def test_ins_ok

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotLoad1 < MiniTest::Test
def setup

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotLoad2 < MiniTest::Test
def setup

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotLoad3 < MiniTest::Test
include Parfait::MethodHelper

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestSameCheck < MomInstructionTest
module SlotMachine
class TestSameCheck < SlotMachineInstructionTest
def instruction
target = SlotDefinition.new(:message , :caller)
TruthCheck.new(target , Label.new("ok" , "target"))

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestIntComp1Risc < BootTest
def setup
@method = get_compiler("Integer",:lt)
end
def test_mom_length
def test_slot_length
assert_equal :< , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class
@ -21,9 +21,9 @@ module Mom
def setup
@method = get_compiler("Integer",:gt)
end
def test_mom_length
def test_slot_length
assert_equal :> , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestIntDiv10Risc < BootTest
def setup
@method = get_compiler("Integer",:div10)
end
def test_mom_length
def test_slot_length
assert_equal :div10 , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestIntDiv4Risc < BootTest
def setup
@method = get_compiler("Integer",:div4)
end
def test_mom_length
def test_slot_length
assert_equal :div4 , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,15 +1,15 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestObjectExitRisc < BootTest
def setup
super
@method = get_compiler("Object",:exit)
end
def test_mom_length
def test_slot_length
assert_equal :exit , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,15 +1,15 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestWordGetRisc < BootTest
def setup
super
@method = get_compiler("Word",:get)
end
def test_mom_length
def test_slot_length
assert_equal :get_internal_byte , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,15 +1,15 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestWordGetRisc < BootTest
def setup
super
@method = get_compiler("Object",:get)
end
def test_mom_length
def test_slot_length
assert_equal :get_internal_word , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,16 +1,16 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestObjectInitRisc < BootTest
def setup
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
coll = compiler.ruby_to_mom( get_preload("Space.main") )
@method = MomCollection.create_init_compiler
coll = compiler.ruby_to_slot( get_preload("Space.main") )
@method = SlotCollection.create_init_compiler
end
def test_mom_length
def test_slot_length
assert_equal :__init__ , @method.callable.name
assert_equal 2 , @method.mom_instructions.length
assert_equal 2 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestObjectMissingRisc < BootTest
def setup
@method = get_compiler("Object",:missing)
end
def test_mom_length
def test_slot_length
assert_equal :method_missing , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestIntOpPl < BootTest
def setup
@method = get_compiler("Integer",:and)
end
def test_mom_length
def test_slot_length
assert_equal :& , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class
@ -21,9 +21,9 @@ module Mom
def setup
@method = get_compiler("Integer",:or)
end
def test_mom_length
def test_slot_length
assert_equal :| , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestWordPutRisc < BootTest
def setup
@method = get_compiler("Word",:put)
end
def test_mom_length
def test_slot_length
assert_equal :putstring , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,15 +1,15 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestWordSetRisc < BootTest
def setup
super
@method = get_compiler("Word",:set)
end
def test_mom_length
def test_slot_length
assert_equal :set_internal_byte , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestWordSetRisc < BootTest
def setup
@method = get_compiler("Word",:set)
end
def test_mom_length
def test_slot_length
assert_equal :set_internal_byte , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestBlockCompiler1 < MiniTest::Test
include ScopeHelper

View File

@ -3,13 +3,13 @@ require_relative "helper"
module Vool
class TestBlockArg < MiniTest::Test
include MomCompile
include SlotMachineCompile
def setup
@ret = compile_mom( as_main("self.main {|elem| elem = 5 } "))
@ret = compile_slot( as_main("self.main {|elem| elem = 5 } "))
end
def test_is_compiler
assert_equal Mom::MomCollection , @ret.class
assert_equal SlotMachine::SlotCollection , @ret.class
end
def test_has_method
assert_equal Parfait::CallableMethod , @ret.method_compilers.get_method.class
@ -19,9 +19,9 @@ module Vool
end
end
class TestBlockLocal < MiniTest::Test
include MomCompile
include SlotMachineCompile
def setup
@ret = compile_mom( as_main("self.main {|elem| local = 5 } "))
@ret = compile_slot( as_main("self.main {|elem| local = 5 } "))
@block = @ret.method_compilers.get_method.blocks
end
def test_block_arg_type
@ -38,16 +38,16 @@ module Vool
end
end
class TestBlockMethodArg < MiniTest::Test
include MomCompile
include SlotMachineCompile
def setup
end
def test_method_arg_compiles
ret = compile_mom( as_main("self.main {|elem| arg = 5 } "))
ret = compile_slot( as_main("self.main {|elem| arg = 5 } "))
assert ret
end
def test_method_local_compiles
ret = compile_mom( as_main("local = 5 ; self.main {|elem| local = 10 } "))
ret = compile_slot( as_main("local = 5 ; self.main {|elem| local = 10 } "))
assert ret
end
end

View File

@ -1,5 +1,5 @@
require_relative "helper"
module Mom
module SlotMachine
class FakeCallableCompiler < CallableCompiler
def source_name
"luke"
@ -20,8 +20,8 @@ module Mom
assert_equal Label , @compiler.current.class
assert_equal @compiler.source_name , @compiler.current.name
end
def test_mom
assert @compiler.mom_instructions
def test_slot
assert @compiler.slot_instructions
end
def test_const
assert_equal Array , @compiler.constants.class

View File

@ -0,0 +1,24 @@
require_relative "helper"
module Vool
class TestClassStatementSlotMachine < MiniTest::Test
include SlotMachineCompile
def setup
@ret = compile_slot( as_main("return 1"))
end
def test_return_class
assert_equal SlotMachine::SlotCollection , @ret.class
end
def test_has_compilers
assert_equal SlotMachine::MethodCompiler , @ret.method_compilers.class
end
def test_constant
assert @ret.method_compilers.add_constant( Parfait::Integer.new(5) )
end
end
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
module SlotMachine
class TestInstruction < MiniTest::Test
def test_instantiates

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestMethodCompiler < MiniTest::Test
include ScopeHelper
@ -10,7 +10,7 @@ module Mom
def in_test_vool(str)
vool = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_vool(in_Test(str))
vool.to_parfait
vool.to_mom(nil)
vool.to_slot(nil)
vool
end
def create_method(body = "@ivar = 5;return")
@ -62,10 +62,10 @@ module Mom
assert_equal 2 , method.frame_type.variable_index(:a)
end
def constant_setup(input)
mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(in_Test(input))
assert_equal Mom::MomCollection , mom.class
mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(in_Test(input))
assert_equal SlotMachine::SlotCollection , mom.class
compiler = mom.method_compilers
assert_equal Mom::MethodCompiler , compiler.class
assert_equal SlotMachine::MethodCompiler , compiler.class
compiler
end
def test_return_label

View File

@ -1,34 +1,34 @@
require_relative "helper"
module Mom
class TestMomCollection < MiniTest::Test
include MomCompile
module SlotMachine
class TestSlotCollection < MiniTest::Test
include SlotMachineCompile
def setup
@comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;")
@comp = compile_slot( "class Test ; def main(); return 'Hi'; end; end;")
end
def test_class
assert_equal MomCollection , @comp.class
assert_equal SlotCollection , @comp.class
end
def test_compilers
assert_equal 3 , @comp.compilers.num_compilers
end
def test_init_compilers
assert_equal MomCollection , @comp.init_compilers.class
assert_equal SlotCollection , @comp.init_compilers.class
end
def test_compilers_bare
assert_equal 2 , MomCollection.new.compilers.num_compilers
assert_equal 2 , SlotCollection.new.compilers.num_compilers
end
def test_append_class
assert_equal MomCollection, (@comp.append @comp).class
assert_equal SlotCollection, (@comp.append @comp).class
end
end
class TestMomCollectionToRisc < MiniTest::Test
include MomCompile
class TestSlotCollectionToRisc < MiniTest::Test
include SlotMachineCompile
def setup
@comp = compile_mom( "class Space ; def main(); return 'Hi'; end; end;")
@comp = compile_slot( "class Space ; def main(); return 'Hi'; end; end;")
@collection = @comp.to_risc()
end
def compiler

View File

@ -30,24 +30,24 @@ module ScopeHelper
end
module VoolCompile
include ScopeHelper
include Mom
include SlotMachine
include Preloader
def compile_main( input , preload = nil)
input = get_preload(preload) + as_main( input )
collection = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(input)
assert collection.is_a?(Mom::MomCollection) , collection.class.name
collection = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(input)
assert collection.is_a?(SlotMachine::SlotCollection) , collection.class.name
compiler = collection.compilers.find_compiler_name(:main)
assert_equal Mom::MethodCompiler , compiler.class
assert_equal SlotMachine::MethodCompiler , compiler.class
compiler
end
def compile_main_block( block_input , method_input = "main_local = 5" , preload = nil)
source = get_preload(preload) + as_main("#{method_input} ; self.main{|val| #{block_input}}")
mom_col = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom( source )
mom_col = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot( source )
compiler = mom_col.method_compilers.find_compiler_name(:main)
block = mom_col.method_compilers.find_compiler_name(:main_block)
assert block
block.mom_instructions.next
block.slot_instructions.next
end
def check_array( should , is )
index = 0
@ -75,11 +75,11 @@ module VoolCompile
end
module MomCompile
module SlotMachineCompile
include ScopeHelper
def compile_mom(input)
RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(input)
def compile_slot(input)
RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(input)
end
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,7 @@
require_relative "helper"
module VoolBlocks
class TestConditionIfMom < MiniTest::Test
class TestConditionIfSlotMachine < MiniTest::Test
include VoolCompile
def setup

View File

@ -1,7 +1,7 @@
require_relative "helper"
module VoolBlocks
class TestSimpleWhileMom < MiniTest::Test
class TestSimpleWhileSlotMachine < MiniTest::Test
include VoolCompile
def setup

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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