diff options
| author | Graydon Hoare <[email protected]> | 2010-06-23 21:03:09 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-06-23 21:03:09 -0700 |
| commit | d6b7c96c3eb29b9244ece0c046d3f372ff432d04 (patch) | |
| tree | b425187e232966063ffc2f0d14c04a55d8f004ef /src/test/run-fail | |
| parent | Initial git commit. (diff) | |
| download | rust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.tar.xz rust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.zip | |
Populate tree.
Diffstat (limited to 'src/test/run-fail')
| -rw-r--r-- | src/test/run-fail/explicit-fail.rs | 5 | ||||
| -rw-r--r-- | src/test/run-fail/fail.rs | 5 | ||||
| -rw-r--r-- | src/test/run-fail/linked-failure.rs | 14 | ||||
| -rw-r--r-- | src/test/run-fail/pred.rs | 17 | ||||
| -rw-r--r-- | src/test/run-fail/str-overrun.rs | 16 | ||||
| -rw-r--r-- | src/test/run-fail/vec-overrun.rs | 11 | ||||
| -rw-r--r-- | src/test/run-fail/vec-underrun.rs | 11 |
7 files changed, 79 insertions, 0 deletions
diff --git a/src/test/run-fail/explicit-fail.rs b/src/test/run-fail/explicit-fail.rs new file mode 100644 index 00000000..cb0e37e5 --- /dev/null +++ b/src/test/run-fail/explicit-fail.rs @@ -0,0 +1,5 @@ +// error-pattern:explicit + +fn main() { + fail; +} diff --git a/src/test/run-fail/fail.rs b/src/test/run-fail/fail.rs new file mode 100644 index 00000000..8808b8c8 --- /dev/null +++ b/src/test/run-fail/fail.rs @@ -0,0 +1,5 @@ +// error-pattern:1 == 2 + +fn main() { + check (1 == 2); +} diff --git a/src/test/run-fail/linked-failure.rs b/src/test/run-fail/linked-failure.rs new file mode 100644 index 00000000..419fa0f3 --- /dev/null +++ b/src/test/run-fail/linked-failure.rs @@ -0,0 +1,14 @@ +// -*- rust -*- + +// error-pattern:1 == 2 + +fn child() { + check (1 == 2); +} + +io fn main() { + let port[int] p = port(); + spawn child(); + let int x; + x <- p; +} diff --git a/src/test/run-fail/pred.rs b/src/test/run-fail/pred.rs new file mode 100644 index 00000000..e5456a5e --- /dev/null +++ b/src/test/run-fail/pred.rs @@ -0,0 +1,17 @@ +// -*- rust -*- + +// error-pattern:predicate check + +fn f(int a, int b) : lt(a,b) { +} + +fn lt(int a, int b) -> bool { + ret a < b; +} + +fn main() { + let int a = 10; + let int b = 23; + check lt(b,a); + f(b,a); +} diff --git a/src/test/run-fail/str-overrun.rs b/src/test/run-fail/str-overrun.rs new file mode 100644 index 00000000..7d5a12cb --- /dev/null +++ b/src/test/run-fail/str-overrun.rs @@ -0,0 +1,16 @@ +// -*- rust -*- + +// error-pattern:bounds check + +fn main() { + let str s = "hello"; + let int x = 0; + check (s.(x) == u8(0x68)); + + // NB: at the moment a string always has a trailing NULL, + // so the largest index value on the string above is 5, not + // 4. Possibly change this. + + // Bounds-check failure. + check (s.(x + 6) == u8(0x0)); +} diff --git a/src/test/run-fail/vec-overrun.rs b/src/test/run-fail/vec-overrun.rs new file mode 100644 index 00000000..e646a107 --- /dev/null +++ b/src/test/run-fail/vec-overrun.rs @@ -0,0 +1,11 @@ +// -*- rust -*- + +// error-pattern:bounds check + +fn main() { + let vec[int] v = vec(10); + let int x = 0; + check (v.(x) == 10); + // Bounds-check failure. + check (v.(x + 2) == 20); +} diff --git a/src/test/run-fail/vec-underrun.rs b/src/test/run-fail/vec-underrun.rs new file mode 100644 index 00000000..c9073030 --- /dev/null +++ b/src/test/run-fail/vec-underrun.rs @@ -0,0 +1,11 @@ +// -*- rust -*- + +// error-pattern:bounds check + +fn main() { + let vec[int] v = vec(10, 20); + let int x = 0; + check (v.(x) == 10); + // Bounds-check failure. + check (v.(x-1) == 20); +} |