Some tests for ! annotations
This commit is contained in:
parent
a1b440baaa
commit
7b4eec215c
12
src/test/compile-fail/bad-bang-ann-2.rs
Normal file
12
src/test/compile-fail/bad-bang-ann-2.rs
Normal 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);
|
||||
}
|
12
src/test/compile-fail/bad-bang-ann-3.rs
Normal file
12
src/test/compile-fail/bad-bang-ann-3.rs
Normal 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);
|
||||
}
|
16
src/test/compile-fail/bad-bang-ann.rs
Normal file
16
src/test/compile-fail/bad-bang-ann.rs
Normal 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);
|
||||
}
|
18
src/test/run-pass/ret-bang.rs
Normal file
18
src/test/run-pass/ret-bang.rs
Normal 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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user