summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/js/tcodegendeclproc.nim11
-rw-r--r--tests/js/tcodegendeclvar.nim10
-rw-r--r--tests/macros/tgettypeinst.nim32
3 files changed, 47 insertions, 6 deletions
diff --git a/tests/js/tcodegendeclproc.nim b/tests/js/tcodegendeclproc.nim
new file mode 100644
index 000000000..3acf0bc13
--- /dev/null
+++ b/tests/js/tcodegendeclproc.nim
@@ -0,0 +1,11 @@
+discard """
+  output: '''
+-1
+8
+'''
+  ccodecheck: "'console.log(-1); function fac_' \\d+ '(n_' \\d+ ')'"
+"""
+proc fac(n: int): int {.codegenDecl: "console.log(-1); function $2($3)".} =
+  return n
+
+echo fac(8)
diff --git a/tests/js/tcodegendeclvar.nim b/tests/js/tcodegendeclvar.nim
new file mode 100644
index 000000000..645443ef7
--- /dev/null
+++ b/tests/js/tcodegendeclvar.nim
@@ -0,0 +1,10 @@
+discard """
+  output: '''
+-1
+2
+'''
+  ccodecheck: "'console.log(-1); var v_' \\d+ ' = [2]'"
+"""
+
+var v {.codegenDecl: "console.log(-1); var $2".} = 2
+echo v
diff --git a/tests/macros/tgettypeinst.nim b/tests/macros/tgettypeinst.nim
index 8e1d9bc13..ea98721c4 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,14 @@ type
   Generic[T] = seq[int]
   Concrete = Generic[int]
 
+  Alias1 = float
+  Alias2 = Concrete
+
+  Vec[N: static[int],T] = object
+    arr: array[N,T]
+  Vec4[T] = Vec[4,T]
+
+
 test(bool)
 test(char)
 test(int)
@@ -149,6 +159,16 @@ test(Generic[int]):
   type _ = seq[int]
 test(Generic[float]):
   type _ = seq[int]
+test(Alias1):
+  type _ = float
+test(Alias2):
+  type _ = Generic[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: