From 4741e8f9a1d1148d58e129626952219e14ede255 Mon Sep 17 00:00:00 2001
From: Araq <rumpf_a@web.de>
Date: Fri, 1 Apr 2011 15:07:16 +0200
Subject: ugh, maybe broke git

---
 tests/accept/compile/tconstraints.nim    | 15 +++++++++++++++
 tests/accept/compile/tgenericmatcher.nim | 19 +++++++++++++++++++
 tests/accept/compile/tgenericrefs.nim    | 24 ++++++++++++++++++++++++
 3 files changed, 58 insertions(+)
 create mode 100644 tests/accept/compile/tconstraints.nim
 create mode 100644 tests/accept/compile/tgenericmatcher.nim
 create mode 100644 tests/accept/compile/tgenericrefs.nim

(limited to 'tests/accept/compile')

diff --git a/tests/accept/compile/tconstraints.nim b/tests/accept/compile/tconstraints.nim
new file mode 100644
index 000000000..7aef0d645
--- /dev/null
+++ b/tests/accept/compile/tconstraints.nim
@@ -0,0 +1,15 @@
+
+
+proc myGenericProc[T: object|tuple|int|ptr|ref|distinct](x: T): string = 
+  result = $x
+
+type
+  TMyObj = tuple[x, y: int]
+
+var
+  x: TMyObj
+
+assert myGenericProc(232) == "232"
+assert myGenericProc(x) == "(x: 0, y: 0)"
+
+
diff --git a/tests/accept/compile/tgenericmatcher.nim b/tests/accept/compile/tgenericmatcher.nim
new file mode 100644
index 000000000..eaf3da67c
--- /dev/null
+++ b/tests/accept/compile/tgenericmatcher.nim
@@ -0,0 +1,19 @@
+
+type
+  TMatcherKind = enum
+    mkTerminal, mkSequence, mkAlternation, mkRepeat
+  TMatcher[T] = object
+    case kind: TMatcherKind
+    of mkTerminal:
+      value: T
+    of mkSequence, mkAlternation:
+      matchers: seq[TMatcher[T]]
+    of mkRepeat:
+      matcher: PMatcher[T]
+      min, max: int
+  PMatcher[T] = ref TMatcher[T]
+
+var 
+  m: PMatcher[int]
+
+
diff --git a/tests/accept/compile/tgenericrefs.nim b/tests/accept/compile/tgenericrefs.nim
new file mode 100644
index 000000000..b0e77cef5
--- /dev/null
+++ b/tests/accept/compile/tgenericrefs.nim
@@ -0,0 +1,24 @@
+# Compiles:
+
+type 
+  TA[T] = object
+  PA[T] = ref TA[T]
+var a: PA[string]
+
+# Compiles unless you use var a: PA[string]
+type 
+  PA = ref TA
+  TA[T] = object
+
+
+# Cannot instanciate:
+type 
+  TA[T] = object
+    a: PA[T]
+  PA[T] = ref TA[T]
+
+type 
+  PA[T] = ref TA[T]
+  TA[T] = object
+
+
-- 
cgit 1.4.1-2-gfad0