diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2011-06-27 18:12:37 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2011-06-27 18:14:23 -0700 |
| commit | 85b5b2a8e46f943a35513bb2bbe8a6d026ed2785 (patch) | |
| tree | fc503bd66d9271612611a72cc24f7f679daddec8 /src/test | |
| parent | 6d1050b1c7c8f5075aaaf6b922ff36f3aceef5e2 (diff) | |
| download | rust-85b5b2a8e46f943a35513bb2bbe8a6d026ed2785.tar.gz rust-85b5b2a8e46f943a35513bb2bbe8a6d026ed2785.zip | |
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.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/do-while-constraints.rs | 17 | ||||
| -rw-r--r-- | src/test/compile-fail/while-loop-constraints.rs | 17 | ||||
| -rw-r--r-- | src/test/run-pass/while-loop-constraints-2.rs | 16 |
3 files changed, 50 insertions, 0 deletions
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 |
