about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2011-06-28 11:48:54 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2011-06-28 11:49:11 -0700
commit926049edddb6a990f22658205a2f3d467d0e4475 (patch)
treece07d8d619a993b05e5c9c282d584b44d7fe9a86 /src
parent1ca0db5421c0737088112d55475d37bd7f3d0bb4 (diff)
Tests only: more tests with constraints and loops
Diffstat (limited to 'src')
-rw-r--r--src/test/compile-fail/do-while-pred-constraints.rs26
-rw-r--r--src/test/compile-fail/while-loop-pred-constraints.rs27
2 files changed, 53 insertions, 0 deletions
diff --git a/src/test/compile-fail/do-while-pred-constraints.rs b/src/test/compile-fail/do-while-pred-constraints.rs
new file mode 100644
index 00000000000..77b1558efb2
--- /dev/null
+++ b/src/test/compile-fail/do-while-pred-constraints.rs
@@ -0,0 +1,26 @@
+// xfail-stage0
+// error-pattern: Unsatisfied precondition constraint (for example, even(y
+
+fn print_even(int y) : even(y) {
+  log y;
+}
+
+pred even(int y) -> bool {
+  true
+}
+
+fn main() {
+
+  let int y = 42;
+  check even(y);
+  do {
+    print_even(y);
+    do {
+      do {
+	do {
+	  y += 1;
+	} while (true);
+      } while (true);
+    } while (true);
+  } while (true);
+}
\ No newline at end of file
diff --git a/src/test/compile-fail/while-loop-pred-constraints.rs b/src/test/compile-fail/while-loop-pred-constraints.rs
new file mode 100644
index 00000000000..2304de6290b
--- /dev/null
+++ b/src/test/compile-fail/while-loop-pred-constraints.rs
@@ -0,0 +1,27 @@
+// xfail-stage0
+// error-pattern: Unsatisfied precondition constraint (for example, even(y
+
+fn print_even(int y) : even(y) {
+  log y;
+}
+
+pred even(int y) -> bool {
+  true
+}
+
+fn main() {
+
+  let int y = 42;
+  let int x = 1;
+  check even(y);
+  while (true) {
+    print_even(y);
+    while (true) {
+      while (true) {
+	while (true) {
+	  y += x;
+	}
+      }
+    }
+  }
+}
\ No newline at end of file