From 63dfee097862dc7148e4ce386c75f45626ffc555 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 2 Jul 2018 23:20:54 +0300 Subject: [PATCH] move some tests around (and fix them) --- lib/mom/mom_compiler.rb | 1 - test/mom/test_mom_compiler.rb | 25 -------------- test/mom/test_mom_compiler1.rb | 47 ++++++++++++++++++++++++++ test/risc/test_interpreter_platform.rb | 33 +----------------- 4 files changed, 48 insertions(+), 58 deletions(-) create mode 100644 test/mom/test_mom_compiler1.rb diff --git a/lib/mom/mom_compiler.rb b/lib/mom/mom_compiler.rb index cb866dea..fa42e3da 100644 --- a/lib/mom/mom_compiler.rb +++ b/lib/mom/mom_compiler.rb @@ -16,7 +16,6 @@ module Mom platform = Risc::Platform.for(platform_sym) assemblers = translate_methods( platform.translator ) Risc::Linker.new(platform , assemblers) - #@cpu_init = risc_init.to_cpu(@platform.translator) end # go through all methods and translate them to cpu, given the translator diff --git a/test/mom/test_mom_compiler.rb b/test/mom/test_mom_compiler.rb index 6bebe52e..ac6aec4f 100644 --- a/test/mom/test_mom_compiler.rb +++ b/test/mom/test_mom_compiler.rb @@ -19,29 +19,4 @@ module Mom assert @comp.translate(:interpreter) end end - class TestMomCompilerTranslate < MiniTest::Test - include MomCompile - - def setup - Parfait.boot! - @comp = compile_mom( "class Test ; def main(); return 1; end; end;") - @trans = @comp.translate(:interpreter) - end - - def test_translate_class - assert_equal Risc::Linker , @trans.class - end - def test_translate_platform - assert_kind_of Risc::Platform , @trans.platform - end - def test_translate_assemblers - assert_equal Risc::Assembler , @trans.assemblers.first.class - end - def test_assembler_code - assert_equal Risc::Label , @trans.assemblers.first.instructions.class - end - def test_assembler_assembled - assert_equal Risc::SlotToReg , @trans.assemblers.first.instructions.next.class - end - end end diff --git a/test/mom/test_mom_compiler1.rb b/test/mom/test_mom_compiler1.rb new file mode 100644 index 00000000..4cd399a9 --- /dev/null +++ b/test/mom/test_mom_compiler1.rb @@ -0,0 +1,47 @@ +require_relative "helper" + +module Mom + class TestMomCompilerTranslate < MiniTest::Test + include MomCompile + + def setup + Parfait.boot! + @comp = compile_mom( "class Test ; def main(); return 1; end; end;") + @linker = @comp.translate(:interpreter) + end + + def test_translate_class + assert_equal Risc::Linker , @linker.class + end + def test_translate_platform + assert_kind_of Risc::Platform , @linker.platform + end + def test_translate_assemblers + assert_equal Risc::Assembler , @linker.assemblers.first.class + end + def test_assembler_code + assert_equal Risc::Label , @linker.assemblers.first.instructions.class + end + def test_assembler_assembled + assert_equal Risc::SlotToReg , @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.method.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 diff --git a/test/risc/test_interpreter_platform.rb b/test/risc/test_interpreter_platform.rb index 12bcae10..77a52603 100644 --- a/test/risc/test_interpreter_platform.rb +++ b/test/risc/test_interpreter_platform.rb @@ -22,7 +22,7 @@ module Risc def setup Parfait.boot! - @machine = Risc.machine.boot + Risc.boot! @translator = IdentityTranslator.new end @@ -32,37 +32,6 @@ module Risc translated = @translator.translate(load) assert label != translated.constant end - def test_translate_first_label - label = Parfait.object_space.get_main.risc_instructions - assert_equal "Space_Type.main" ,label.to_cpu(@translator).name , label - end - - def test_translate_space - assert @machine.translate(:interpreter) - end - - def test_no_loops_in_chain - @machine.translate(:interpreter) - @machine.position_all - init = Parfait.object_space.get_init - all = [] - init.cpu_instructions.each do |ins| - assert !all.include?(ins) - all << ins - end - end - def test_no_risc - @machine.translate(:interpreter) - @machine.position_all - @machine.create_binary - @machine.object_positions.each do | method , position| - next unless method.is_a? Parfait::TypedMethod - method.cpu_instructions.each do |ins| - ins.assemble(Util::DevNull.new) - end - end - end - end end