Skip to content

Commit

Permalink
Add some tests for new kind system
Browse files Browse the repository at this point in the history
Issue #1177
  • Loading branch information
marijnh committed Nov 18, 2011
1 parent 196b2b9 commit a7573af
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 73 deletions.
20 changes: 0 additions & 20 deletions src/test/compile-fail/copy-res-into-tag.rs

This file was deleted.

18 changes: 0 additions & 18 deletions src/test/compile-fail/resource-vec-copy.rs

This file was deleted.

18 changes: 0 additions & 18 deletions src/test/compile-fail/unique-pinned-nocopy-3.rs

This file was deleted.

13 changes: 11 additions & 2 deletions src/test/run-pass/init-res-into-things.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Resources can't be copied into other types but still need to be able
// to find their way into things.
// Resources can't be copied, but storing into data structures counts
// as a move unless the stored thing is used afterwards.

This comment has been minimized.

Copy link
@brson

brson Nov 18, 2011

Contributor

This rule is very subtle.


resource r(i: @mutable int) {
*i = *i + 1;
Expand Down Expand Up @@ -59,6 +59,14 @@ fn test_box_rec() {
assert *i == 1;
}

fn test_obj() {
obj o(_f: r) {}
let i = @mutable 0;
let rr = r(i);
{ let _oo = o(rr); }
assert *i == 1;
}

fn main() {
test_box();
test_rec();
Expand All @@ -67,4 +75,5 @@ fn main() {
test_tup();
test_unique();
test_box_rec();
test_obj();
}
16 changes: 11 additions & 5 deletions src/test/run-pass/resource-assign-is-not-copy.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
resource r(i: int) {
}
resource r(i: @mutable int) { *i += 1; }

fn main() {
// Even though this looks like a copy, it's guaranteed not to be
let a = r(0);
}
let i = @mutable 0;
// Even though these look like copies, they are guaranteed not to be
{
let a = r(i);
let b = (a, 10);
let (c, _d) = b;
log c;
}
assert *i == 1;
}
18 changes: 8 additions & 10 deletions src/test/run-pass/type-param-constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@ fn u_foo<send T>(unique: T) { }
resource r(i: int) { }

fn main() {
// FIXME: passing resources doesn't work?
//p_foo(r(10));
//p_foo(@r(10));
// FIXME: unique boxes not yet supported.
// p_foo(~r(10));
p_foo(r(10));
p_foo(@r(10));

p_foo(~r(10));
p_foo(@10);
// p_foo(~10);
p_foo(~10);
p_foo(10);

//s_foo(@r(10));
//s_foo(~r(10));
s_foo(@r(10));
s_foo(@10);
//s_foo(~10);
s_foo(~10);
s_foo(10);

//u_foo(~10);
u_foo(~10);
u_foo(10);
}

0 comments on commit a7573af

Please sign in to comment.