test cases for the new typedesc features
This commit is contained in:
parent
badb6c0f66
commit
c899b51b52
2 changed files with 28 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
discard """
|
||||
msg: "int\nstring\nTBar[int]"
|
||||
output: "int\nstring\nTBar[int]\nint\nrange 0..2"
|
||||
output: "int\nstring\nTBar[int]\nint\nrange 0..2\nstring"
|
||||
"""
|
||||
|
||||
import typetraits
|
||||
|
|
@ -36,3 +36,24 @@ proc foo3[R, T](x: array[R, T]) =
|
|||
echo name(R)
|
||||
|
||||
foo3 arr
|
||||
|
||||
const TypeList = [int, string, seq[int]]
|
||||
|
||||
macro selectType(inType: typedesc): typedesc =
|
||||
var typeSeq = @[float, TBar[int]]
|
||||
|
||||
for t in TypeList:
|
||||
typeSeq.add(t)
|
||||
|
||||
typeSeq.add(inType)
|
||||
typeSeq.add(type(10))
|
||||
|
||||
var typeSeq2: seq[typedesc] = @[]
|
||||
typeSeq2 = typeSeq
|
||||
|
||||
result = typeSeq2[5]
|
||||
|
||||
var xvar: selectType(string)
|
||||
xvar = "proba"
|
||||
echo xvar.type.name
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue