diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-02-19 02:07:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-19 11:07:17 +0100 |
commit | 273a93581f851d2d16d6891d7dd1d7d9edfbb4ef (patch) | |
tree | 1e9e772bb7c839e2469bdd6aed122dca5050d2c8 /tests | |
parent | d1f9f11245a29f00bfa8cd86f9b4eb4ab0963a15 (diff) | |
download | Nim-273a93581f851d2d16d6891d7dd1d7d9edfbb4ef.tar.gz |
fix incorrect lenTuple implementation (#13423)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/metatype/ttypetraits.nim | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/tests/metatype/ttypetraits.nim b/tests/metatype/ttypetraits.nim index 218ffadc2..a6813ed00 100644 --- a/tests/metatype/ttypetraits.nim +++ b/tests/metatype/ttypetraits.nim @@ -92,7 +92,43 @@ block distinctBase: doAssert($distinctBase(typeof(b2)) == "string") doAssert($distinctBase(typeof(c2)) == "int") +block: # lenTuple + doAssert not compiles(lenTuple(int)) + + type + MyTupleType = (int,float,string) + + static: doAssert MyTupleType.lenTuple == 3 + + type + MyGenericTuple[T] = (T,int,float) + MyGenericAlias = MyGenericTuple[string] + static: doAssert MyGenericAlias.lenTuple == 3 + + type + MyGenericTuple2[T,U] = (T,U,string) + MyGenericTuple2Alias[T] = MyGenericTuple2[T,int] + + MyGenericTuple2Alias2 = MyGenericTuple2Alias[float] + static: doAssert MyGenericTuple2Alias2.lenTuple == 3 + + static: doAssert (int, float).lenTuple == 2 + static: doAssert (1, ).lenTuple == 1 + static: doAssert ().lenTuple == 0 + + let x = (1,2,) + doAssert x.lenTuple == 2 + doAssert ().lenTuple == 0 + doAssert (1,).lenTuple == 1 + doAssert (int,).lenTuple == 1 + doAssert type(x).lenTuple == 2 + doAssert type(x).default.lenTuple == 2 + type T1 = (int,float) + type T2 = T1 + doAssert T2.lenTuple == 2 + block genericParams: + type Foo[T1, T2]=object doAssert genericParams(Foo[float, string]) is (float, string) type Foo1 = Foo[float, int] @@ -103,10 +139,6 @@ block genericParams: doAssert genericParams(Foo2).get(1) is Foo1 doAssert (int,).get(0) is int doAssert (int, float).get(1) is float - static: doAssert (int, float).lenTuple == 2 - static: doAssert (1, ).lenTuple == 1 - static: doAssert ().lenTuple == 0 - ############################################## # bug 13095 |