diff options
author | Araq <rumpf_a@web.de> | 2012-12-05 22:03:36 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-12-05 22:03:36 +0100 |
commit | 38ab30d153f7ae3b1b2b74329092ffb7ca781ead (patch) | |
tree | d39dc114db80ccdd50534dbf26f9133ef119405a /tests/run | |
parent | 7171ae62cb94bf5e7ed426ec0679e4247c993121 (diff) | |
download | Nim-38ab30d153f7ae3b1b2b74329092ffb7ca781ead.tar.gz |
implemented generic converters
Diffstat (limited to 'tests/run')
-rw-r--r-- | tests/run/tgenericconverter.nim | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/run/tgenericconverter.nim b/tests/run/tgenericconverter.nim new file mode 100644 index 000000000..e1c9f7c4c --- /dev/null +++ b/tests/run/tgenericconverter.nim @@ -0,0 +1,30 @@ +discard """ + output: '''666 +666''' +""" + +# test the new generic converters: + +type + TFoo2[T] = object + x: T + + TFoo[T] = object + data: array[0..100, T] + +converter toFoo[T](a: TFoo2[T]): TFoo[T] = + result.data[0] = a.x + +proc p(a: TFoo[int]) = + echo a.data[0] + +proc q[T](a: TFoo[T]) = + echo a.data[0] + + +var + aa: TFoo2[int] +aa.x = 666 + +p aa +q aa |