rubyx/test/risc/test_builder.rb

45 lines
1.2 KiB
Ruby
Raw Normal View History

require_relative "../helper"
module Risc
class TestCodeBuilder < MiniTest::Test
def setup
2019-02-08 22:03:23 +01:00
Parfait.boot!(Parfait.default_test_options)
Risc.boot!
label = SlotMachine::Label.new( "source_name", "return_label")
@builder = Risc::MethodCompiler.new( FakeCallable.new ,label).builder("source")
@label = Risc.label("source","name")
@start = @builder.compiler.current
end
def built
@start.next
end
def test_has_build
assert @builder.respond_to?(:build)
end
def test_has_attribute
assert_nil @builder.built
end
def test_message
reg = @builder.message
assert_equal :message , reg.symbol
assert_equal :Message , reg.type.class_name
end
2018-04-07 23:50:51 +02:00
def test_if_zero
ret = @builder.if_zero @label
assert_equal IsZero , ret.class
assert_equal @label , ret.label
end
def test_if_not_zero
ret = @builder.if_not_zero @label
assert_equal IsNotZero , ret.class
assert_equal @label , ret.label
end
def test_branch
ret = @builder.branch @label
assert_equal Branch , ret.class
assert_equal @label , ret.label
end
end
end