2019-08-12 10:08:09 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-08-12 11:36:32 +02:00
|
|
|
module Mom
|
2019-08-12 10:08:09 +02:00
|
|
|
module Builtin
|
|
|
|
class TestIntDiv4 < BootTest
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@method = get_compiler(:div4)
|
|
|
|
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
|
|
|
|
end
|
|
|
|
class TestIntDiv10 < BootTest
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@method = get_compiler(:div10)
|
|
|
|
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
|
|
|
|
end
|
|
|
|
class TestIntComp1 < BootTest
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@method = get_compiler(:<)
|
|
|
|
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
|
|
|
|
end
|
|
|
|
class TestIntComp2 < BootTest
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@method = get_compiler(:>=)
|
|
|
|
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
|
|
|
|
end
|
2019-08-12 10:31:47 +02:00
|
|
|
class TestIntOperators < BootTest
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
end
|
|
|
|
def each_method &block
|
|
|
|
Risc.operators.each do |name|
|
|
|
|
method = get_compiler(name)
|
|
|
|
block.yield(method)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def test_has_get_internal
|
|
|
|
each_method do |method|
|
|
|
|
assert_equal Mom::MethodCompiler , method.class
|
|
|
|
assert_equal 5 , method.mom_instructions.length
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-08-12 10:08:09 +02:00
|
|
|
end
|
|
|
|
end
|