diff options
| author | bors <bors@rust-lang.org> | 2014-01-09 16:11:18 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-09 16:11:18 -0800 |
| commit | ff3d5d460399070f660f5a59855fbb4698c797ee (patch) | |
| tree | 6ec333e4e6eb9e153e79bc4a325c9a440ea4c2c2 /src/test | |
| parent | d28317d78f09d7658c8928b2ff27c6f2ce60b5a4 (diff) | |
| parent | e12711540a00ded4021250f7b2a31773fc4dc734 (diff) | |
| download | rust-ff3d5d460399070f660f5a59855fbb4698c797ee.tar.gz rust-ff3d5d460399070f660f5a59855fbb4698c797ee.zip | |
auto merge of #11055 : pcwalton/rust/placement-box, r=pcwalton
r? @nikomatsakis
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/new-box-syntax-bad.rs | 14 | ||||
| -rw-r--r-- | src/test/run-pass/new-box-syntax.rs | 22 |
2 files changed, 34 insertions, 2 deletions
diff --git a/src/test/compile-fail/new-box-syntax-bad.rs b/src/test/compile-fail/new-box-syntax-bad.rs new file mode 100644 index 00000000000..942c8621207 --- /dev/null +++ b/src/test/compile-fail/new-box-syntax-bad.rs @@ -0,0 +1,14 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Tests that the new `box` syntax works with unique pointers and GC pointers. + +use std::gc::Gc; +use std::owned::HEAP; + +pub fn main() { + let x: Gc<int> = box(HEAP) 2; //~ ERROR mismatched types + let y: Gc<int> = box(HEAP)(1 + 2); //~ ERROR mismatched types + let z: ~int = box(GC)(4 + 5); //~ ERROR mismatched types +} + diff --git a/src/test/run-pass/new-box-syntax.rs b/src/test/run-pass/new-box-syntax.rs index 2d6e7a4ef0a..d237c4d9a4e 100644 --- a/src/test/run-pass/new-box-syntax.rs +++ b/src/test/run-pass/new-box-syntax.rs @@ -1,8 +1,26 @@ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ +// Tests that the new `box` syntax works with unique pointers and GC pointers. + +use std::gc::Gc; +use std::owned::HEAP; + +struct Structure { + x: int, + y: int, +} + pub fn main() { - let x: ~int = box 3; - println!("{}", *x); + let x: ~int = box(HEAP) 2; + let y: ~int = box 2; + let z: Gc<int> = box(GC) 2; + let a: Gc<Structure> = box(GC) Structure { + x: 10, + y: 20, + }; + let b: ~int = box()(1 + 2); + let c = box()(3 + 4); + let d = box(GC)(5 + 6); } |
