parent
11b4a92fc8
commit
de40318037
3 changed files with 44 additions and 0 deletions
16
src/test/compile-fail/noncopyable-class.rs
Normal file
16
src/test/compile-fail/noncopyable-class.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// error-pattern: copying a noncopyable value
|
||||
|
||||
// Test that a class with a non-copyable field can't be
|
||||
// copied
|
||||
class bar {
|
||||
new() {}
|
||||
drop {}
|
||||
}
|
||||
|
||||
class foo {
|
||||
let i: int;
|
||||
let j: bar;
|
||||
new(i:int) { self.i = i; self.j = bar(); }
|
||||
}
|
||||
|
||||
fn main() { let x <- foo(10); let y = x; log(error, x); }
|
15
src/test/compile-fail/unsendable-class.rs
Normal file
15
src/test/compile-fail/unsendable-class.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Test that a class with an unsendable field can't be
|
||||
// sent
|
||||
|
||||
class foo {
|
||||
let i: int;
|
||||
let j: @str;
|
||||
new(i:int, j: @str) { self.i = i; self.j = j; }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let cat = "kitty";
|
||||
let po = comm::port(); //! ERROR missing `send`
|
||||
let ch = comm::chan(po); //! ERROR missing `send`
|
||||
comm::send(ch, foo(42, @cat)); //! ERROR missing `send`
|
||||
}
|
13
src/test/run-pass/sendable-class.rs
Normal file
13
src/test/run-pass/sendable-class.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Test that a class with only sendable fields can be sent
|
||||
|
||||
class foo {
|
||||
let i: int;
|
||||
let j: char;
|
||||
new(i:int, j: char) { self.i = i; self.j = j; }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let po = comm::port::<foo>();
|
||||
let ch = comm::chan(po);
|
||||
comm::send(ch, foo(42, 'c'));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue