2019-08-11 13:31:00 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-08-12 11:36:32 +02:00
|
|
|
module Mom
|
2019-08-11 13:31:00 +02:00
|
|
|
module Builtin
|
2019-08-11 19:36:10 +02:00
|
|
|
class TestObjectFunctionGet < BootTest
|
2019-08-11 13:31:00 +02:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@method = get_compiler(:get_internal_word)
|
|
|
|
end
|
|
|
|
def test_has_get_internal
|
|
|
|
assert_equal Mom::MethodCompiler , @method.class
|
|
|
|
end
|
|
|
|
def test_mom_length
|
|
|
|
assert_equal 5 , @method.mom_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
|
2019-08-11 19:36:10 +02:00
|
|
|
class TestObjectFunctionSet < BootTest
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@method = get_compiler(:set_internal_word)
|
|
|
|
end
|
|
|
|
def test_has_get_internal
|
|
|
|
assert_equal Mom::MethodCompiler , @method.class
|
|
|
|
end
|
|
|
|
def test_mom_length
|
|
|
|
assert_equal 5 , @method.mom_instructions.length
|
|
|
|
end
|
|
|
|
def test_compile
|
|
|
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
|
|
|
end
|
|
|
|
def test_risc_length
|
|
|
|
assert_equal 21 , @method.to_risc.risc_instructions.length
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestObjectFunctionMissing < BootTest
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@method = get_compiler(:method_missing)
|
|
|
|
end
|
|
|
|
def test_has_get_internal
|
|
|
|
assert_equal Mom::MethodCompiler , @method.class
|
|
|
|
end
|
|
|
|
def test_mom_length
|
|
|
|
assert_equal 5 , @method.mom_instructions.length
|
|
|
|
end
|
|
|
|
def test_compile
|
|
|
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
|
|
|
end
|
|
|
|
def test_risc_length
|
|
|
|
assert_equal 48 , @method.to_risc.risc_instructions.length
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestObjectFunctionExit < BootTest
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@method = get_compiler(:exit)
|
|
|
|
end
|
|
|
|
def test_has_get_internal
|
|
|
|
assert_equal Mom::MethodCompiler , @method.class
|
|
|
|
end
|
|
|
|
def test_mom_length
|
|
|
|
assert_equal 5 , @method.mom_instructions.length
|
|
|
|
end
|
|
|
|
def test_compile
|
|
|
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
|
|
|
end
|
|
|
|
def test_risc_length
|
|
|
|
assert_equal 46 , @method.to_risc.risc_instructions.length
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestObjectFunctionInit < BootTest
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@method = get_compiler(:__init__)
|
|
|
|
end
|
|
|
|
def test_has_get_internal
|
|
|
|
assert_equal Mom::MethodCompiler , @method.class
|
|
|
|
end
|
|
|
|
def test_mom_length
|
|
|
|
assert_equal 5 , @method.mom_instructions.length
|
|
|
|
end
|
|
|
|
def test_compile
|
|
|
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
|
|
|
end
|
|
|
|
def test_risc_length
|
|
|
|
assert_equal 48 , @method.to_risc.risc_instructions.length
|
|
|
|
end
|
|
|
|
end
|
2019-08-11 13:31:00 +02:00
|
|
|
end
|
|
|
|
end
|