A few tests for infinite loops
This commit is contained in:
parent
a0a230de83
commit
813c41362b
13
src/test/compile-fail/loop-does-not-diverge.rs
Normal file
13
src/test/compile-fail/loop-does-not-diverge.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// error-pattern:some control paths may return
|
||||
/* Make sure a loop{} with a break in it can't be
|
||||
the tailexpr in the body of a diverging function */
|
||||
fn forever() -> ! {
|
||||
loop {
|
||||
break;
|
||||
}
|
||||
ret 42;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if (1 == 2) { forever(); }
|
||||
}
|
10
src/test/run-pass/loop-diverges.rs
Normal file
10
src/test/run-pass/loop-diverges.rs
Normal file
@ -0,0 +1,10 @@
|
||||
/* Make sure a loop{} can be the tailexpr in the body
|
||||
of a diverging function */
|
||||
|
||||
fn forever() -> ! {
|
||||
loop{}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if (1 == 2) { forever(); }
|
||||
}
|
Loading…
Reference in New Issue
Block a user