diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/compile/tgeneric.nim | 11 | ||||
-rw-r--r-- | tests/compile/tgeneric2.nim | 11 | ||||
-rw-r--r-- | tests/compile/tgenericprop.nim | 12 |
3 files changed, 34 insertions, 0 deletions
diff --git a/tests/compile/tgeneric.nim b/tests/compile/tgeneric.nim new file mode 100644 index 000000000..8bda15c42 --- /dev/null +++ b/tests/compile/tgeneric.nim @@ -0,0 +1,11 @@ +import tables + +type + TX = TTable[string, int] + +proc foo(models: seq[TTable[string, float]]): seq[float] = + result = @[] + for model in models.items: + result.add model["foobar"] + + diff --git a/tests/compile/tgeneric2.nim b/tests/compile/tgeneric2.nim new file mode 100644 index 000000000..b9b8e5a62 --- /dev/null +++ b/tests/compile/tgeneric2.nim @@ -0,0 +1,11 @@ +import tables + +type + TX = TTable[string, int] + +proc foo(models: seq[TX]): seq[int] = + result = @[] + for model in models.items: + result.add model["foobar"] + + diff --git a/tests/compile/tgenericprop.nim b/tests/compile/tgenericprop.nim new file mode 100644 index 000000000..211fddecf --- /dev/null +++ b/tests/compile/tgenericprop.nim @@ -0,0 +1,12 @@ + +type + TProperty[T] = object of TObject + getProc: proc(property: TProperty[T]): T + setProc: proc(property: TProperty[T], value: T) + value: T + +proc newProperty[T](value: TObject): TProperty[T] = + result.getProc = proc (property: TProperty[T]) = + return property.value + + |