summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2014-01-04 12:28:25 +0200
committerZahary Karadjov <zahary@gmail.com>2014-01-04 13:10:52 +0200
commit789ba107cf3bcc1a87d896fc7cbfa11e151898c2 (patch)
treea912096f7e5133f3dd08528d1499d6cd1ecec305 /tests
parent02533c260b16ce7b16a47781d104b46b36544749 (diff)
downloadNim-789ba107cf3bcc1a87d896fc7cbfa11e151898c2.tar.gz
introduce tyFromExpr; fixes #618
Diffstat (limited to 'tests')
-rw-r--r--tests/compile/compilehelpers.nim6
-rw-r--r--tests/compile/tmatrix3.nim41
-rw-r--r--tests/run/tdestructor.nim2
3 files changed, 48 insertions, 1 deletions
diff --git a/tests/compile/compilehelpers.nim b/tests/compile/compilehelpers.nim
new file mode 100644
index 000000000..cb26ca5b5
--- /dev/null
+++ b/tests/compile/compilehelpers.nim
@@ -0,0 +1,6 @@
+template accept(e: expr) =
+  static: assert(compiles(e))
+
+template reject(e: expr) =
+  static: assert(not compiles(e))
+
diff --git a/tests/compile/tmatrix3.nim b/tests/compile/tmatrix3.nim
new file mode 100644
index 000000000..900404524
--- /dev/null
+++ b/tests/compile/tmatrix3.nim
@@ -0,0 +1,41 @@
+discard """
+  output: '''0.0000000000000000e+00
+0.0000000000000000e+00
+0
+0
+0
+'''
+"""
+
+include compilehelpers
+
+type
+  Matrix*[M, N, T] = object 
+    aij*: array[M, array[N, T]]
+  
+  Matrix2*[T] = Matrix[range[0..1], range[0..1], T]
+  
+  Matrix3*[T] = Matrix[range[0..2], range[0..2], T]
+
+proc mn(x: Matrix): Matrix.T = x.aij[0][0]
+
+proc m2(x: Matrix2): Matrix2.T = x.aij[0][0]
+
+proc m3(x: Matrix3): auto = x.aij[0][0]
+
+var 
+  matn: Matrix[range[0..3], range[0..2], int]
+  mat2: Matrix2[int]
+  mat3: Matrix3[float]
+
+echo m3(mat3)
+echo mn(mat3)
+echo m2(mat2)
+echo mn(mat2)
+echo mn(matn)
+
+reject m3(mat2)
+reject m3(matn)
+reject m2(mat3)
+reject m2(matn)
+
diff --git a/tests/run/tdestructor.nim b/tests/run/tdestructor.nim
index 9b90995c7..bb1410d92 100644
--- a/tests/run/tdestructor.nim
+++ b/tests/run/tdestructor.nim
@@ -1,7 +1,7 @@
 discard """
   output: '''----
 myobj constructed
-myobj destructed
+myobj destroyed
 ----
 mygeneric1 constructed
 mygeneric1 destroyed