fixing risc collection tests

This commit is contained in:
2019-08-12 16:12:17 +03:00
parent 9a2716280c
commit 9474932320
7 changed files with 77 additions and 31 deletions

View File

@ -13,13 +13,13 @@ module Mom
assert_equal MomCollection , @comp.class
end
def test_compilers
assert_equal 1 , @comp.compilers.length
assert_equal 22 , @comp.compilers.length
end
def test_boot_compilers
# assert_equal 22 , @comp.boot_compilers.length
assert_equal 21 , @comp.boot_compilers.length
end
def test_compilers_bare
assert_equal 0 , MomCollection.new.compilers.length
assert_equal 21 , MomCollection.new.compilers.length
end
def test_returns_constants
assert_equal Array , @comp.constants.class
@ -50,7 +50,7 @@ module Mom
end
def test_has_risc_compiler
assert_equal Risc::MethodCompiler, compiler.class
assert_equal 1, @collection.method_compilers.length
assert_equal 22, @collection.method_compilers.length
end
def test_has_risc_instructions
assert_equal Risc::Label, compiler.risc_instructions.class

View File

@ -0,0 +1,59 @@
require_relative "helper"
module Risc
class TestMomCompilerTranslate < MiniTest::Test
include MomCompile
def setup
Parfait.boot!(Parfait.default_test_options)
@comp = compile_mom( "class Test ; def main(); main{return 'Ho'};return 'Hi'; end; end;")
@linker = @comp.to_risc.translate(:interpreter)
end
def test_translate_class
assert_equal Linker , @linker.class
end
def test_linker_has_constants
assert_equal Array , @linker.constants.class
end
def test_linker_constants_not_empty
assert !@linker.constants.empty?
end
def test_linker_constants_contains_hi
assert @linker.constants.include?("Hi")
end
def test_linker_constants_contains_ho
assert @linker.constants.include?("Ho")
end
def test_translate_platform
assert_kind_of Platform , @linker.platform
end
def test_translate_assemblers
assert_equal Assembler , @linker.assemblers.first.class
end
def test_assembler_code
assert_equal Label , @linker.assemblers.first.instructions.class
end
def test_assembler_assembled
assert_equal LoadConstant , @linker.assemblers.first.instructions.next.class
end
def test_no_loops_in_chain
@linker.assemblers.each do |asm|
all = []
asm.instructions.each do |ins|
assert !all.include?(ins) , "Double in #{asm.callable.name}:#{ins}"
all << ins
end
end
end
def test_no_risc
@linker.position_all
@linker.create_binary
@linker.assemblers.each do |asm|
asm.instructions.each do |ins|
ins.assemble(Util::DevNull.new)
end # risc instruction don't have an assemble
end
end
end
end

View File

@ -5,7 +5,6 @@ module Risc
include MomCompile
def setup
Parfait.boot!(Parfait.default_test_options)
@comp = compile_mom( "class Test ; def main(); main{return 'Ho'};return 'Hi'; end; end;")
@linker = @comp.to_risc.translate(:interpreter)
end