]>
Commit | Line | Data |
---|---|---|
b7449926 XL |
1 | // ignore-windows failing on win32 bot |
2 | // ignore-freebsd: gdb package too new | |
3 | // ignore-android: FIXME(#10381) | |
fc512014 | 4 | // ignore-macos: FIXME(#78665) |
b7449926 | 5 | // compile-flags:-g |
0731742a XL |
6 | |
7 | // The pretty printers being tested here require the patch from | |
8 | // https://sourceware.org/bugzilla/show_bug.cgi?id=21763 | |
3dfed10e | 9 | // min-gdb-version: 8.1 |
0731742a | 10 | |
b7449926 XL |
11 | // min-lldb-version: 310 |
12 | ||
13 | // === GDB TESTS =================================================================================== | |
14 | ||
15 | // gdb-command: run | |
16 | ||
17 | // gdb-command: print btree_set | |
f035d41b | 18 | // gdb-check:$1 = BTreeSet(size=15) = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14} |
b7449926 | 19 | |
ba9703b0 | 20 | // gdb-command: print empty_btree_set |
f035d41b | 21 | // gdb-check:$2 = BTreeSet(size=0) |
ba9703b0 | 22 | |
b7449926 | 23 | // gdb-command: print btree_map |
f035d41b | 24 | // gdb-check:$3 = BTreeMap(size=15) = {[0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8, [9] = 9, [10] = 10, [11] = 11, [12] = 12, [13] = 13, [14] = 14} |
ba9703b0 XL |
25 | |
26 | // gdb-command: print empty_btree_map | |
f035d41b | 27 | // gdb-check:$4 = BTreeMap(size=0) |
ba9703b0 XL |
28 | |
29 | // gdb-command: print option_btree_map | |
f035d41b | 30 | // gdb-check:$5 = BTreeMap(size=2) = {[false] = [...], [true] = [...]} |
ba9703b0 XL |
31 | // (abbreviated because both values vary wildly over gdb versions and/or linux distributions) |
32 | ||
33 | // gdb-command: print nasty_btree_map | |
f035d41b | 34 | // gdb-check:$6 = BTreeMap(size=15) = {[0] = pretty_std_collections::MyLeafNode (0), [...]} |
ba9703b0 | 35 | // (abbreviated because it's boring but we need enough elements to include internal nodes) |
b7449926 | 36 | |
29967ef6 XL |
37 | // gdb-command: print zst_key_btree_map |
38 | // gdb-check:$7 = BTreeMap(size=1) = {[()] = 1} | |
39 | ||
40 | // gdb-command: print zst_val_btree_map | |
41 | // gdb-check:$8 = BTreeMap(size=1) = {[1] = ()} | |
42 | ||
43 | // gdb-command: print zst_key_val_btree_map | |
44 | // gdb-check:$9 = BTreeMap(size=1) = {[()] = ()} | |
45 | ||
b7449926 | 46 | // gdb-command: print vec_deque |
29967ef6 | 47 | // gdb-check:$10 = VecDeque(size=3) = {5, 3, 7} |
b7449926 | 48 | |
a1dfa0c6 | 49 | // gdb-command: print vec_deque2 |
29967ef6 | 50 | // gdb-check:$11 = VecDeque(size=7) = {2, 3, 4, 5, 6, 7, 8} |
f035d41b XL |
51 | |
52 | // gdb-command: print hash_map | |
29967ef6 | 53 | // gdb-check:$12 = HashMap(size=4) = {[1] = 10, [2] = 20, [3] = 30, [4] = 40} |
f035d41b XL |
54 | |
55 | // gdb-command: print hash_set | |
29967ef6 | 56 | // gdb-check:$13 = HashSet(size=4) = {1, 2, 3, 4} |
f035d41b XL |
57 | |
58 | // === LLDB TESTS ================================================================================== | |
59 | ||
60 | // lldb-command:run | |
61 | ||
62 | // lldb-command:print vec_deque | |
63 | // lldbg-check:[...]$0 = size=3 { [0] = 5 [1] = 3 [2] = 7 } | |
64 | // lldbr-check:(alloc::collections::vec_deque::VecDeque<i32>) vec_deque = size=3 = { [0] = 5 [1] = 3 [2] = 7 } | |
65 | ||
66 | // lldb-command:print vec_deque2 | |
67 | // lldbg-check:[...]$1 = size=7 { [0] = 2 [1] = 3 [2] = 4 [3] = 5 [4] = 6 [5] = 7 [6] = 8 } | |
68 | // lldbr-check:(alloc::collections::vec_deque::VecDeque<i32>) vec_deque2 = size=7 = { [0] = 2 [1] = 3 [2] = 4 [3] = 5 [4] = 6 [5] = 7 [6] = 8 } | |
69 | ||
70 | // lldb-command:print hash_map | |
71 | // lldbg-check:[...]$2 = size=4 { [0] = { 0 = 1 1 = 10 } [1] = { 0 = 2 1 = 20 } [2] = { 0 = 3 1 = 30 } [3] = { 0 = 4 1 = 40 } } | |
72 | // lldbr-check:(std::collections::hash::map::HashMap<u64, u64, [...]>) hash_map = size=4 size=4 { [0] = { 0 = 1 1 = 10 } [1] = { 0 = 2 1 = 20 } [2] = { 0 = 3 1 = 30 } [3] = { 0 = 4 1 = 40 } } | |
73 | ||
74 | // lldb-command:print hash_set | |
75 | // lldbg-check:[...]$3 = size=4 { [0] = 1 [1] = 2 [2] = 3 [3] = 4 } | |
76 | // lldbr-check:(std::collections::hash::set::HashSet<u64, [...]>) hash_set = size=4 { [0] = 1 [1] = 2 [2] = 3 [3] = 4 } | |
a1dfa0c6 | 77 | |
b7449926 | 78 | #![allow(unused_variables)] |
b7449926 | 79 | use std::collections::BTreeMap; |
ba9703b0 | 80 | use std::collections::BTreeSet; |
f035d41b XL |
81 | use std::collections::HashMap; |
82 | use std::collections::HashSet; | |
29967ef6 | 83 | use std::collections::VecDeque; |
f035d41b | 84 | use std::hash::{BuildHasherDefault, Hasher}; |
b7449926 | 85 | |
ba9703b0 | 86 | struct MyLeafNode(i32); // helps to ensure we don't blindly replace substring "LeafNode" |
b7449926 | 87 | |
f035d41b XL |
88 | #[derive(Default)] |
89 | struct SimpleHasher { hash: u64 } | |
90 | ||
91 | impl Hasher for SimpleHasher { | |
92 | fn finish(&self) -> u64 { self.hash } | |
93 | fn write(&mut self, bytes: &[u8]) {} | |
94 | fn write_u64(&mut self, i: u64) { self.hash = i } | |
95 | } | |
96 | ||
b7449926 | 97 | fn main() { |
b7449926 XL |
98 | // BTreeSet |
99 | let mut btree_set = BTreeSet::new(); | |
a1dfa0c6 XL |
100 | for i in 0..15 { |
101 | btree_set.insert(i); | |
102 | } | |
b7449926 | 103 | |
fc512014 | 104 | let empty_btree_set: BTreeSet<i32> = BTreeSet::new(); |
ba9703b0 | 105 | |
b7449926 XL |
106 | // BTreeMap |
107 | let mut btree_map = BTreeMap::new(); | |
a1dfa0c6 XL |
108 | for i in 0..15 { |
109 | btree_map.insert(i, i); | |
110 | } | |
b7449926 | 111 | |
fc512014 | 112 | let empty_btree_map: BTreeMap<i32, u32> = BTreeMap::new(); |
ba9703b0 XL |
113 | |
114 | let mut option_btree_map: BTreeMap<bool, Option<bool>> = BTreeMap::new(); | |
115 | option_btree_map.insert(false, None); | |
116 | option_btree_map.insert(true, Some(true)); | |
117 | ||
118 | let mut nasty_btree_map: BTreeMap<i32, MyLeafNode> = BTreeMap::new(); | |
119 | for i in 0..15 { | |
120 | nasty_btree_map.insert(i, MyLeafNode(i)); | |
121 | } | |
122 | ||
29967ef6 XL |
123 | let mut zst_key_btree_map: BTreeMap<(), i32> = BTreeMap::new(); |
124 | zst_key_btree_map.insert((), 1); | |
125 | ||
126 | let mut zst_val_btree_map: BTreeMap<i32, ()> = BTreeMap::new(); | |
127 | zst_val_btree_map.insert(1, ()); | |
128 | ||
129 | let mut zst_key_val_btree_map: BTreeMap<(), ()> = BTreeMap::new(); | |
130 | zst_key_val_btree_map.insert((), ()); | |
131 | ||
b7449926 XL |
132 | // VecDeque |
133 | let mut vec_deque = VecDeque::new(); | |
134 | vec_deque.push_back(5); | |
135 | vec_deque.push_back(3); | |
136 | vec_deque.push_back(7); | |
137 | ||
a1dfa0c6 XL |
138 | // VecDeque where an element was popped. |
139 | let mut vec_deque2 = VecDeque::new(); | |
140 | for i in 1..8 { | |
141 | vec_deque2.push_back(i) | |
142 | } | |
143 | vec_deque2.pop_front(); | |
144 | vec_deque2.push_back(8); | |
145 | ||
f035d41b XL |
146 | // HashMap |
147 | let mut hash_map = HashMap::<u64, u64, BuildHasherDefault<SimpleHasher>>::default(); | |
148 | for i in 1..5 { | |
149 | hash_map.insert(i, i * 10); | |
150 | } | |
151 | ||
152 | // HashSet | |
153 | let mut hash_set = HashSet::<u64, BuildHasherDefault<SimpleHasher>>::default(); | |
154 | for i in 1..5 { | |
155 | hash_set.insert(i); | |
156 | } | |
157 | ||
b7449926 XL |
158 | zzz(); // #break |
159 | } | |
160 | ||
ba9703b0 XL |
161 | fn zzz() { |
162 | () | |
163 | } |