fix constant propagation through the layers

so they can end up in the binary
This commit is contained in:
Torsten Ruger
2018-07-03 10:12:22 +03:00
parent 63dfee0978
commit bb1d1495db
5 changed files with 29 additions and 9 deletions

View File

@ -6,7 +6,7 @@ module Mom
def setup
Parfait.boot!
@comp = compile_mom( "class Test ; def main(); return 1; end; end;")
@comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;")
end
def test_class
@ -15,6 +15,12 @@ module Mom
def test_compilers
assert_equal 24 , @comp.method_compilers.length
end
def test_returns_constants
assert_equal Array , @comp.constants.class
end
def test_has_constant
assert_equal "Hi" , @comp.constants.first.to_string
end
def test_has_translate
assert @comp.translate(:interpreter)
end

View File

@ -6,13 +6,22 @@ module Mom
def setup
Parfait.boot!
@comp = compile_mom( "class Test ; def main(); return 1; end; end;")
@comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;")
@linker = @comp.translate(:interpreter)
end
def test_translate_class
assert_equal Risc::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_translate_platform
assert_kind_of Risc::Platform , @linker.platform
end