diff options
author | Zahary Karadjov <zahary@gmail.com> | 2014-01-06 00:15:55 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2014-01-06 00:15:55 +0200 |
commit | 1ffae7cbafd63ed5d8546dcda1a0e5ec883fd00b (patch) | |
tree | c553bf1a94197b95a0fdf54b8cc2885c3b16a128 /tests | |
parent | 789ba107cf3bcc1a87d896fc7cbfa11e151898c2 (diff) | |
download | Nim-1ffae7cbafd63ed5d8546dcda1a0e5ec883fd00b.tar.gz |
progress towards fixing tgenericshardcases
Diffstat (limited to 'tests')
-rw-r--r-- | tests/compile/tgenericshardcases.nim | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/tests/compile/tgenericshardcases.nim b/tests/compile/tgenericshardcases.nim index 90981c701..2ef63bc20 100644 --- a/tests/compile/tgenericshardcases.nim +++ b/tests/compile/tgenericshardcases.nim @@ -1,6 +1,6 @@ discard """ file: "tgenericshardcases.nim" - output: "int\nfloat\nint\nstring" + output: "2\n5\n126\n3" """ import typetraits @@ -13,18 +13,24 @@ macro selectType(a, b: typedesc): typedesc = type Foo[T] = object - data1: array[high(T), int] - data2: array[1..typeNameLen(T), selectType(float, string)] + data1: array[T.high, int] + data2: array[typeNameLen(T), float] # data3: array[0..T.typeNameLen, selectType(float, int)] - MyEnum = enum A, B, C,D + MyEnum = enum A, B, C, D var f1: Foo[MyEnum] var f2: Foo[int8] -static: - assert high(f1.data1) == D - assert high(f1.data2) == 6 # length of MyEnum +echo high(f1.data1) # (D = 3) - 1 == 2 +echo high(f1.data2) # (MyEnum.len = 6) - 1 == 5 - assert high(f2.data1) == 127 - assert high(f2.data2) == 4 # length of int8 +echo high(f2.data1) # 127 - 1 == 126 +echo high(f2.data2) # int8.len - 1 == 3 + +#static: +# assert high(f1.data1) == ord(D) +# assert high(f1.data2) == 6 # length of MyEnum + +# assert high(f2.data1) == 127 +# assert high(f2.data2) == 4 # length of int8 |