rubyx/test/risc/test_method_compiler.rb

33 lines
1.1 KiB
Ruby
Raw Normal View History

2017-04-08 11:10:42 +02:00
require_relative "helper"
2018-06-29 21:56:49 +02:00
module Risc
class TestMethodCompiler < MiniTest::Test
include ScopeHelper
2017-04-08 11:10:42 +02:00
def setup
code = in_Test("def meth; @ivar = 5;return ;end")
rubyx = RubyX::RubyXCompiler.new(RubyX.default_test_options)
@compiler = rubyx.ruby_to_slot(code).compilers.to_risc
end
def test_compiles_risc
assert_equal Risc::MethodCompiler , @compiler.class
assert_equal Risc::Label , @compiler.risc_instructions.class
end
def test_compiles_all_risc
assert_equal Risc::LoadConstant , @compiler.risc_instructions.next.class
2020-03-13 14:49:36 +01:00
assert_equal 15 , @compiler.risc_instructions.length
end
def test_translate_cpu
cpu = @compiler.translate_cpu(Platform.for(:arm).translator)
assert_equal Assembler , cpu.class
assert_equal :meth , cpu.callable.name
end
def test_translate_method
ass = @compiler.translate_method(Platform.for(:arm) , [])
assert_equal Array , ass.class
assert_equal Assembler , ass.first.class
assert_equal :meth , ass.first.callable.name
end
2017-04-08 11:10:42 +02:00
end
end