2019-08-06 17:33:27 +02:00
|
|
|
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
|
2019-08-07 11:06:06 +02:00
|
|
|
assert_equal MomCollection , @comp.class
|
2019-08-06 17:33:27 +02:00
|
|
|
end
|
|
|
|
def test_compilers
|
2019-09-28 11:41:38 +02:00
|
|
|
assert_equal 3 , @comp.compilers.num_compilers
|
2019-09-15 14:13:11 +02:00
|
|
|
end
|
|
|
|
def test_init_compilers
|
2019-09-28 11:41:38 +02:00
|
|
|
assert_equal MomCollection , @comp.init_compilers.class
|
2019-08-06 17:33:27 +02:00
|
|
|
end
|
|
|
|
def test_compilers_bare
|
2019-09-28 11:41:38 +02:00
|
|
|
assert_equal 2 , MomCollection.new.compilers.num_compilers
|
2019-08-06 17:33:27 +02:00
|
|
|
end
|
|
|
|
def test_append_class
|
2019-08-07 11:06:06 +02:00
|
|
|
assert_equal MomCollection, (@comp.append @comp).class
|
2019-08-06 17:33:27 +02:00
|
|
|
end
|
|
|
|
end
|
2019-08-08 11:18:36 +02:00
|
|
|
class TestMomCollectionToRisc < MiniTest::Test
|
|
|
|
include MomCompile
|
|
|
|
|
|
|
|
def setup
|
2019-09-12 12:10:31 +02:00
|
|
|
@comp = compile_mom( "class Space ; def main(); return 'Hi'; end; end;")
|
2019-08-08 11:18:36 +02:00
|
|
|
@collection = @comp.to_risc()
|
|
|
|
end
|
2019-08-10 20:30:00 +02:00
|
|
|
def compiler
|
2019-09-28 14:07:20 +02:00
|
|
|
@collection.method_compilers
|
2019-08-10 20:30:00 +02:00
|
|
|
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
|
2019-08-10 20:30:00 +02:00
|
|
|
assert_equal Risc::MethodCompiler, compiler.class
|
2019-09-28 14:07:20 +02:00
|
|
|
assert_equal 3, @collection.method_compilers.num_compilers
|
2019-08-10 20:30:00 +02:00
|
|
|
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
|
2019-08-06 17:33:27 +02:00
|
|
|
end
|