diff options
| author | Tim Chevalier <[email protected]> | 2011-05-04 11:32:06 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-05-05 11:26:07 -0700 |
| commit | acf9bd7909a4f6a68d974cabff96c4b72791c201 (patch) | |
| tree | 6b1e5761e7dcdb8625941cf7d02387a554f534ed /src/test | |
| parent | Bring back "pred" syntax for writing predicates for check (diff) | |
| download | rust-acf9bd7909a4f6a68d974cabff96c4b72791c201.tar.xz rust-acf9bd7909a4f6a68d974cabff96c4b72791c201.zip | |
Test cases for pred / check stuff
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/impure-pred.rs | 17 | ||||
| -rw-r--r-- | src/test/compile-fail/not-a-pred-2.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/not-a-pred-3.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/not-a-pred-check.rs | 12 | ||||
| -rw-r--r-- | src/test/compile-fail/not-pred-args.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/pred-not-bool.rs | 13 | ||||
| -rw-r--r-- | src/test/run-pass/pred-check.rs | 11 | ||||
| -rw-r--r-- | src/test/run-pass/pred.rs | 4 |
8 files changed, 57 insertions, 3 deletions
diff --git a/src/test/compile-fail/impure-pred.rs b/src/test/compile-fail/impure-pred.rs new file mode 100644 index 00000000..b5ebc10e --- /dev/null +++ b/src/test/compile-fail/impure-pred.rs @@ -0,0 +1,17 @@ +// -*- rust -*- +// xfail-boot +// xfail-stage0 +// error-pattern: impure function + +fn g() -> () {} + +pred f(int q) -> bool { + g(); + ret true; +} + +fn main() { + auto x = 0; + + check f(x); +} diff --git a/src/test/compile-fail/not-a-pred-2.rs b/src/test/compile-fail/not-a-pred-2.rs index c8ac4a08..07ea13b3 100644 --- a/src/test/compile-fail/not-a-pred-2.rs +++ b/src/test/compile-fail/not-a-pred-2.rs @@ -1,5 +1,6 @@ // -*- rust -*- // xfail-boot +// xfail-stage0 // error-pattern: non-predicate diff --git a/src/test/compile-fail/not-a-pred-3.rs b/src/test/compile-fail/not-a-pred-3.rs index ea1b6cc0..f4dafd20 100644 --- a/src/test/compile-fail/not-a-pred-3.rs +++ b/src/test/compile-fail/not-a-pred-3.rs @@ -1,5 +1,6 @@ // -*- rust -*- // xfail-boot +// xfail-stage0 // error-pattern: expected the constraint name diff --git a/src/test/compile-fail/not-a-pred-check.rs b/src/test/compile-fail/not-a-pred-check.rs new file mode 100644 index 00000000..55698ad2 --- /dev/null +++ b/src/test/compile-fail/not-a-pred-check.rs @@ -0,0 +1,12 @@ +// -*- rust -*- +// xfail-boot +// xfail-stage0 +// error-pattern: non-predicate + +fn f(int q) -> bool { ret true; } + +fn main() { + auto x = 0; + + check f(x); +} diff --git a/src/test/compile-fail/not-pred-args.rs b/src/test/compile-fail/not-pred-args.rs index c92b4ff9..7fe6220a 100644 --- a/src/test/compile-fail/not-pred-args.rs +++ b/src/test/compile-fail/not-pred-args.rs @@ -1,5 +1,6 @@ // -*- rust -*- // xfail-boot +// xfail-stage0 // error-pattern: Constraint args must be diff --git a/src/test/compile-fail/pred-not-bool.rs b/src/test/compile-fail/pred-not-bool.rs new file mode 100644 index 00000000..c0d19ef2 --- /dev/null +++ b/src/test/compile-fail/pred-not-bool.rs @@ -0,0 +1,13 @@ +// -*- rust -*- + +// error-pattern: mismatched types + +// this checks that a pred with a non-bool return +// type is rejected, even if the pred is never used + +pred bad(int a) -> int { + ret 37; +} + +fn main() { +} diff --git a/src/test/run-pass/pred-check.rs b/src/test/run-pass/pred-check.rs new file mode 100644 index 00000000..e0997564 --- /dev/null +++ b/src/test/run-pass/pred-check.rs @@ -0,0 +1,11 @@ +// -*- rust -*- +// xfail-boot +// xfail-stage0 + +pred f(int q) -> bool { ret true; } + +fn main() { + auto x = 0; + + check f(x); +} diff --git a/src/test/run-pass/pred.rs b/src/test/run-pass/pred.rs index 022e1fc4..b4d003a8 100644 --- a/src/test/run-pass/pred.rs +++ b/src/test/run-pass/pred.rs @@ -1,12 +1,10 @@ // xfail-stage0 -// xfail-stage1 -// xfail-stage2 // -*- rust -*- fn f(int a, int b) : lt(a,b) { } -fn lt(int a, int b) -> bool { +pred lt(int a, int b) -> bool { ret a < b; } |