增加复杂的嵌套测试
This commit is contained in:
parent
f2f30b8d7b
commit
4237c7db7a
121
test
121
test
@ -52,7 +52,6 @@ module: MainModule
|
|||||||
end body
|
end body
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|
||||||
function: main
|
function: main
|
||||||
parameter:
|
parameter:
|
||||||
declare args: string
|
declare args: string
|
||||||
@ -74,6 +73,63 @@ module: MainModule
|
|||||||
body:
|
body:
|
||||||
if i % 2 == 0 then
|
if i % 2 == 0 then
|
||||||
BuiltinUtils.print("i is even: " + BuiltinUtils.to_string(i))
|
BuiltinUtils.print("i is even: " + BuiltinUtils.to_string(i))
|
||||||
|
|
||||||
|
if i > 2 then
|
||||||
|
BuiltinUtils.print("i is greater than 2")
|
||||||
|
|
||||||
|
loop:
|
||||||
|
initializer:
|
||||||
|
declare k: int = 0
|
||||||
|
condition:
|
||||||
|
k < 3
|
||||||
|
update:
|
||||||
|
k = k + 1
|
||||||
|
body:
|
||||||
|
BuiltinUtils.print("k = " + BuiltinUtils.to_string(k))
|
||||||
|
|
||||||
|
if k == 2 then
|
||||||
|
BuiltinUtils.print("k is two")
|
||||||
|
|
||||||
|
loop:
|
||||||
|
initializer:
|
||||||
|
declare n: int = 0
|
||||||
|
condition:
|
||||||
|
n < 2
|
||||||
|
update:
|
||||||
|
n = n + 1
|
||||||
|
body:
|
||||||
|
BuiltinUtils.print("n = " + BuiltinUtils.to_string(n))
|
||||||
|
|
||||||
|
if n == 1 then
|
||||||
|
BuiltinUtils.print("n is one")
|
||||||
|
|
||||||
|
if i > 3 then
|
||||||
|
BuiltinUtils.print("deep i > 3 block")
|
||||||
|
|
||||||
|
loop:
|
||||||
|
initializer:
|
||||||
|
declare x: int = 0
|
||||||
|
condition:
|
||||||
|
x < 2
|
||||||
|
update:
|
||||||
|
x = x + 1
|
||||||
|
body:
|
||||||
|
if x == 1 then
|
||||||
|
BuiltinUtils.print("x is one at depth")
|
||||||
|
else
|
||||||
|
BuiltinUtils.print("x is zero at depth")
|
||||||
|
end if
|
||||||
|
end body
|
||||||
|
end loop
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end body
|
||||||
|
end loop
|
||||||
|
end if
|
||||||
|
end body
|
||||||
|
end loop
|
||||||
|
end if
|
||||||
|
|
||||||
else
|
else
|
||||||
BuiltinUtils.print("i is odd: " + BuiltinUtils.to_string(i))
|
BuiltinUtils.print("i is odd: " + BuiltinUtils.to_string(i))
|
||||||
|
|
||||||
@ -86,12 +142,64 @@ module: MainModule
|
|||||||
j = j + 1
|
j = j + 1
|
||||||
body:
|
body:
|
||||||
if j == 1 then
|
if j == 1 then
|
||||||
BuiltinUtils.print(" first inner")
|
BuiltinUtils.print("first inner")
|
||||||
else
|
else
|
||||||
if j % 2 == 0 then
|
if j % 2 == 0 then
|
||||||
BuiltinUtils.print(" j even")
|
BuiltinUtils.print("j even")
|
||||||
|
|
||||||
|
if j > 2 then
|
||||||
|
BuiltinUtils.print("j > 2, deeper if")
|
||||||
|
|
||||||
|
loop:
|
||||||
|
initializer:
|
||||||
|
declare y: int = 0
|
||||||
|
condition:
|
||||||
|
y < 2
|
||||||
|
update:
|
||||||
|
y = y + 1
|
||||||
|
body:
|
||||||
|
BuiltinUtils.print("y in deep even j loop: " + BuiltinUtils.to_string(y))
|
||||||
|
if y == 1 then
|
||||||
|
BuiltinUtils.print("y is one")
|
||||||
|
end if
|
||||||
|
end body
|
||||||
|
end loop
|
||||||
|
end if
|
||||||
|
|
||||||
else
|
else
|
||||||
BuiltinUtils.print(" j odd")
|
BuiltinUtils.print("j odd")
|
||||||
|
|
||||||
|
loop:
|
||||||
|
initializer:
|
||||||
|
declare m: int = 0
|
||||||
|
condition:
|
||||||
|
m < 2
|
||||||
|
update:
|
||||||
|
m = m + 1
|
||||||
|
body:
|
||||||
|
BuiltinUtils.print("m = " + BuiltinUtils.to_string(m))
|
||||||
|
|
||||||
|
if m == 1 then
|
||||||
|
BuiltinUtils.print("m is one")
|
||||||
|
|
||||||
|
if j > 3 then
|
||||||
|
BuiltinUtils.print("j > 3, going deeper")
|
||||||
|
|
||||||
|
loop:
|
||||||
|
initializer:
|
||||||
|
declare z: int = 0
|
||||||
|
condition:
|
||||||
|
z < 2
|
||||||
|
update:
|
||||||
|
z = z + 1
|
||||||
|
body:
|
||||||
|
BuiltinUtils.print("z = " + BuiltinUtils.to_string(z))
|
||||||
|
end body
|
||||||
|
end loop
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end body
|
||||||
|
end loop
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
end body
|
end body
|
||||||
@ -100,7 +208,7 @@ module: MainModule
|
|||||||
|
|
||||||
declare sum: int = CommonTasks.add_numbers(i, 10)
|
declare sum: int = CommonTasks.add_numbers(i, 10)
|
||||||
declare squared: int = MathUtils.square_number(sum)
|
declare squared: int = MathUtils.square_number(sum)
|
||||||
BuiltinUtils.print(" i+10 squared = " + BuiltinUtils.to_string(squared))
|
BuiltinUtils.print("i+10 squared = " + BuiltinUtils.to_string(squared))
|
||||||
end body
|
end body
|
||||||
end loop
|
end loop
|
||||||
|
|
||||||
@ -109,4 +217,7 @@ module: MainModule
|
|||||||
end body
|
end body
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end module
|
end module
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user