rubyx/test/mom/test_while_simple.rb
Torsten Rüger 4bf23defc8 fix many tests with preloading
preloading, something akin to builtin, loads some very small predefined (macro) methods for the tests to work (ie call)
2019-09-12 22:27:26 +03:00

44 lines
1.4 KiB
Ruby

require_relative "helper"
module Risc
class TestWhileSimple < MiniTest::Test
include Statements
def setup
@input = "while(@true_object) ; arg = 5 end;return"
@expect = [Label, SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, #4
IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant, #9
RegToSlot, Branch, Label, LoadConstant, RegToSlot, #14
Branch] #19
end
def test_while_instructions
assert_nil msg = check_nil , msg
end
def test_false_load
produced = produce_body
assert_equal Parfait::FalseClass , produced.next(3).constant.class
end
def test_false_check
produced = produce_body
assert_equal IsZero , produced.next(5).class
assert_equal Label , produced.next(12).class
assert_equal produced.next(12).name , produced.next(5).label.name
end
def test_nil_load
produced = produce_body
assert_equal Parfait::NilClass , produced.next(6).constant.class
end
def test_merge_label
produced = produce_body
assert produced.next(12).name.start_with?("merge_label")
end
def test_back_jump # should jump back to condition label
produced = produce_body
assert_equal Branch , produced.next(11).class
assert_equal produced.name , produced.next(11).label.name
end
end
end