Skip to content

Commit

Permalink
tests: update the --expandArc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zerbina committed Nov 9, 2024
1 parent 369e4a9 commit 772b7ff
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 120 deletions.
59 changes: 39 additions & 20 deletions tests/arc/topt_cursor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ scope:
L1:
def_cursor _3: (string, int) = x
def _4: string = $(arg _3) -> [Resume]
echo(arg type(array[0..0, string]), arg _4) -> [L2, Resume]
goto [L2, L3]
echo(arg type(array[0..0, string]), arg _4) -> [L2]
=destroy(name _4)
goto [L3]
finally (L2):
=destroy(name _4)
continue {L3}
continue [Resume]
L3:
-- end of expandArc ------------------------
--expandArc: sio
Expand All @@ -29,34 +30,52 @@ scope:
def_cursor filename: string = "debug.txt"
def_cursor _3: string = filename
def f: File = open(arg _3, arg fmRead, arg 8000) -> [Resume]
def _4: uint32
scope:
def res: string = newStringOfCap(arg 80)
scope:
while true:
scope:
def_cursor _6: File = f
def :tmp: bool = readLine(arg _6, name res) -> [L1, L2, Resume]
def_cursor _7: File = f
def :tmp: bool = readLine(arg _7, name res) -> [L1]
scope:
def_cursor _7: bool = :tmp
def _8: bool = not(arg _7)
if _8:
def_cursor _8: bool = :tmp
def _9: bool = not(arg _8)
if _9:
scope:
goto [L4]
goto [L3]
scope:
def_cursor x: string = res
def_cursor _10: string = x
echo(arg type(array[0..0, string]), arg _10) -> [L1, L2, Resume]
L4:
goto [L1, L2, L5]
def_cursor _11: string = x
echo(arg type(array[0..0, string]), arg _11) -> [L1]
L3:
=destroy(name res)
_4 = 0'u32
goto [L4]
finally (L1):
=destroy(name res)
continue {L2}
finally (L2):
scope:
def_cursor _11: File = f
close(arg _11) -> [Leave(L2), Resume]
continue {L5}
L5:
continue [L5]
except (L5):
_4 := 1'u32
L4:
scope:
def_cursor _12: File = f
close(arg _12) -> [L6]
goto [L7]
finally (L6):
def _13: bool = eqI(arg _4, arg 1'u32)
if _13:
nimAbortException(arg true)
continue [Resume]
L7:
case _4
of 0'u32: goto L9
of 1'u32: goto L10
L9:
goto [L11]
L10:
raise -> [Resume]
L11:
-- end of expandArc ------------------------'''
"""
Expand Down
95 changes: 50 additions & 45 deletions tests/arc/topt_no_cursor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ doing shady stuff...
nimout: '''--expandArc: newTarget
scope:
def splat: tuple[dir: string, name: string, ext: string] = splitFile(arg path) -> [L0, Resume]
def splat: tuple[dir: string, name: string, ext: string] = splitFile(arg path) -> [L0]
bind_mut _7: string = splat.0
def _3: string = move _7
wasMoved(name _7)
Expand All @@ -28,7 +28,7 @@ scope:
=destroy(name splat)
goto [L1]
finally (L0):
continue {}
continue [Resume]
L1:
-- end of expandArc ------------------------
--expandArc: delete
Expand Down Expand Up @@ -79,15 +79,17 @@ scope:
=copy(name _5, arg it.1)
def a: (seq[int], seq[int]) = (consume _4, consume _5)
def_cursor _6: (seq[int], seq[int]) = a
def _7: string = $(arg _6) -> [L0, Resume]
echo(arg type(array[0..0, string]), arg _7) -> [L1, L0, Resume]
goto [L1, L0, L2]
def _7: string = $(arg _6) -> [L0]
echo(arg type(array[0..0, string]), arg _7) -> [L1]
=destroy(name _7)
=destroy(name a)
goto [L2]
finally (L1):
=destroy(name _7)
continue {L0}
continue [L0]
finally (L0):
=destroy(name a)
continue {L2}
continue [Resume]
L2:
-- end of expandArc ------------------------
--expandArc: extractConfig
Expand All @@ -114,7 +116,7 @@ scope:
def_cursor _11: int = i
def line: lent string = borrow a[_11]
def_cursor _13: string = line[]
def splitted: seq[string] = split(arg _13, arg " ", arg -1) -> [L3, Resume]
def splitted: seq[string] = split(arg _13, arg " ", arg -1) -> [L3]
scope:
def_cursor _14: string = splitted[0]
def _15: bool = eqStr(arg _14, arg "opt")
Expand All @@ -123,27 +125,29 @@ scope:
def_cursor _18: string = splitted[1]
=copy(name lan_ip, arg _18)
def_cursor _16: string = lan_ip
echo(arg type(array[0..0, string]), arg _16) -> [L4, L3, Resume]
echo(arg type(array[0..0, string]), arg _16) -> [L4]
def_cursor _17: string = splitted[1]
echo(arg type(array[0..0, string]), arg _17) -> [L4, L3, Resume]
goto [L4, L6]
echo(arg type(array[0..0, string]), arg _17) -> [L4]
=destroy(name splitted)
goto [L6]
finally (L4):
=destroy(name splitted)
continue {L3, L6}
continue [L3]
L6:
i = addI(arg i, arg 1) -> [L3, Resume]
i = addI(arg i, arg 1) -> [L3]
L2:
goto [L3, L7]
=destroy(name lan_ip)
goto [L7]
finally (L3):
=destroy(name lan_ip)
continue {L7}
continue [Resume]
L7:
--expandArc: mergeShadowScope
scope:
def shadowScope: Scope
=copy(name shadowScope, arg c[].currentScope)
rawCloseScope(arg c) -> [L0, Resume]
rawCloseScope(arg c) -> [L0]
scope:
def_cursor _4: Scope = shadowScope
def_cursor a: seq[Symbol] = _4[].symbols
Expand All @@ -166,17 +170,18 @@ scope:
def sym: lent Symbol = borrow a[_13]
def _14: Symbol
=copy(name _14, arg sym[])
addInterfaceDecl(arg c, consume _14) -> [L4, L0, Resume]
goto [L4, L5]
addInterfaceDecl(arg c, consume _14) -> [L4]
goto [L5]
finally (L4):
continue {L0, L5}
continue [L0]
L5:
i = addI(arg i, arg 1) -> [L0, Resume]
i = addI(arg i, arg 1) -> [L0]
L3:
goto [L0, L6]
=destroy(name shadowScope)
goto [L6]
finally (L0):
=destroy(name shadowScope)
continue {L6}
continue [Resume]
L6:
-- end of expandArc ------------------------
--expandArc: treturn
Expand All @@ -190,25 +195,25 @@ scope:
if _4:
scope:
result := move x
wasMoved(name x)
goto [L1, L2]
goto [L1]
def_cursor _5: sink string = x
def _6: int = lengthStr(arg _5)
def _7: string = $(arg _6) -> [L1, L3, Resume]
echo(arg type(array[0..0, string]), arg _7) -> [L4, L1, L3, Resume]
goto [L4, L1, L5]
finally (L4):
def _7: string = $(arg _6) -> [L2]
echo(arg type(array[0..0, string]), arg _7) -> [L3]
=destroy(name _7)
=destroy(name x)
goto [L4]
finally (L3):
=destroy(name _7)
continue {L1}
finally (L1):
continue [L2]
finally (L2):
=destroy(name x)
continue {L2, L3, L5}
L5:
goto [L2]
finally (L3):
=destroy(name result)
continue {}
L2:
continue [L5]
L4:
goto [L1]
finally (L5):
continue [Resume]
L1:
-- end of expandArc ------------------------
--expandArc: check
Expand All @@ -231,38 +236,38 @@ scope:
def _9: string = parentDir(arg _8) -> [Resume]
def _10: string
=copy(name _10, arg this[].value)
def _11: tuple[head: string, tail: string] = splitPath(consume _10) -> [L2, Resume]
def _11: tuple[head: string, tail: string] = splitPath(consume _10) -> [L2]
bind_mut _19: string = _11.1
def _12: string = move _19
wasMoved(name _19)
_4 := (consume _9, consume _12)
wasMoved(name _9)
=destroy(name _11)
goto [L2, L3]
goto [L3]
finally (L2):
=destroy(name _9)
continue {L3}
continue [Resume]
L3:
L1:
def par: tuple[dir: string, front: string] = move _4
scope:
def_cursor _13: string = par.0
def _14: bool = dirExists(arg _13) -> [L4, Resume]
def _14: bool = dirExists(arg _13) -> [L4]
if _14:
scope:
def_cursor _15: string = par.0
def_cursor _16: string = par.1
def _17: seq[string] = getSubDirs(arg _15, arg _16) -> [L4, Resume]
def _17: seq[string] = getSubDirs(arg _15, arg _16) -> [L4]
=sink(name this[].matchDirs, arg _17)
goto [L6]
scope:
def _18: seq[string] = @[]
=sink(name this[].matchDirs, arg _18)
L6:
goto [L4, L7]
=destroy(name par)
goto [L7]
finally (L4):
=destroy(name par)
continue {L7}
continue [Resume]
L7:
-- end of expandArc ------------------------'''
Expand Down
16 changes: 9 additions & 7 deletions tests/arc/topt_no_loop_cursor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ scope:
goto [L2]
def y: Object = ()
def_cursor _5: Object = x
use(arg _5) -> [L3, L4, Resume]
use(arg _5) -> [L3]
x = sink y
goto [L3, L5]
destroy y
goto [L4]
finally (L3):
destroy y
continue {L4, L5}
L5:
continue [L5]
L4:
L2:
goto [L4, L6]
finally (L4):
destroy x
goto [L6]
finally (L5):
destroy x
continue {L6}
continue [Resume]
L6:
-- end
Expand Down
16 changes: 8 additions & 8 deletions tests/arc/topt_refcursors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ scope:
=copy(name ri, arg _18[].ri)
def_cursor _19: Node = jt
def_cursor _20: string = _19[].s
echo(arg type(array[0..0, string]), arg _20) -> [L6, L7, Resume]
echo(arg type(array[0..0, string]), arg _20) -> [L6]
=sink(name jt, arg ri)
wasMoved(name ri)
goto [L6, L8]
goto [L7]
finally (L6):
=destroy(name ri)
continue {L7, L8}
L8:
continue [L8]
L7:
L5:
goto [L7, L9]
finally (L7):
=destroy(name jt)
goto [L9]
finally (L8):
=destroy(name jt)
continue {L9}
continue [Resume]
L9:
-- end of expandArc ------------------------'''
Expand Down
Loading

0 comments on commit 772b7ff

Please sign in to comment.