rubyx/test/mom/test_mom_collection.rb

56 lines
1.5 KiB
Ruby
Raw Normal View History

require_relative "helper"
module Mom
class TestMomCollection < MiniTest::Test
include MomCompile
def setup
@comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;")
end
def test_class
assert_equal MomCollection , @comp.class
end
def test_compilers
assert_equal 3 , @comp.compilers.length
end
def test_init_compilers
assert_equal Array , @comp.init_compiler.class
end
def test_init_compiler
assert_equal Mom::MethodCompiler , @comp.init_compiler.first.class
end
def test_compilers_bare
assert_equal 2 , MomCollection.new.compilers.length
end
def test_append_class
assert_equal MomCollection, (@comp.append @comp).class
end
def test_append_length
assert_equal 2 , @comp.append(@comp).method_compilers.length
end
end
2019-08-08 11:18:36 +02:00
class TestMomCollectionToRisc < MiniTest::Test
include MomCompile
def setup
@comp = compile_mom( "class Space ; def main(); return 'Hi'; end; end;")
2019-08-08 11:18:36 +02:00
@collection = @comp.to_risc()
end
def compiler
@collection.method_compilers.first
end
def test_has_to_risc
2019-08-08 11:18:36 +02:00
assert_equal Risc::RiscCollection, @collection.class
end
def test_has_risc_compiler
assert_equal Risc::MethodCompiler, compiler.class
assert_equal 3, @collection.method_compilers.length
end
def test_has_risc_instructions
assert_equal Risc::Label, compiler.risc_instructions.class
2019-08-23 14:31:04 +02:00
assert_equal 13, compiler.risc_instructions.length
2019-08-08 11:18:36 +02:00
end
end
end