tests for word macros
This commit is contained in:
@ -3,7 +3,8 @@ require_relative "../helper"
|
||||
module RubyX
|
||||
module BuiltinHelper
|
||||
def setup
|
||||
@mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(source)
|
||||
whole ="class Space;def main(arg);return;end;end;" + source
|
||||
@mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(whole)
|
||||
@mom.method_compilers.first
|
||||
assert_equal Mom::MomCollection , @mom.class
|
||||
assert_equal Mom::MethodCompiler , compiler.class
|
||||
|
@ -6,11 +6,6 @@ module RubyX
|
||||
include BuiltinHelper
|
||||
def source
|
||||
<<GET
|
||||
class Space
|
||||
def main(arg)
|
||||
return
|
||||
end
|
||||
end
|
||||
class Object
|
||||
def exit(at)
|
||||
X.exit
|
||||
|
@ -6,11 +6,6 @@ module RubyX
|
||||
include BuiltinHelper
|
||||
def source
|
||||
<<GET
|
||||
class Space
|
||||
def main(arg)
|
||||
return
|
||||
end
|
||||
end
|
||||
class Object
|
||||
def __init(at)
|
||||
X.__init
|
||||
|
30
test/rubyx/builtin/test_word_get.rb
Normal file
30
test/rubyx/builtin/test_word_get.rb
Normal file
@ -0,0 +1,30 @@
|
||||
require_relative "helper"
|
||||
|
||||
module RubyX
|
||||
module Builtin
|
||||
class TestWordGet < MiniTest::Test
|
||||
include BuiltinHelper
|
||||
def source
|
||||
<<GET
|
||||
class Word
|
||||
def get_internal_byte(at)
|
||||
X.get_internal_byte
|
||||
end
|
||||
end
|
||||
GET
|
||||
end
|
||||
def test_mom_meth
|
||||
assert_equal :get_internal_byte , compiler.callable.name
|
||||
end
|
||||
def test_instr_len
|
||||
assert_equal 7 , compiler.mom_instructions.length
|
||||
end
|
||||
def test_instr_get
|
||||
assert_equal Mom::GetInternalByte , compiler.mom_instructions.next.class
|
||||
end
|
||||
def test_risc
|
||||
assert_equal 41 , compiler.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
30
test/rubyx/builtin/test_word_putstring.rb
Normal file
30
test/rubyx/builtin/test_word_putstring.rb
Normal file
@ -0,0 +1,30 @@
|
||||
require_relative "helper"
|
||||
|
||||
module RubyX
|
||||
module Builtin
|
||||
class TestWordPutstring < MiniTest::Test
|
||||
include BuiltinHelper
|
||||
def source
|
||||
<<GET
|
||||
class Word
|
||||
def putstring
|
||||
X.putstring
|
||||
end
|
||||
end
|
||||
GET
|
||||
end
|
||||
def test_mom_meth
|
||||
assert_equal :putstring , compiler.callable.name
|
||||
end
|
||||
def test_instr_len
|
||||
assert_equal 7 , compiler.mom_instructions.length
|
||||
end
|
||||
def test_instr_get
|
||||
assert_equal Mom::Putstring , compiler.mom_instructions.next.class
|
||||
end
|
||||
def test_risc
|
||||
assert_equal 44 , compiler.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
30
test/rubyx/builtin/test_word_set.rb
Normal file
30
test/rubyx/builtin/test_word_set.rb
Normal file
@ -0,0 +1,30 @@
|
||||
require_relative "helper"
|
||||
|
||||
module RubyX
|
||||
module Builtin
|
||||
class TestWordSet < MiniTest::Test
|
||||
include BuiltinHelper
|
||||
def source
|
||||
<<GET
|
||||
class Word
|
||||
def set_internal_byte( at , value)
|
||||
X.set_internal_byte
|
||||
end
|
||||
end
|
||||
GET
|
||||
end
|
||||
def test_mom_meth
|
||||
assert_equal :set_internal_byte , compiler.callable.name
|
||||
end
|
||||
def test_instr_len
|
||||
assert_equal 7 , compiler.mom_instructions.length
|
||||
end
|
||||
def test_instr_get
|
||||
assert_equal Mom::SetInternalByte , compiler.mom_instructions.next.class
|
||||
end
|
||||
def test_risc
|
||||
assert_equal 20 , compiler.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user