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,10 +1,12 @@
import unittest
import unittest, typetraits
type
TFoo[T, U] = object
x: T
y: U
proc getTypeName(t: typedesc): string = t.name
proc foo(T: typedesc[float], a: expr): string =
result = "float " & $(a.len > 5)
@ -21,6 +23,9 @@ template foo(T: typedesc[seq]): expr = "seq"
test "types can be used as proc params":
# XXX: `check` needs to know that TFoo[int, float] is a type and
# cannot be assigned for a local variable for later inspection
check ((string.getTypeName == "string"))
check ((getTypeName(int) == "int"))
check ((foo(TFoo[int, float], 1000) == "TFoo 1000"))
var f = 10.0