Files
Nim/tests/arc/trepr.nim
Clyybber 813dd1b670 repr_v2 improvements (#14992)
* Support proc in arc repr

* Typo

* Improve repr for strings and chars
2020-07-15 22:04:15 +02:00

71 lines
1.0 KiB
Nim

discard """
cmd: "nim c --gc:arc $file"
nimout: '''(a: true, n: doAssert)
Table[system.string, trepr.MyType](data: @[], counter: 0)
nil
'''
output: '''
nil
2
Obj(member: ref @["hello"])
ref (member: ref @["hello"])
'''
"""
import tables
type
NimSym = distinct NimNode
MyType = tuple
a: bool
n: NimSym
proc myproc(t: MyType) =
echo repr(t)
proc myproc2(t: MyType) =
var x = Table[string, t]()
echo repr(x)
proc myproc3(t: MyType) =
var x: TableRef[string, t]
echo repr(x)
macro dumpSym(a: typed) =
myproc((a: true, n: NimSym(a)))
myproc2((a: true, n: NimSym(a)))
myproc3((a: true, n: NimSym(a)))
dumpSym(doAssert)
# bug 13731
import os
var a: File
echo repr a
# bug 13872
echo repr(2'u16)
# bug 14270
type
Obj = ref object
member: ref seq[string]
var c = Obj(member: new seq[string])
c.member[] = @["hello"]
echo c.repr
var c2 = new tuple[member: ref seq[string]]
c2.member = new seq[string]
c2.member[] = @["hello"]
echo c2.repr
proc p2 =
echo "hey"
discard repr p2