rubyx/test/rubyx/test_rubyx_compiler2.rb
Torsten Rüger b2260d856d And we are green again
After having over 600 failing tests at one point, this does feel good.
Even better, most of the risc/interpreter tests where i didn't change anything came gree without changing the tests. ie we have binary compatibility.
2019-08-14 11:11:26 +03:00

48 lines
1.4 KiB
Ruby

require_relative "helper"
module RubyX
class TestRubyXCompilerRisc < MiniTest::Test
include ScopeHelper
include RubyXHelper
def setup
super
code = "class Space ; def main(arg);return arg;end; end"
@comp = RubyXCompiler.new(load_parfait: true )
@collection = @comp.ruby_to_risc(code)
end
def test_to_risc
assert_equal Risc::RiscCollection , @collection.class
end
def test_linker
assert_equal Risc::Linker , @collection.translate(:interpreter).class
end
def test_method
linker = @collection.translate(:interpreter)
assert_equal :main , linker.assemblers.first.callable.name
end
def test_asm_len
linker = @collection.translate(:interpreter)
assert_equal 22 , linker.assemblers.length
end
end
class TestRubyXCompilerParfait #< MiniTest::Test
include ScopeHelper
include RubyXHelper
def setup
super
code = "class Space ; def self.class_method(); return 1; end;def main(arg);return Space.class_method;end; end"
@comp = RubyXCompiler.ruby_to_risc(code , load_parfait: true)# , platform: :interpreter)
end
def test_load
object = Parfait.object_space.get_class_by_name(:Object)
assert_equal Parfait::Class , object.class
object = object.instance_type
object.methods.each_method {|m| puts m.name}
assert_equal Parfait::Type , object.get_method(:set_type)
end
end
end