rubyx/test/compiler/statements/test_while.rb
Torsten Ruger 6c7e4c0fe2 stop pinning self and frame
before: r0-message , r1-self , r2-frame , r3-new_message , r4 + tmps
now: r0-message , r1-new_message , r2 + tmps
programs got smaller, less fuss
also fix in return implementation that got the address from the wrong
message
2015-10-18 17:20:19 +03:00

62 lines
1.4 KiB
Ruby

require_relative 'helper'
module Register
class TestWhile < MiniTest::Test
include Statements
def test_while_mini
@string_input = <<HERE
class Object
int main()
while(1)
return 3
end
end
end
HERE
@expect = [[Virtual::MethodEnter],[LoadConstant,IsZeroBranch,LoadConstant,AlwaysBranch],
[],[Virtual::MethodReturn]]
check
end
def test_while_assign
@string_input = <<HERE
class Object
int main()
int n = 5
while(n > 0)
n = n - 1
end
end
end
HERE
@expect = [[Virtual::MethodEnter,LoadConstant,GetSlot,SetSlot],[GetSlot,GetSlot,LoadConstant,OperatorInstruction,
IsZeroBranch,GetSlot,GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,AlwaysBranch],
[],[Virtual::MethodReturn]]
check
end
def test_while_return
@string_input = <<HERE
class Object
int main()
int n = 10
while( n > 5)
n = n + 1
return n
end
end
end
HERE
@expect = [[Virtual::MethodEnter,LoadConstant,GetSlot,SetSlot],
[GetSlot,GetSlot,LoadConstant,OperatorInstruction,IsZeroBranch,GetSlot,
GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,GetSlot,
GetSlot,AlwaysBranch] ,
[],[Virtual::MethodReturn]]
check
end
end
end