Add a number of unwinding tests

Issue #236
This commit is contained in:
Brian Anderson 2011-09-07 17:01:24 -07:00
parent 4fba02c7e9
commit f99cf2d62f
11 changed files with 130 additions and 0 deletions

View file

@ -0,0 +1,6 @@
// error-pattern:fail
fn main() {
let a = @0;
assert false;
}

View file

@ -0,0 +1,8 @@
// error-pattern:fail
pure fn p(a: @int) -> bool { false }
fn main() {
let a = @0;
check p(a);
}

View file

@ -0,0 +1,10 @@
// error-pattern:fail
fn f(a: @int) {
fail;
}
fn main() {
let g = bind f(@0);
g();
}

View file

@ -0,0 +1,7 @@
// error-pattern:fail
fn main() {
let a: @int = {
fail;
};
}

View file

@ -0,0 +1,12 @@
// error-pattern:fail
iter x() -> int {
fail;
put 0;
}
fn main() {
let a = @0;
for each x in x() {
}
}

View file

@ -0,0 +1,11 @@
// error-pattern:fail
fn main() {
let a = @0;
{
let b = @0;
{
fail;
}
}
}

View file

@ -0,0 +1,16 @@
// error-pattern:fail
fn f() {
let a = @0;
fail;
}
fn g() {
let b = @0;
f();
}
fn main() {
let a = @0;
g();
}

View file

@ -0,0 +1,10 @@
// error-pattern:fail
fn f() {
fail;
}
fn main() {
f();
let a = @0;
}

View file

@ -0,0 +1,13 @@
use std;
import std::task;
fn f() {
task::unsupervise();
let a = @0;
fail;
}
fn main() {
let g = f;
task::spawn(g);
}

View file

@ -0,0 +1,20 @@
use std;
import std::task;
import std::comm;
resource complainer(c: comm::chan<bool>) {
comm::send(c, true);
}
fn f(c: -comm::chan<bool>) {
task::unsupervise();
let c <- complainer(c);
fail;
}
fn main() {
let p = comm::port();
let c = comm::chan(p);
task::spawn(bind f(c));
assert comm::recv(p);
}

View file

@ -0,0 +1,17 @@
use std;
import std::task;
import std::comm;
resource complainer(c: @int) {
}
fn f() {
task::unsupervise();
let c <- complainer(@0);
fail;
}
fn main() {
let g = f;
task::spawn(g);
}