Skip to content

Commit 9ec5e90

Browse files
committed
Tests for constraint propagation
1 parent 182c413 commit 9ec5e90

File tree

5 files changed

+70
-0
lines changed

5 files changed

+70
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// error-pattern:Unsatisfied precondition constraint (for example, le(b, d
2+
// xfail-stage0
3+
use std;
4+
import std::str::*;
5+
import std::uint::*;
6+
7+
fn main() {
8+
let uint a = 1u;
9+
let uint b = 4u;
10+
let uint c = 5u;
11+
// make sure that the constraint le(b, a) exists...
12+
check le(b, a);
13+
// ...invalidate it...
14+
b += 1u;
15+
check le(c, a);
16+
// ...and check that it doesn't get set in the poststate of
17+
// the next statement, since it's not true in the
18+
// prestate.
19+
auto d <- a;
20+
log (safe_slice("kitties", b, d));
21+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// xfail-stage0
2+
use std;
3+
import std::str::*;
4+
import std::uint::*;
5+
6+
fn main() {
7+
let uint a = 1u;
8+
let uint b = 4u;
9+
let uint c = 17u;
10+
check le(a, b);
11+
c <- a;
12+
log (safe_slice("kitties", c, b));
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// xfail-stage0
2+
use std;
3+
import std::str::*;
4+
import std::uint::*;
5+
6+
fn main() {
7+
let uint a = 1u;
8+
let uint b = 4u;
9+
check le(a, b);
10+
auto c <- a;
11+
log (safe_slice("kitties", c, b));
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// xfail-stage0
2+
use std;
3+
import std::str::*;
4+
import std::uint::*;
5+
6+
fn main() {
7+
let uint a = 4u;
8+
let uint b = 1u;
9+
check le(b, a);
10+
b <-> a;
11+
log (safe_slice("kitties", a, b));
12+
}

src/test/run-pass/constraint-prop.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// xfail-stage0
2+
use std;
3+
import std::str::*;
4+
import std::uint::*;
5+
6+
fn main() {
7+
let uint a = 1u;
8+
let uint b = 4u;
9+
check le(a, b);
10+
auto c = b;
11+
log (safe_slice("kitties", a, c));
12+
}

0 commit comments

Comments
 (0)