blob: 0f05eea62821318510363eb4f2580b5ff326f38b [file] [log] [blame]
Michael Woerister55a8bd52014-04-24 09:35:481// 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-android: FIXME(#10381)
12
13// compile-flags:-g
Michael Woeristerc7f45a92014-07-09 12:46:0914
15// === GDB TESTS ===================================================================================
16
Michael Woerister55a8bd52014-04-24 09:35:4817// gdb-command:rbreak zzz
18// gdb-command:run
19
20// STACK BY REF
21// gdb-command:finish
22// gdb-command:print *self
23// gdb-check:$1 = {x = {8888, -8888}}
24// gdb-command:print arg1
25// gdb-check:$2 = -1
Michael Woeristerc7f45a92014-07-09 12:46:0926// gdb-command:print arg2
27// gdb-check:$3 = 2
Michael Woerister55a8bd52014-04-24 09:35:4828// gdb-command:continue
29
30// STACK BY VAL
31// gdb-command:finish
32// gdb-command:print self
33// gdb-check:$4 = {x = {8888, -8888}}
34// gdb-command:print arg1
35// gdb-check:$5 = -3
36// gdb-command:print arg2
37// gdb-check:$6 = -4
38// gdb-command:continue
39
40// OWNED BY REF
41// gdb-command:finish
42// gdb-command:print *self
43// gdb-check:$7 = {x = 1234.5}
44// gdb-command:print arg1
45// gdb-check:$8 = -5
46// gdb-command:print arg2
47// gdb-check:$9 = -6
48// gdb-command:continue
49
50// OWNED BY VAL
51// gdb-command:finish
52// gdb-command:print self
53// gdb-check:$10 = {x = 1234.5}
54// gdb-command:print arg1
55// gdb-check:$11 = -7
56// gdb-command:print arg2
57// gdb-check:$12 = -8
58// gdb-command:continue
59
60// OWNED MOVED
61// gdb-command:finish
62// gdb-command:print *self
63// gdb-check:$13 = {x = 1234.5}
64// gdb-command:print arg1
65// gdb-check:$14 = -9
66// gdb-command:print arg2
67// gdb-check:$15 = -10.5
68// gdb-command:continue
69
Michael Woeristerc7f45a92014-07-09 12:46:0970
71// === LLDB TESTS ==================================================================================
72
73// lldb-command:run
74
75// STACK BY REF
76// lldb-command:print *self
77// lldb-check:[...]$0 = Struct<(u32, i32)> { x: (8888, -8888) }
78// lldb-command:print arg1
79// lldb-check:[...]$1 = -1
80// lldb-command:print arg2
81// lldb-check:[...]$2 = 2
82// lldb-command:continue
83
84// STACK BY VAL
85// lldb-command:print self
86// lldb-check:[...]$3 = Struct<(u32, i32)> { x: (8888, -8888) }
87// lldb-command:print arg1
88// lldb-check:[...]$4 = -3
89// lldb-command:print arg2
90// lldb-check:[...]$5 = -4
91// lldb-command:continue
92
93// OWNED BY REF
94// lldb-command:print *self
95// lldb-check:[...]$6 = Struct<f64> { x: 1234.5 }
96// lldb-command:print arg1
97// lldb-check:[...]$7 = -5
98// lldb-command:print arg2
99// lldb-check:[...]$8 = -6
100// lldb-command:continue
101
102// OWNED BY VAL
103// lldb-command:print self
104// lldb-check:[...]$9 = Struct<f64> { x: 1234.5 }
105// lldb-command:print arg1
106// lldb-check:[...]$10 = -7
107// lldb-command:print arg2
108// lldb-check:[...]$11 = -8
109// lldb-command:continue
110
111// OWNED MOVED
112// lldb-command:print *self
113// lldb-check:[...]$12 = Struct<f64> { x: 1234.5 }
114// lldb-command:print arg1
115// lldb-check:[...]$13 = -9
116// lldb-command:print arg2
117// lldb-check:[...]$14 = -10.5
118// lldb-command:continue
119
120
Michael Woerister55a8bd52014-04-24 09:35:48121struct Struct<T> {
122 x: T
123}
124
125impl<T1> Struct<T1> {
126
127 fn self_by_ref<T2>(&self, arg1: int, arg2: T2) -> int {
Michael Woeristerc7f45a92014-07-09 12:46:09128 zzz(); // #break
Michael Woerister55a8bd52014-04-24 09:35:48129 arg1
130 }
131
132 fn self_by_val<T2>(self, arg1: int, arg2: T2) -> int {
Michael Woeristerc7f45a92014-07-09 12:46:09133 zzz(); // #break
Michael Woerister55a8bd52014-04-24 09:35:48134 arg1
135 }
136
137 fn self_owned<T2>(~self, arg1: int, arg2: T2) -> int {
Michael Woeristerc7f45a92014-07-09 12:46:09138 zzz(); // #break
Michael Woerister55a8bd52014-04-24 09:35:48139 arg1
140 }
141}
142
143fn main() {
144 let stack = Struct { x: (8888_u32, -8888_i32) };
Michael Woeristerc7f45a92014-07-09 12:46:09145 let _ = stack.self_by_ref(-1, 2_u16);
Michael Woerister55a8bd52014-04-24 09:35:48146 let _ = stack.self_by_val(-3, -4_i16);
147
Patrick Waltona5bb0a32014-06-27 19:30:25148 let owned = box Struct { x: 1234.5f64 };
Michael Woerister55a8bd52014-04-24 09:35:48149 let _ = owned.self_by_ref(-5, -6_i32);
150 let _ = owned.self_by_val(-7, -8_i64);
151 let _ = owned.self_owned(-9, -10.5_f32);
152}
153
154fn zzz() {()}