Some tests for ! annotations

This commit is contained in:
Tim Chevalier 2011-05-20 19:53:50 -07:00
parent a1b440baaa
commit 7b4eec215c
4 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,12 @@
// -*- rust -*-
// xfail-stage0
// Tests that a function with a ! annotation always actually fails
// error-pattern: some control paths may return
fn bad_bang(uint i) -> ! {
log 3;
}
fn main() {
bad_bang(5u);
}

View File

@ -0,0 +1,12 @@
// -*- rust -*-
// xfail-stage0
// Tests that a function with a ! annotation always actually fails
// error-pattern: some control paths may return
fn bad_bang(uint i) -> ! {
ret 7u;
}
fn main() {
bad_bang(5u);
}

View File

@ -0,0 +1,16 @@
// -*- rust -*-
// xfail-stage0
// Tests that a function with a ! annotation always actually fails
// error-pattern: may return to the caller
fn bad_bang(uint i) -> ! {
if (i < 0u) {
}
else {
fail;
}
}
fn main() {
bad_bang(5u);
}

View File

@ -0,0 +1,18 @@
// -*- rust -*-
fn my_err(str s) -> ! {
log_err s;
fail;
}
fn okay(uint i) -> int {
if (i == 3u) {
my_err("I don't like three");
}
else {
ret 42;
}
}
fn main() {
okay(4u);
}