Port remaining run-fail tests to use classes instead of resources

This commit is contained in:
Tim Chevalier 2012-06-04 17:04:08 -07:00
parent ebde93861f
commit 7daf986aec
9 changed files with 47 additions and 25 deletions

View File

@ -20,18 +20,21 @@ fn getbig_call_c_and_fail(i: int) {
}
}
resource and_then_get_big_again(_i: ()) {
class and_then_get_big_again {
new() {}
drop {
fn getbig(i: int) {
if i != 0 {
getbig(i - 1);
}
}
getbig(10000);
}
}
fn main() {
task::spawn {||
let r = and_then_get_big_again(());
let r = and_then_get_big_again();
getbig_call_c_and_fail(10000);
};
}

View File

@ -5,7 +5,7 @@
use std;
fn getbig_and_fail(&&i: int) {
let r = and_then_get_big_again(@0);
let _r = and_then_get_big_again();
if i != 0 {
getbig_and_fail(i - 1);
} else {
@ -13,13 +13,16 @@ fn getbig_and_fail(&&i: int) {
}
}
resource and_then_get_big_again(_i: @int) {
class and_then_get_big_again {
new() {}
drop {
fn getbig(i: int) {
if i != 0 {
getbig(i - 1);
}
}
getbig(100);
}
}
fn main() {

View File

@ -5,7 +5,7 @@
use std;
fn getbig_and_fail(&&i: int) {
let r = and_then_get_big_again(@0);
let r = and_then_get_big_again();
if i != 0 {
getbig_and_fail(i - 1);
} else {
@ -13,7 +13,9 @@ fn getbig_and_fail(&&i: int) {
}
}
resource and_then_get_big_again(_i: @int) {
class and_then_get_big_again {
new() {}
drop {}
}
fn main() {

View File

@ -1,15 +1,19 @@
// error-pattern:whatever
class r {
// Setting the exit status after the runtime has already
// failed has no effect and the process exits with the
// runtime's exit code
drop {
os::set_exit_status(50);
}
new() {}
}
fn main() {
log(error, "whatever");
task::spawn {||
resource r(_i: ()) {
// Setting the exit status after the runtime has already
// failed has no effect and the process exits with the
// runtime's exit code
os::set_exit_status(50);
}
let i = r(());
let i = r();
};
fail;
}

View File

@ -9,11 +9,15 @@ fn recurse() {
recurse();
}
resource r(recursed: *mut bool) unsafe {
class r {
let recursed: *mut bool;
new(recursed: *mut bool) unsafe { self.recursed = recursed; }
drop unsafe {
if !*recursed {
*recursed = true;
recurse();
}
}
}
fn main() {

View File

@ -4,8 +4,12 @@ fn failfn() {
fail;
}
resource r(v: *int) unsafe {
let v2: ~int = unsafe::reinterpret_cast(v);
class r {
let v: *int;
new(v: *int) { self.v = v; }
drop unsafe {
let _v2: ~int = unsafe::reinterpret_cast(self.v);
}
}
fn main() unsafe {

View File

@ -1,9 +1,9 @@
// error-pattern:fail
// xfail-test
resource r(i: int) {
// What happens when destructors throw?
fail;
class r {
new(i:int) {}
drop { fail; }
}
fn main() {

View File

@ -1,9 +1,9 @@
// error-pattern:fail
// xfail-test
resource r(i: int) {
// Double-fail!!
fail;
class r {
new(i:int) {}
drop { fail; }
}
fn main() {

View File

@ -1,9 +1,11 @@
// error-pattern:quux
// xfail-test
resource faily_box(_i: @int) {
// What happens to the box pointer owned by this resource?
fail "quux";
class faily_box {
let i: @int;
new(i: @int) { self.i = i; }
// What happens to the box pointer owned by this class?
drop { fail "quux"; }
}
fn main() {