Merge tests into a larger file (part 2 of ∞) (#9335)
* merge controlflow tests * merge distinct tests * merge enum tests * merge fields tests * merge implicit tests * merge iter issues tests
This commit is contained in:
parent
ef820769a4
commit
3c9fcc4c30
40 changed files with 809 additions and 802 deletions
46
tests/implicit/timplicit.nim
Normal file
46
tests/implicit/timplicit.nim
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
discard """
|
||||
output: '''
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
2
|
||||
88
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
for x in [1, 2, 3, 4]:
|
||||
echo x
|
||||
|
||||
|
||||
type
|
||||
TValue* {.pure, final.} = object of RootObj
|
||||
a: int
|
||||
PValue = ref TValue
|
||||
PPValue = ptr PValue
|
||||
|
||||
|
||||
var x: PValue
|
||||
new x
|
||||
var sp: PPValue = addr x
|
||||
|
||||
sp.a = 2
|
||||
if sp.a == 2: echo 2 # with sp[].a the error is gone
|
||||
|
||||
# Test the new auto-deref a little
|
||||
|
||||
{.experimental.}
|
||||
|
||||
proc p(x: var int; y: int) = x += y
|
||||
|
||||
block:
|
||||
var x: ref int
|
||||
new(x)
|
||||
|
||||
x.p(44)
|
||||
|
||||
var indirect = p
|
||||
x.indirect(44)
|
||||
|
||||
echo x[]
|
||||
Loading…
Add table
Add a link
Reference in a new issue