diff options
author | Daniil Yarancev <21169548+Yardanico@users.noreply.github.com> | 2018-01-07 21:02:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-07 21:02:00 +0300 |
commit | fb44c522e6173528efa8035ecc459c84887d0167 (patch) | |
tree | a2f5e98606be265981a5f72748896967033e23d7 /tests/macros | |
parent | ccf99fa5ce4fe992fb80dc89271faa51456c3fa5 (diff) | |
parent | e23ea64c41e101d4e1d933f0b015f51cc6c2f7de (diff) | |
download | Nim-fb44c522e6173528efa8035ecc459c84887d0167.tar.gz |
Merge pull request #1 from nim-lang/devel
upstream
Diffstat (limited to 'tests/macros')
-rw-r--r-- | tests/macros/tgettypeinst.nim | 44 | ||||
-rw-r--r-- | tests/macros/tnimnode_for_runtime.nim | 12 |
2 files changed, 37 insertions, 19 deletions
diff --git a/tests/macros/tgettypeinst.nim b/tests/macros/tgettypeinst.nim index 8e1d9bc13..2f1abe193 100644 --- a/tests/macros/tgettypeinst.nim +++ b/tests/macros/tgettypeinst.nim @@ -27,9 +27,10 @@ macro testX(x,inst0: typed; recurse: static[bool]; implX: typed): typed = let inst = x.getTypeInst let instr = inst.symToIdent.treeRepr let inst0r = inst0.symToIdent.treeRepr - #echo instr - #echo inst0r - doAssert(instr == inst0r) + if instr != inst0r: + echo "instr:\n", instr + echo "inst0r:\n", inst0r + doAssert(instr == inst0r) # check that getTypeImpl(x) is correct # if implX is nil then compare to inst0 @@ -41,9 +42,10 @@ macro testX(x,inst0: typed; recurse: static[bool]; implX: typed): typed = else: implX[0][2] let implr = impl.symToIdent.treerepr let impl0r = impl0.symToIdent.treerepr - #echo implr - #echo impl0r - doAssert(implr == impl0r) + if implr != impl0r: + echo "implr:\n", implr + echo "impl0r:\n", impl0r + doAssert(implr == impl0r) result = newStmtList() #template echoString(s: string) = echo s.replace("\n","\n ") @@ -111,6 +113,18 @@ type Generic[T] = seq[int] Concrete = Generic[int] + Generic2[T1, T2] = seq[T1] + Concrete2 = Generic2[int, float] + + Alias1 = float + Alias2 = Concrete + Alias3 = Concrete2 + + Vec[N: static[int],T] = object + arr: array[N,T] + Vec4[T] = Vec[4,T] + + test(bool) test(char) test(int) @@ -144,11 +158,27 @@ test(Tree): left: ref Tree right: ref Tree test(Concrete): - type _ = Generic[int] + type _ = seq[int] test(Generic[int]): type _ = seq[int] test(Generic[float]): type _ = seq[int] +test(Concrete2): + type _ = seq[int] +test(Generic2[int,float]): + type _ = seq[int] +test(Alias1): + type _ = float +test(Alias2): + type _ = seq[int] +test(Alias3): + type _ = seq[int] +test(Vec[4,float32]): + type _ = object + arr: array[0..3,float32] +test(Vec4[float32]): + type _ = object + arr: array[0..3,float32] # bug #4862 static: diff --git a/tests/macros/tnimnode_for_runtime.nim b/tests/macros/tnimnode_for_runtime.nim deleted file mode 100644 index 0520cd0dd..000000000 --- a/tests/macros/tnimnode_for_runtime.nim +++ /dev/null @@ -1,12 +0,0 @@ -discard """ - output: "bla" -""" - -import macros -proc makeMacro: NimNode = - result = nil - -var p = makeMacro() - -echo "bla" - |