Builtin is no more, final conversions done
All preloading where it needs to be (some)tests for the preload split compiler test remembered binary tests (usually just run on travis)
This commit is contained in:
@ -3,10 +3,6 @@ require_relative "../helper"
|
||||
module Elf
|
||||
|
||||
class FullTest < MiniTest::Test
|
||||
DEBUG = false
|
||||
|
||||
def setup
|
||||
end
|
||||
|
||||
def in_space(input)
|
||||
"class Space; #{input} ; end"
|
||||
|
@ -49,8 +49,9 @@ module Mains
|
||||
|
||||
def run_code(input , name )
|
||||
puts "Compiling #{name}.o" if DEBUG
|
||||
code = Vool::Builtin.builtin_code + input
|
||||
|
||||
linker = ::RubyX::RubyXCompiler.new({}).ruby_to_binary( input , :arm )
|
||||
linker = ::RubyX::RubyXCompiler.new({}).ruby_to_binary( code , :arm )
|
||||
writer = Elf::ObjectWriter.new(linker)
|
||||
|
||||
writer.save "mains.o"
|
||||
|
@ -4,18 +4,19 @@ module Mom
|
||||
module Builtin
|
||||
class TestObjectInitRisc < BootTest
|
||||
def setup
|
||||
super
|
||||
@method = get_compiler("Object",:init)
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
get_compiler("Space",:main)
|
||||
@method = MomCollection.create_init_compiler
|
||||
end
|
||||
def test_mom_length
|
||||
assert_equal :__init__ , @method.callable.name
|
||||
assert_equal 7 , @method.mom_instructions.length
|
||||
assert_equal 2 , @method.mom_instructions.length
|
||||
end
|
||||
def test_compile
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 31 , @method.to_risc.risc_instructions.length
|
||||
assert_equal 19 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -99,7 +99,7 @@ module Ruby
|
||||
assert_equal "'string'" , compile_const( "'string'")
|
||||
end
|
||||
def test_sym
|
||||
assert_equal "'symbol'" , compile_const( ":symbol")
|
||||
assert_equal ":symbol" , compile_const( ":symbol")
|
||||
end
|
||||
def test_nil
|
||||
assert_equal "nil" , compile_const( "nil")
|
||||
|
11
test/rubyx/test_compile.rb
Normal file
11
test/rubyx/test_compile.rb
Normal file
@ -0,0 +1,11 @@
|
||||
require_relative "helper"
|
||||
require "rubyx/rubyxc"
|
||||
|
||||
module RubyX
|
||||
class TestRubyXCliCompile < MiniTest::Test
|
||||
|
||||
def test_compile
|
||||
assert_output(/compiling/) {RubyXC.start(["compile" , "--preload","test/mains/source/add__4.rb"])}
|
||||
end
|
||||
end
|
||||
end
|
11
test/rubyx/test_execute.rb
Normal file
11
test/rubyx/test_execute.rb
Normal file
@ -0,0 +1,11 @@
|
||||
require_relative "helper"
|
||||
require "rubyx/rubyxc"
|
||||
|
||||
module RubyX
|
||||
class TestRubyXCliExecute < MiniTest::Test
|
||||
|
||||
def test_execute
|
||||
assert_output(/Running/) {RubyXC.start(["execute" ,"--preload", "test/mains/source/add__4.rb"])}
|
||||
end
|
||||
end
|
||||
end
|
11
test/rubyx/test_interpret.rb
Normal file
11
test/rubyx/test_interpret.rb
Normal file
@ -0,0 +1,11 @@
|
||||
require_relative "helper"
|
||||
require "rubyx/rubyxc"
|
||||
|
||||
module RubyX
|
||||
class TestRubyXCliInterpret < MiniTest::Test
|
||||
|
||||
def test_interpret
|
||||
assert_output(/interpreting/) {RubyXC.start(["interpret" ,"--preload", "test/mains/source/add__4.rb"])}
|
||||
end
|
||||
end
|
||||
end
|
@ -13,21 +13,5 @@ module RubyX
|
||||
def test_file_fail
|
||||
assert_output(nil , /No such file/) {RubyXC.start(["compile" , "hi"])}
|
||||
end
|
||||
def test_file_open
|
||||
assert_output(/compiling/) {RubyXC.start(["compile" , "test/mains/source/add__4.rb"])}
|
||||
#File.delete "add__4.o"
|
||||
end
|
||||
def test_interpret
|
||||
assert_output(/interpreting/) {RubyXC.start(["interpret" , "test/mains/source/add__4.rb"])}
|
||||
end
|
||||
def test_execute
|
||||
assert_output(/Running/) {RubyXC.start(["execute" , "test/mains/source/add__4.rb"])}
|
||||
end
|
||||
def test_stats
|
||||
out, err = capture_io {RubyXC.start(["stats" , "test/mains/source/add__4.rb"])}
|
||||
assert out.include?("Space") , out
|
||||
assert out.include?("Total") , out
|
||||
assert out.include?("Objects=") , out
|
||||
end
|
||||
end
|
||||
end
|
||||
|
14
test/rubyx/test_stats.rb
Normal file
14
test/rubyx/test_stats.rb
Normal file
@ -0,0 +1,14 @@
|
||||
require_relative "helper"
|
||||
require "rubyx/rubyxc"
|
||||
|
||||
module RubyX
|
||||
class TestRubyXCliStats < MiniTest::Test
|
||||
|
||||
def test_stats
|
||||
out, err = capture_io {RubyXC.start(["stats" ,"--preload", "test/mains/source/add__4.rb"])}
|
||||
assert out.include?("Space") , out
|
||||
assert out.include?("Total") , out
|
||||
assert out.include?("Objects=") , out
|
||||
end
|
||||
end
|
||||
end
|
@ -6,7 +6,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@code = Macro.boot_methods({})
|
||||
@code = Builtin.boot_methods({})
|
||||
end
|
||||
def as_ruby
|
||||
@ruby = Ruby::RubyCompiler.compile(@code)
|
||||
|
@ -7,6 +7,9 @@ module Mom
|
||||
@a = arg
|
||||
@b = b
|
||||
end
|
||||
def to_risc(compiler)
|
||||
Risc.label("some" , "thing")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -30,6 +33,10 @@ module Vool
|
||||
assert_equal Vool::IntegerConstant , @ins.b.class
|
||||
assert_equal 1 , @ins.b.value
|
||||
end
|
||||
def test_to_risc
|
||||
comp = @compiler.to_risc
|
||||
assert_equal Risc::MethodCompiler , comp.class
|
||||
assert_equal :main , comp.callable.name
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user