Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 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-android: FIXME(#10381) |
| 12 | |
| 13 | // compile-flags:-g |
Michael Woerister | c7f45a9 | 2014-07-09 12:46:09 | [diff] [blame^] | 14 | |
| 15 | // === GDB TESTS =================================================================================== |
| 16 | |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 17 | // 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 Woerister | c7f45a9 | 2014-07-09 12:46:09 | [diff] [blame^] | 26 | // gdb-command:print arg2 |
| 27 | // gdb-check:$3 = 2 |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 28 | // 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 Woerister | c7f45a9 | 2014-07-09 12:46:09 | [diff] [blame^] | 70 | |
| 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 Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 121 | struct Struct<T> { |
| 122 | x: T |
| 123 | } |
| 124 | |
| 125 | impl<T1> Struct<T1> { |
| 126 | |
| 127 | fn self_by_ref<T2>(&self, arg1: int, arg2: T2) -> int { |
Michael Woerister | c7f45a9 | 2014-07-09 12:46:09 | [diff] [blame^] | 128 | zzz(); // #break |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 129 | arg1 |
| 130 | } |
| 131 | |
| 132 | fn self_by_val<T2>(self, arg1: int, arg2: T2) -> int { |
Michael Woerister | c7f45a9 | 2014-07-09 12:46:09 | [diff] [blame^] | 133 | zzz(); // #break |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 134 | arg1 |
| 135 | } |
| 136 | |
| 137 | fn self_owned<T2>(~self, arg1: int, arg2: T2) -> int { |
Michael Woerister | c7f45a9 | 2014-07-09 12:46:09 | [diff] [blame^] | 138 | zzz(); // #break |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 139 | arg1 |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | fn main() { |
| 144 | let stack = Struct { x: (8888_u32, -8888_i32) }; |
Michael Woerister | c7f45a9 | 2014-07-09 12:46:09 | [diff] [blame^] | 145 | let _ = stack.self_by_ref(-1, 2_u16); |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 146 | let _ = stack.self_by_val(-3, -4_i16); |
| 147 | |
Patrick Walton | a5bb0a3 | 2014-06-27 19:30:25 | [diff] [blame] | 148 | let owned = box Struct { x: 1234.5f64 }; |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 149 | 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 | |
| 154 | fn zzz() {()} |