Change Mom to SlotMachine
rather large commit, but essentially a simple rename Rationale in docs and blogs
This commit is contained in:
10
test/slot_machine/macro/README.md
Normal file
10
test/slot_machine/macro/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Builtin Testing
|
||||
|
||||
At the Module level (word/object/integer) mostly testing that
|
||||
- functions exist
|
||||
- they compile
|
||||
- basic length tests (no "contents")
|
||||
|
||||
Minimal tests for risc compilation, and again length only (should be array too)
|
||||
|
||||
Functionality is tested by interpreter over in interpreter dir
|
17
test/slot_machine/macro/helper.rb
Normal file
17
test/slot_machine/macro/helper.rb
Normal file
@ -0,0 +1,17 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Mom
|
||||
module Builtin
|
||||
class BootTest < MiniTest::Test
|
||||
include Preloader
|
||||
|
||||
def get_compiler(clazz , name)
|
||||
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
|
||||
coll = compiler.ruby_to_mom( get_preload("Space.main;#{clazz}.#{name}") )
|
||||
@method = coll.method_compilers.last_compiler
|
||||
@method
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
36
test/slot_machine/macro/test_comparison.rb
Normal file
36
test/slot_machine/macro/test_comparison.rb
Normal file
@ -0,0 +1,36 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestIntComp1Risc < BootTest
|
||||
def setup
|
||||
@method = get_compiler("Integer",:lt)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :< , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 26 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
class TestIntComp2Risc < BootTest
|
||||
def setup
|
||||
@method = get_compiler("Integer",:gt)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :> , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 26 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
21
test/slot_machine/macro/test_div10.rb
Normal file
21
test/slot_machine/macro/test_div10.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestIntDiv10Risc < BootTest
|
||||
def setup
|
||||
@method = get_compiler("Integer",:div10)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :div10 , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 70 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
22
test/slot_machine/macro/test_div4.rb
Normal file
22
test/slot_machine/macro/test_div4.rb
Normal file
@ -0,0 +1,22 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestIntDiv4Risc < BootTest
|
||||
def setup
|
||||
@method = get_compiler("Integer",:div4)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :div4 , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
assert_equal :div4 , @method.callable.name
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 41 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
22
test/slot_machine/macro/test_exit.rb
Normal file
22
test/slot_machine/macro/test_exit.rb
Normal file
@ -0,0 +1,22 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestObjectExitRisc < BootTest
|
||||
def setup
|
||||
super
|
||||
@method = get_compiler("Object",:exit)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :exit , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 40 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
22
test/slot_machine/macro/test_get_internal_byte.rb
Normal file
22
test/slot_machine/macro/test_get_internal_byte.rb
Normal file
@ -0,0 +1,22 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestWordGetRisc < BootTest
|
||||
def setup
|
||||
super
|
||||
@method = get_compiler("Word",:get)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :get_internal_byte , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 41 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
22
test/slot_machine/macro/test_get_internal_word.rb
Normal file
22
test/slot_machine/macro/test_get_internal_word.rb
Normal file
@ -0,0 +1,22 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestWordGetRisc < BootTest
|
||||
def setup
|
||||
super
|
||||
@method = get_compiler("Object",:get)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :get_internal_word , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 18 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
23
test/slot_machine/macro/test_init.rb
Normal file
23
test/slot_machine/macro/test_init.rb
Normal file
@ -0,0 +1,23 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestObjectInitRisc < BootTest
|
||||
def setup
|
||||
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
|
||||
coll = compiler.ruby_to_slot( get_preload("Space.main") )
|
||||
@method = SlotCollection.create_init_compiler
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :__init__ , @method.callable.name
|
||||
assert_equal 2 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 19 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
21
test/slot_machine/macro/test_method_missing.rb
Normal file
21
test/slot_machine/macro/test_method_missing.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestObjectMissingRisc < BootTest
|
||||
def setup
|
||||
@method = get_compiler("Object",:missing)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :method_missing , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 15 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
36
test/slot_machine/macro/test_operator.rb
Normal file
36
test/slot_machine/macro/test_operator.rb
Normal file
@ -0,0 +1,36 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestIntOpPl < BootTest
|
||||
def setup
|
||||
@method = get_compiler("Integer",:and)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :& , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 42 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
class TestIntOpMM < BootTest
|
||||
def setup
|
||||
@method = get_compiler("Integer",:or)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :| , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 42 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
21
test/slot_machine/macro/test_putstring.rb
Normal file
21
test/slot_machine/macro/test_putstring.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestWordPutRisc < BootTest
|
||||
def setup
|
||||
@method = get_compiler("Word",:put)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :putstring , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 44 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
22
test/slot_machine/macro/test_set_internal_byte.rb
Normal file
22
test/slot_machine/macro/test_set_internal_byte.rb
Normal file
@ -0,0 +1,22 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestWordSetRisc < BootTest
|
||||
def setup
|
||||
super
|
||||
@method = get_compiler("Word",:set)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :set_internal_byte , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 20 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
21
test/slot_machine/macro/test_set_internal_word.rb
Normal file
21
test/slot_machine/macro/test_set_internal_word.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
module Builtin
|
||||
class TestWordSetRisc < BootTest
|
||||
def setup
|
||||
@method = get_compiler("Word",:set)
|
||||
end
|
||||
def test_slot_length
|
||||
assert_equal :set_internal_byte , @method.callable.name
|
||||
assert_equal 7 , @method.slot_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 20 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user