From 7daf986aeca81a72be5869a5a41d4fde753eca0f Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 4 Jun 2012 17:04:08 -0700 Subject: [PATCH] Port remaining run-fail tests to use classes instead of resources --- src/test/run-fail/morestack2.rs | 7 +++++-- src/test/run-fail/morestack3.rs | 7 +++++-- src/test/run-fail/morestack4.rs | 6 ++++-- src/test/run-fail/rt-set-exit-status-fail2.rs | 18 +++++++++++------- .../run-fail/too-much-recursion-unwinding.rs | 6 +++++- src/test/run-fail/unwind-box-res.rs | 8 ++++++-- src/test/run-fail/unwind-resource-fail.rs | 6 +++--- src/test/run-fail/unwind-resource-fail2.rs | 6 +++--- src/test/run-fail/unwind-resource-fail3.rs | 8 +++++--- 9 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/test/run-fail/morestack2.rs b/src/test/run-fail/morestack2.rs index 15123a0540d..736d0d81a5d 100644 --- a/src/test/run-fail/morestack2.rs +++ b/src/test/run-fail/morestack2.rs @@ -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); }; } \ No newline at end of file diff --git a/src/test/run-fail/morestack3.rs b/src/test/run-fail/morestack3.rs index 223f9211307..61b0b824d25 100644 --- a/src/test/run-fail/morestack3.rs +++ b/src/test/run-fail/morestack3.rs @@ -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() { diff --git a/src/test/run-fail/morestack4.rs b/src/test/run-fail/morestack4.rs index 8f0ccec560f..63155b50de1 100644 --- a/src/test/run-fail/morestack4.rs +++ b/src/test/run-fail/morestack4.rs @@ -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() { diff --git a/src/test/run-fail/rt-set-exit-status-fail2.rs b/src/test/run-fail/rt-set-exit-status-fail2.rs index 8b685b7c712..680df73d62e 100644 --- a/src/test/run-fail/rt-set-exit-status-fail2.rs +++ b/src/test/run-fail/rt-set-exit-status-fail2.rs @@ -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; } \ No newline at end of file diff --git a/src/test/run-fail/too-much-recursion-unwinding.rs b/src/test/run-fail/too-much-recursion-unwinding.rs index e56361e2f72..b483a5eb10a 100644 --- a/src/test/run-fail/too-much-recursion-unwinding.rs +++ b/src/test/run-fail/too-much-recursion-unwinding.rs @@ -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() { diff --git a/src/test/run-fail/unwind-box-res.rs b/src/test/run-fail/unwind-box-res.rs index e076f891031..8b771dc7651 100644 --- a/src/test/run-fail/unwind-box-res.rs +++ b/src/test/run-fail/unwind-box-res.rs @@ -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 { diff --git a/src/test/run-fail/unwind-resource-fail.rs b/src/test/run-fail/unwind-resource-fail.rs index 4ab8dc95085..9e24c1598c6 100644 --- a/src/test/run-fail/unwind-resource-fail.rs +++ b/src/test/run-fail/unwind-resource-fail.rs @@ -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() { diff --git a/src/test/run-fail/unwind-resource-fail2.rs b/src/test/run-fail/unwind-resource-fail2.rs index 5c90bc6b4ed..a29f83bf49a 100644 --- a/src/test/run-fail/unwind-resource-fail2.rs +++ b/src/test/run-fail/unwind-resource-fail2.rs @@ -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() { diff --git a/src/test/run-fail/unwind-resource-fail3.rs b/src/test/run-fail/unwind-resource-fail3.rs index 834c3ff7821..c7eeec2e548 100644 --- a/src/test/run-fail/unwind-resource-fail3.rs +++ b/src/test/run-fail/unwind-resource-fail3.rs @@ -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() {