move soml tests out, small cleanup
This commit is contained in:
61
stash/soml/statements/test_while.rb
Normal file
61
stash/soml/statements/test_while.rb
Normal file
@@ -0,0 +1,61 @@
|
||||
require_relative 'helper'
|
||||
|
||||
module Register
|
||||
class TestWhile < MiniTest::Test
|
||||
include Statements
|
||||
|
||||
|
||||
def test_while_mini
|
||||
@string_input = <<HERE
|
||||
class Space
|
||||
int main()
|
||||
while_plus(1)
|
||||
return 3
|
||||
end
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, Branch, Label, LoadConstant, SetSlot, Label, LoadConstant ,
|
||||
IsPlus, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
def test_while_assign
|
||||
@string_input = <<HERE
|
||||
class Space
|
||||
int main()
|
||||
int n = 5
|
||||
while_plus(n)
|
||||
n = n - 1
|
||||
end
|
||||
return n
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant, GetSlot, SetSlot, Branch, Label, GetSlot ,
|
||||
GetSlot, LoadConstant, OperatorInstruction, GetSlot, SetSlot, Label, GetSlot ,
|
||||
GetSlot, IsPlus, GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
|
||||
def test_while_return
|
||||
@string_input = <<HERE
|
||||
class Space
|
||||
int main()
|
||||
int n = 10
|
||||
while_plus( n - 5)
|
||||
n = n + 1
|
||||
return n
|
||||
end
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant, GetSlot, SetSlot, Branch, Label, GetSlot ,
|
||||
GetSlot, LoadConstant, OperatorInstruction, GetSlot, SetSlot, GetSlot, GetSlot ,
|
||||
SetSlot, Label, GetSlot, GetSlot, LoadConstant, OperatorInstruction, IsPlus ,
|
||||
Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user