fix the if syntax and branches
This commit is contained in:
@ -8,7 +8,7 @@ class TestIfStatement < MiniTest::Test
|
||||
@string_input = <<HERE
|
||||
class Object
|
||||
int main()
|
||||
if_plus( 10 < 12)
|
||||
if_plus( 10 - 12)
|
||||
return 3
|
||||
else
|
||||
return 4
|
||||
@ -17,18 +17,36 @@ class Object
|
||||
end
|
||||
HERE
|
||||
@expect = [[SaveReturn,LoadConstant,LoadConstant,
|
||||
OperatorInstruction,IsZero] ,
|
||||
OperatorInstruction,IsPlus] ,
|
||||
[LoadConstant,Branch] ,[LoadConstant] ,[] ,
|
||||
[RegisterTransfer,GetSlot,FunctionReturn]]
|
||||
check
|
||||
end
|
||||
|
||||
|
||||
def test_if_small
|
||||
def test_if_small_minus
|
||||
@string_input = <<HERE
|
||||
class Object
|
||||
int main()
|
||||
if_minus( 10 < 12)
|
||||
if_minus( 10 - 12)
|
||||
return 3
|
||||
end
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [[SaveReturn,LoadConstant,LoadConstant,
|
||||
OperatorInstruction,IsMinus] ,
|
||||
[Branch] ,[LoadConstant] ,[] ,
|
||||
[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
|
||||
@ -40,24 +58,5 @@ HERE
|
||||
[RegisterTransfer,GetSlot,FunctionReturn]]
|
||||
check
|
||||
end
|
||||
|
||||
|
||||
def ttest_call_function
|
||||
@string_input = <<HERE
|
||||
class Object
|
||||
int itest(int n)
|
||||
return 4
|
||||
end
|
||||
|
||||
int main()
|
||||
itest(20)
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [ [SaveReturn,GetSlot,SetSlot,LoadConstant,
|
||||
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,
|
||||
GetSlot] ,[RegisterTransfer,GetSlot,FunctionReturn] ]
|
||||
check
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user