]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/output-slot-variants.rs
fallout: run-pass tests that use box. (many could be ported to `Box::new` instead...
[rust.git] / src / test / run-pass / output-slot-variants.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(dead_assignment)]
12 #![allow(unused_variable)]
13 #![allow(unknown_features)]
14 #![feature(box_syntax)]
15
16 struct A { a: int, b: int }
17 struct Abox { a: Box<int>, b: Box<int> }
18
19 fn ret_int_i() -> int { 10 }
20
21 fn ret_ext_i() -> Box<int> { box 10 }
22
23 fn ret_int_rec() -> A { A {a: 10, b: 10} }
24
25 fn ret_ext_rec() -> Box<A> { box A {a: 10, b: 10} }
26
27 fn ret_ext_mem() -> Abox { Abox {a: box 10, b: box 10} }
28
29 fn ret_ext_ext_mem() -> Box<Abox> { box Abox{a: box 10, b: box 10} }
30
31 pub fn main() {
32     let mut int_i: int;
33     let mut ext_i: Box<int>;
34     let mut int_rec: A;
35     let mut ext_rec: Box<A>;
36     let mut ext_mem: Abox;
37     let mut ext_ext_mem: Box<Abox>;
38     int_i = ret_int_i(); // initializing
39
40     int_i = ret_int_i(); // non-initializing
41
42     int_i = ret_int_i(); // non-initializing
43
44     ext_i = ret_ext_i(); // initializing
45
46     ext_i = ret_ext_i(); // non-initializing
47
48     ext_i = ret_ext_i(); // non-initializing
49
50     int_rec = ret_int_rec(); // initializing
51
52     int_rec = ret_int_rec(); // non-initializing
53
54     int_rec = ret_int_rec(); // non-initializing
55
56     ext_rec = ret_ext_rec(); // initializing
57
58     ext_rec = ret_ext_rec(); // non-initializing
59
60     ext_rec = ret_ext_rec(); // non-initializing
61
62     ext_mem = ret_ext_mem(); // initializing
63
64     ext_mem = ret_ext_mem(); // non-initializing
65
66     ext_mem = ret_ext_mem(); // non-initializing
67
68     ext_ext_mem = ret_ext_ext_mem(); // initializing
69
70     ext_ext_mem = ret_ext_ext_mem(); // non-initializing
71
72     ext_ext_mem = ret_ext_ext_mem(); // non-initializing
73
74 }