test cases for the new typedesc features

This commit is contained in:
Zahary Karadjov 2012-09-25 02:01:16 +03:00
commit c899b51b52
2 changed files with 28 additions and 2 deletions

View file

@ -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