]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/method-on-enum.rs
rollup merge of #20350: fhahn/issue-20340-rustdoc-version
[rust.git] / src / test / debuginfo / method-on-enum.rs
1 // Copyright 2013-2014 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 // ignore-tidy-linelength
12 // ignore-android: FIXME(#10381)
13 // min-lldb-version: 310
14
15 // compile-flags:-g
16
17 // === GDB TESTS ===================================================================================
18
19 // gdb-command:run
20
21 // STACK BY REF
22 // gdb-command:print *self
23 // gdb-check:$1 = {{RUST$ENUM$DISR = Variant2, [...]}, {RUST$ENUM$DISR = Variant2, 117901063}}
24 // gdb-command:print arg1
25 // gdb-check:$2 = -1
26 // gdb-command:print arg2
27 // gdb-check:$3 = -2
28 // gdb-command:continue
29
30 // STACK BY VAL
31 // gdb-command:print self
32 // gdb-check:$4 = {{RUST$ENUM$DISR = Variant2, [...]}, {RUST$ENUM$DISR = Variant2, 117901063}}
33 // gdb-command:print arg1
34 // gdb-check:$5 = -3
35 // gdb-command:print arg2
36 // gdb-check:$6 = -4
37 // gdb-command:continue
38
39 // OWNED BY REF
40 // gdb-command:print *self
41 // gdb-check:$7 = {{RUST$ENUM$DISR = Variant1, x = 1799, y = 1799}, {RUST$ENUM$DISR = Variant1, [...]}}
42 // gdb-command:print arg1
43 // gdb-check:$8 = -5
44 // gdb-command:print arg2
45 // gdb-check:$9 = -6
46 // gdb-command:continue
47
48 // OWNED BY VAL
49 // gdb-command:print self
50 // gdb-check:$10 = {{RUST$ENUM$DISR = Variant1, x = 1799, y = 1799}, {RUST$ENUM$DISR = Variant1, [...]}}
51 // gdb-command:print arg1
52 // gdb-check:$11 = -7
53 // gdb-command:print arg2
54 // gdb-check:$12 = -8
55 // gdb-command:continue
56
57 // OWNED MOVED
58 // gdb-command:print *self
59 // gdb-check:$13 = {{RUST$ENUM$DISR = Variant1, x = 1799, y = 1799}, {RUST$ENUM$DISR = Variant1, [...]}}
60 // gdb-command:print arg1
61 // gdb-check:$14 = -9
62 // gdb-command:print arg2
63 // gdb-check:$15 = -10
64 // gdb-command:continue
65
66
67 // === LLDB TESTS ==================================================================================
68
69 // lldb-command:run
70
71 // STACK BY REF
72 // lldb-command:print *self
73 // lldb-check:[...]$0 = Variant2(117901063)
74 // lldb-command:print arg1
75 // lldb-check:[...]$1 = -1
76 // lldb-command:print arg2
77 // lldb-check:[...]$2 = -2
78 // lldb-command:continue
79
80 // STACK BY VAL
81 // lldb-command:print self
82 // lldb-check:[...]$3 = Variant2(117901063)
83 // lldb-command:print arg1
84 // lldb-check:[...]$4 = -3
85 // lldb-command:print arg2
86 // lldb-check:[...]$5 = -4
87 // lldb-command:continue
88
89 // OWNED BY REF
90 // lldb-command:print *self
91 // lldb-check:[...]$6 = Variant1 { x: 1799, y: 1799 }
92 // lldb-command:print arg1
93 // lldb-check:[...]$7 = -5
94 // lldb-command:print arg2
95 // lldb-check:[...]$8 = -6
96 // lldb-command:continue
97
98 // OWNED BY VAL
99 // lldb-command:print self
100 // lldb-check:[...]$9 = Variant1 { x: 1799, y: 1799 }
101 // lldb-command:print arg1
102 // lldb-check:[...]$10 = -7
103 // lldb-command:print arg2
104 // lldb-check:[...]$11 = -8
105 // lldb-command:continue
106
107 // OWNED MOVED
108 // lldb-command:print *self
109 // lldb-check:[...]$12 = Variant1 { x: 1799, y: 1799 }
110 // lldb-command:print arg1
111 // lldb-check:[...]$13 = -9
112 // lldb-command:print arg2
113 // lldb-check:[...]$14 = -10
114 // lldb-command:continue
115
116 #![omit_gdb_pretty_printer_section]
117
118 enum Enum {
119     Variant1 { x: u16, y: u16 },
120     Variant2 (u32)
121 }
122
123 impl Enum {
124
125     fn self_by_ref(&self, arg1: int, arg2: int) -> int {
126         zzz(); // #break
127         arg1 + arg2
128     }
129
130     fn self_by_val(self, arg1: int, arg2: int) -> int {
131         zzz(); // #break
132         arg1 + arg2
133     }
134
135     fn self_owned(self: Box<Enum>, arg1: int, arg2: int) -> int {
136         zzz(); // #break
137         arg1 + arg2
138     }
139 }
140
141 fn main() {
142     let stack = Enum::Variant2(117901063);
143     let _ = stack.self_by_ref(-1, -2);
144     let _ = stack.self_by_val(-3, -4);
145
146     let owned = box Enum::Variant1{ x: 1799, y: 1799 };
147     let _ = owned.self_by_ref(-5, -6);
148     let _ = owned.self_by_val(-7, -8);
149     let _ = owned.self_owned(-9, -10);
150 }
151
152 fn zzz() {()}
153
154 impl Copy for Enum {}
155