move some tests around (and fix them)
This commit is contained in:
parent
55b5884c4e
commit
63dfee0978
@ -16,7 +16,6 @@ module Mom
|
|||||||
platform = Risc::Platform.for(platform_sym)
|
platform = Risc::Platform.for(platform_sym)
|
||||||
assemblers = translate_methods( platform.translator )
|
assemblers = translate_methods( platform.translator )
|
||||||
Risc::Linker.new(platform , assemblers)
|
Risc::Linker.new(platform , assemblers)
|
||||||
#@cpu_init = risc_init.to_cpu(@platform.translator)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# go through all methods and translate them to cpu, given the translator
|
# go through all methods and translate them to cpu, given the translator
|
||||||
|
@ -19,29 +19,4 @@ module Mom
|
|||||||
assert @comp.translate(:interpreter)
|
assert @comp.translate(:interpreter)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
47
test/mom/test_mom_compiler1.rb
Normal file
47
test/mom/test_mom_compiler1.rb
Normal file
@ -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
|
@ -22,7 +22,7 @@ module Risc
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!
|
Parfait.boot!
|
||||||
@machine = Risc.machine.boot
|
Risc.boot!
|
||||||
@translator = IdentityTranslator.new
|
@translator = IdentityTranslator.new
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -32,37 +32,6 @@ module Risc
|
|||||||
translated = @translator.translate(load)
|
translated = @translator.translate(load)
|
||||||
assert label != translated.constant
|
assert label != translated.constant
|
||||||
end
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user