rubyx/test/risc/test_builder1.rb

36 lines
1.0 KiB
Ruby
Raw Normal View History

require_relative "../helper"
module Risc
class TestCompilerBuilder < MiniTest::Test
include Parfait::MethodHelper
include HasCompiler
def setup
2019-02-08 22:03:23 +01:00
Parfait.boot!(Parfait.default_test_options)
@method = SlotMachine::SlotCollection.compiler_for( :Space , :main,{},{}).callable
@compiler = Risc::MethodCompiler.new( @method , SlotMachine::Label.new( "source_name", "return_label"))
@builder = @compiler.builder(@method)
end
def test_prepare_int
assert @builder.prepare_int_return
end
def test_allocate_returns
int = @builder.allocate_int
2020-03-02 19:38:36 +01:00
assert int.symbol.to_s.split(".").first.start_with?("id_")
end
def test_allocate_len
int = @builder.allocate_int
assert_equal 22 , @builder.compiler.risc_instructions.length
end
def test_allocate
int = @builder.allocate_int
assert_allocate
end
def test_compiler
int = @builder.allocate_int
assert int.compiler
assert int.symbol.to_s.start_with?("id_fac")
end
end
end