rubyx/test/compiler/statements/test_if.rb
Torsten Ruger 57f37ec023 removed blocks and moved to labels
somewhat easier to understand the code as a linked list
relatively painless change, considering
2015-10-23 21:27:36 +03:00

60 lines
1.2 KiB
Ruby

require_relative 'helper'
module Register
class TestIfStatement < MiniTest::Test
include Statements
def test_if_basic
@string_input = <<HERE
class Object
int main()
if_plus( 10 - 12)
return 3
else
return 4
end
end
end
HERE
@expect = [Label, SaveReturn,LoadConstant,LoadConstant, OperatorInstruction,IsPlus ,
LoadConstant,Branch , Label , LoadConstant ,
Label,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
def test_if_small_minus
@string_input = <<HERE
class Object
int main()
if_minus( 10 - 12)
return 3
end
end
end
HERE
@expect = [Label, SaveReturn,LoadConstant,LoadConstant, OperatorInstruction,IsMinus ,
Branch ,Label , LoadConstant ,
Label,Label , RegisterTransfer,GetSlot,FunctionReturn]
check
end
def test_if_small_zero
@string_input = <<HERE
class Object
int main()
if_zero( 10 - 12)
return 3
end
end
end
HERE
@expect = [Label, SaveReturn,LoadConstant,LoadConstant,OperatorInstruction,IsZero ,
Branch , Label , LoadConstant ,
Label,Label, RegisterTransfer,GetSlot,FunctionReturn]
check
end
end
end