renamed '=' to '=copy' [backport:1.2] (#15585)
* Assign hook name changed to `=copy` * Adapt destructors.rst * [nobackport] Duplicate tests for =copy hook * Fix tests * added a changelog entry Co-authored-by: Clyybber <darkmine956@gmail.com>
This commit is contained in:
parent
42c180c665
commit
da4aa2e1fb
17 changed files with 1001 additions and 29 deletions
41
tests/arc/tcomputedgotocopy.nim
Normal file
41
tests/arc/tcomputedgotocopy.nim
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
discard """
|
||||
cmd: '''nim c --newruntime $file'''
|
||||
output: '''2
|
||||
2'''
|
||||
"""
|
||||
|
||||
type
|
||||
ObjWithDestructor = object
|
||||
a: int
|
||||
proc `=destroy`(self: var ObjWithDestructor) =
|
||||
echo "destroyed"
|
||||
|
||||
proc `=copy`(self: var ObjWithDestructor, other: ObjWithDestructor) =
|
||||
echo "copied"
|
||||
|
||||
proc test(a: range[0..1], arg: ObjWithDestructor) =
|
||||
var iteration = 0
|
||||
while true:
|
||||
{.computedGoto.}
|
||||
|
||||
let
|
||||
b = int(a) * 2
|
||||
c = a
|
||||
d = arg
|
||||
e = arg
|
||||
|
||||
discard c
|
||||
discard d
|
||||
discard e
|
||||
|
||||
inc iteration
|
||||
|
||||
case a
|
||||
of 0:
|
||||
assert false
|
||||
of 1:
|
||||
echo b
|
||||
if iteration == 2:
|
||||
break
|
||||
|
||||
test(1, ObjWithDestructor())
|
||||
Loading…
Add table
Add a link
Reference in a new issue