diff --git a/src/test/run-pass/resource-in-struct.rs b/src/test/run-pass/resource-in-struct.rs index f5a0afe94796..8582bdeddfab 100644 --- a/src/test/run-pass/resource-in-struct.rs +++ b/src/test/run-pass/resource-in-struct.rs @@ -1,9 +1,14 @@ -// Ensures that putting resources inside structual types keeps -// working. +// Ensures that class dtors run if the object is inside an enum +// variant type closable = @mut bool; -resource close_res(i: closable) { *i = false; } +class close_res { + let i: closable; + + new(i: closable) { self.i = i; } + drop { *(self.i) = false; } +} enum option { none, some(T), } diff --git a/src/test/run-pass/send-resource.rs b/src/test/run-pass/send-resource.rs index 666f253c9a12..a733f998160c 100644 --- a/src/test/run-pass/send-resource.rs +++ b/src/test/run-pass/send-resource.rs @@ -1,8 +1,10 @@ import task::*; import comm::*; -resource test(_f: int) { - // Do nothing +class test { + let f: int; + new(f: int) { self.f = f; } + drop {} } fn main() { diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs index f84645c1dbf5..8f19fab4413d 100644 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ b/src/test/run-pass/task-killjoin-rsrc.rs @@ -1,21 +1,22 @@ -// xfail-test -// A port of task-killjoin to use a resource to manage +// A port of task-killjoin to use a class with a dtor to manage // the join. use std; import task; fn joinable(f: fn()) -> (task::task, comm::port) { - resource notify(data: (comm::chan, - @mut bool)) { - let (c, v) = data; - #error["notify: task=%d v=%x unwinding=%b b=%b", + class notify { + let ch: comm::chan; let v: @mut bool; + new(ch: comm::chan, v: @mut bool) { self.ch = ch; self.v = v; } + drop { + #error["notify: task=%d v=%x unwinding=%b b=%b", task::get_task(), - ptr::addr_of(*v) as uint, - task::currently_unwinding(), - *v]; - comm::send(c, *v); + ptr::addr_of(*(self.v)) as uint, + task::failing(), + *(self.v)]; + comm::send(self.ch, *(self.v)); + } } fn wrapper(pair: (comm::chan, fn())) { let (c, f) = pair; @@ -23,7 +24,7 @@ fn joinable(f: fn()) -> (task::task, comm::port) { #error["wrapper: task=%d allocated v=%x", task::get_task(), ptr::addr_of(*b) as uint]; - let _r = notify((c, b)); + let _r = notify(c, b); f(); *b = true; } diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index 7fdaa061ee6e..84b6eb896538 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -2,7 +2,11 @@ fn p_foo(pinned: T) { } fn s_foo(shared: T) { } fn u_foo(unique: T) { } -resource r(i: int) { } +class r { + let i: int; + new(i:int) { self.i = i; } + drop {} +} fn main() { p_foo(r(10)); diff --git a/src/test/run-pass/unique-pinned-nocopy-2.rs b/src/test/run-pass/unique-pinned-nocopy-2.rs index ff94532f9c59..1bde7b3e60eb 100644 --- a/src/test/run-pass/unique-pinned-nocopy-2.rs +++ b/src/test/run-pass/unique-pinned-nocopy-2.rs @@ -1,5 +1,7 @@ -resource r(i: @mut int) { - *i = *i + 1; +class r { + let i: @mut int; + new(i: @mut int) { self.i = i; } + drop { *(self.i) = *(self.i) + 1; } } fn main() { diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs index f8e3d93f431d..7e09b5cca99d 100644 --- a/src/test/run-pass/unwind-resource.rs +++ b/src/test/run-pass/unwind-resource.rs @@ -3,12 +3,18 @@ use std; import task; import comm; -resource complainer(c: comm::chan) { - comm::send(c, true); +class complainer { + let c: comm::chan; + new(c: comm::chan) { + #error("Hello!"); + self.c = c; } + drop { #error("About to send!"); + comm::send(self.c, true); + #error("Sent!"); } } fn f(c: comm::chan) { - let c <- complainer(c); + let _c <- complainer(c); fail; } @@ -18,5 +24,6 @@ fn main() { let builder = task::builder(); task::unsupervise(builder); task::run(builder) {|| f(c); } + #error("hiiiiiiiii"); assert comm::recv(p); } \ No newline at end of file diff --git a/src/test/run-pass/unwind-resource2.rs b/src/test/run-pass/unwind-resource2.rs index 6b0e82928f4e..20120cd6ddd7 100644 --- a/src/test/run-pass/unwind-resource2.rs +++ b/src/test/run-pass/unwind-resource2.rs @@ -3,7 +3,10 @@ use std; import task; import comm; -resource complainer(c: @int) { +class complainer { + let c: @int; + new(c: @int) { self.c = c; } + drop {} } fn f() {