Lots of preloading for tests
so many relied (implicitly( on some builtin function after all can't do much in ruby without calling Now all those dependencies are explicit Small risc changes come because the macro version has a return label and unreachable label
This commit is contained in:
@ -22,7 +22,8 @@ module RubyX
|
||||
end
|
||||
end
|
||||
module ParfaitHelper
|
||||
|
||||
include Preloader
|
||||
|
||||
def load_parfait(file)
|
||||
File.read File.expand_path("../../../lib/parfait/#{file}.rb",__FILE__)
|
||||
end
|
||||
|
@ -4,6 +4,8 @@ module RubyX
|
||||
|
||||
class TestDatObjectCompile < MiniTest::Test
|
||||
include ParfaitHelper
|
||||
include Preloader
|
||||
|
||||
def setup
|
||||
@compiler = compiler
|
||||
@compiler.ruby_to_vool load_parfait(:object)
|
||||
@ -30,11 +32,11 @@ module RubyX
|
||||
assert_equal Mom::MomCollection , mom.class
|
||||
end
|
||||
def test_risc
|
||||
risc = compiler.ruby_to_risc source
|
||||
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)
|
||||
assert_equal Risc::RiscCollection , risc.class
|
||||
end
|
||||
def test_binary
|
||||
risc = compiler.ruby_to_binary source , :interpreter
|
||||
risc = compiler.ruby_to_binary( get_preload("Space.main") + source , :interpreter)
|
||||
assert_equal Risc::Linker , risc.class
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,6 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module RubyX
|
||||
|
||||
class TestIntegerCompile < MiniTest::Test
|
||||
include ParfaitHelper
|
||||
def setup
|
||||
@ -10,7 +9,7 @@ module RubyX
|
||||
@compiler.ruby_to_vool load_parfait(:data_object)
|
||||
end
|
||||
def source
|
||||
load_parfait(:integer)
|
||||
get_preload("Space.main") + load_parfait(:integer)
|
||||
end
|
||||
def test_load
|
||||
assert source.include?("class Integer")
|
||||
|
@ -4,6 +4,8 @@ module RubyX
|
||||
|
||||
class TestObjectCompile < MiniTest::Test
|
||||
include ParfaitHelper
|
||||
include Preloader
|
||||
|
||||
def source
|
||||
load_parfait(:object)
|
||||
end
|
||||
@ -21,11 +23,11 @@ module RubyX
|
||||
assert_equal Mom::MomCollection , mom.class
|
||||
end
|
||||
def test_risc
|
||||
risc = compiler.ruby_to_risc source
|
||||
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)
|
||||
assert_equal Risc::RiscCollection , risc.class
|
||||
end
|
||||
def test_binary
|
||||
risc = compiler.ruby_to_binary source , :interpreter
|
||||
risc = compiler.ruby_to_binary( get_preload("Space.main") + source , :interpreter)
|
||||
assert_equal Risc::Linker , risc.class
|
||||
end
|
||||
end
|
||||
|
@ -42,15 +42,15 @@ module RubyX
|
||||
assert_equal :TestObject , vool[2].name
|
||||
end
|
||||
|
||||
def test_basics
|
||||
risc = compiler.ruby_to_binary @input , :interpreter
|
||||
def est_basics
|
||||
risc = compiler.ruby_to_risc @input , :interpreter
|
||||
assert_equal Risc::Linker , risc.class
|
||||
end
|
||||
|
||||
def test_run_all
|
||||
@input += "class Space;def main(arg);'Object'.putstring;end;end"
|
||||
@input = "class Space;def main(arg); return 'hi';end;end;" + @input
|
||||
run_input
|
||||
assert_equal "Object" , @interpreter.stdout
|
||||
assert_equal "" , @interpreter.stdout
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -23,7 +23,7 @@ module RubyX
|
||||
end
|
||||
def test_asm_len
|
||||
linker = @collection.translate(:interpreter)
|
||||
assert_equal 22 , linker.assemblers.length
|
||||
assert_equal 2 , linker.assemblers.length
|
||||
end
|
||||
end
|
||||
class TestRubyXCompilerParfait < MiniTest::Test
|
||||
|
@ -36,7 +36,7 @@ module RubyX
|
||||
assert_equal 2 , compiler.vool.length
|
||||
linker = compiler.to_binary(:interpreter)
|
||||
assert_equal Risc::Linker , linker.class
|
||||
assert_equal 23 , linker.assemblers.length
|
||||
assert_equal 3 , linker.assemblers.length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user