2018-08-06 10:11:12 +03:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestCompilerBuilder < MiniTest::Test
|
2019-09-13 14:07:12 +03:00
|
|
|
include Parfait::MethodHelper
|
2018-08-06 10:11:12 +03:00
|
|
|
def setup
|
2019-02-08 23:03:23 +02:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2019-10-03 20:55:41 +03:00
|
|
|
@method = SlotMachine::SlotCollection.compiler_for( :Space , :main,{},{}).callable
|
|
|
|
@compiler = Risc::MethodCompiler.new( @method , SlotMachine::Label.new( "source_name", "return_label"))
|
2019-09-13 14:07:12 +03:00
|
|
|
@builder = @compiler.builder(@method)
|
2018-08-06 10:11:12 +03:00
|
|
|
end
|
2018-11-24 22:40:22 +02:00
|
|
|
def test_prepare_int
|
2020-03-02 13:48:21 +02:00
|
|
|
assert @builder.prepare_int_return
|
2018-11-24 22:40:22 +02:00
|
|
|
end
|
2018-11-21 11:12:39 +02:00
|
|
|
def test_allocate_returns
|
|
|
|
int = @builder.allocate_int
|
2020-03-01 10:22:24 +02:00
|
|
|
assert_equal :integer_tmp , int.symbol
|
2018-11-21 11:12:39 +02:00
|
|
|
end
|
|
|
|
def test_allocate_len
|
|
|
|
int = @builder.allocate_int
|
2019-08-23 19:25:02 +03:00
|
|
|
assert_equal 23 , @builder.compiler.risc_instructions.length
|
2018-11-21 11:12:39 +02:00
|
|
|
end
|
2018-08-06 10:11:12 +03:00
|
|
|
end
|
|
|
|
end
|