From 85b5b2a8e46f943a35513bb2bbe8a6d026ed2785 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 27 Jun 2011 18:12:37 -0700 Subject: Tests for while loops that may invalidate constraints Wrote some small test cases that use while loops and moves, to make sure the poststate for the loop body gets propagated into the new prestate and deinitialization gets reflected. Along with that, rewrite the code for intersecting states. I still find it dodgy, but I guess I'll continue trying to add more tests. Also, I'll probably feel better about it once I start formalizing the algorithm. --- src/test/compile-fail/do-while-constraints.rs | 17 +++++++++++++++++ src/test/compile-fail/while-loop-constraints.rs | 17 +++++++++++++++++ src/test/run-pass/while-loop-constraints-2.rs | 16 ++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/test/compile-fail/do-while-constraints.rs create mode 100644 src/test/compile-fail/while-loop-constraints.rs create mode 100644 src/test/run-pass/while-loop-constraints-2.rs (limited to 'src/test') diff --git a/src/test/compile-fail/do-while-constraints.rs b/src/test/compile-fail/do-while-constraints.rs new file mode 100644 index 00000000000..c9c557320a0 --- /dev/null +++ b/src/test/compile-fail/do-while-constraints.rs @@ -0,0 +1,17 @@ +// xfail-stage0 +// error-pattern: Unsatisfied precondition constraint (for example, init(y +fn main() { + + let int y = 42; + let int x; + do { + log y; + do { + do { + do { + x <- y; + } while (true); + } while (true); + } while (true); + } while (true); +} \ No newline at end of file diff --git a/src/test/compile-fail/while-loop-constraints.rs b/src/test/compile-fail/while-loop-constraints.rs new file mode 100644 index 00000000000..981a555ff30 --- /dev/null +++ b/src/test/compile-fail/while-loop-constraints.rs @@ -0,0 +1,17 @@ +// xfail-stage0 +// error-pattern: Unsatisfied precondition constraint (for example, init(y +fn main() { + + let int y = 42; + let int x; + while (true) { + log y; + while (true) { + while (true) { + while (true) { + x <- y; + } + } + } + } +} \ No newline at end of file diff --git a/src/test/run-pass/while-loop-constraints-2.rs b/src/test/run-pass/while-loop-constraints-2.rs new file mode 100644 index 00000000000..c1550ad2d08 --- /dev/null +++ b/src/test/run-pass/while-loop-constraints-2.rs @@ -0,0 +1,16 @@ +// xfail-stage0 +fn main() { + + let int y = 42; + let int z = 42; + let int x; + while (z < 50) { + z += 1; + while (false) { + x <- y; + y = z; + } + log y; + } + assert (y == 42 && z == 50); +} \ No newline at end of file -- cgit 1.4.1-3-g733a5