simple unit test and better documentation for the user defined type classes

This commit is contained in:
Zahary Karadjov
2013-11-17 22:50:26 +02:00
parent 4cea15d274
commit a068aaed3c
8 changed files with 113 additions and 57 deletions

View File

@@ -0,0 +1,28 @@
discard """
output: "Sortable\nSortable\nContainer"
"""
import typetraits
type
TObj = object
x: int
Sortable = generic x, y
(x < y) is bool
ObjectContainer = generic C
C.len is ordinal
for v in items(C):
v.type is tuple|object
proc foo(c: ObjectContainer) =
echo "Container"
proc foo(x: Sortable) =
echo "Sortable"
foo 10
foo "test"
foo(@[TObj(x: 10), TObj(x: 20)])