|
| 1 | +use tskit::prelude::*; |
| 2 | + |
1 | 3 | #[derive(PartialEq, Debug)]
|
2 | 4 | struct IteratorOutput {
|
3 | 5 | edges: Vec<tskit::EdgeTableRow>,
|
@@ -63,13 +65,13 @@ impl IteratorOutput {
|
63 | 65 | }
|
64 | 66 | }
|
65 | 67 |
|
66 |
| - fn new_from_table_access_impl_syntax(access: impl tskit::TableAccess) -> Self { |
| 68 | + fn new_from_table_access_impl_syntax(access: impl TableAccess) -> Self { |
67 | 69 | Self::new_from_table_access(&access)
|
68 | 70 | }
|
69 | 71 |
|
70 | 72 | fn new_from_table_iteration<T>(iterator: &T) -> Self
|
71 | 73 | where
|
72 |
| - T: tskit::TableIteration, |
| 74 | + T: TableIteration, |
73 | 75 | {
|
74 | 76 | let edges = iterator.edges().iter().collect::<Vec<_>>();
|
75 | 77 | let nodes = iterator.nodes().iter().collect::<Vec<_>>();
|
@@ -137,48 +139,74 @@ fn validate_output_from_tables(tables: tskit::TableCollection) {
|
137 | 139 | fn validate_output_from_table_ref(tables: tskit::TableCollection) {
|
138 | 140 | let tref = &tables;
|
139 | 141 | let tables_output = IteratorOutput::new_from_tables(tref);
|
140 |
| - let access_output = IteratorOutput::new_from_table_access(tref); |
141 |
| - assert_eq!(tables_output, access_output); |
142 |
| - let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(tref); |
143 |
| - assert_eq!(tables_output, impl_syntax_output); |
144 |
| - let iteration_output = IteratorOutput::new_from_table_iteration(tref); |
145 |
| - assert_eq!(tables_output, iteration_output); |
| 142 | + { |
| 143 | + let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(tref); |
| 144 | + assert_eq!(tables_output, impl_syntax_output); |
| 145 | + } |
| 146 | + { |
| 147 | + let iteration_output = IteratorOutput::new_from_table_iteration(tref); |
| 148 | + assert_eq!(tables_output, iteration_output); |
| 149 | + } |
146 | 150 | let boxed = Box::new(tref);
|
147 |
| - let dynamic_output = IteratorOutput::new_from_dyn(&boxed); |
148 |
| - assert_eq!(tables_output, dynamic_output); |
149 |
| - let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(&boxed); |
150 |
| - assert_eq!(tables_output, impl_syntax_output); |
| 151 | + { |
| 152 | + let dynamic_output = IteratorOutput::new_from_dyn(&boxed); |
| 153 | + assert_eq!(tables_output, dynamic_output); |
| 154 | + } |
| 155 | + { |
| 156 | + let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(&boxed); |
| 157 | + assert_eq!(tables_output, impl_syntax_output); |
| 158 | + } |
151 | 159 | }
|
152 | 160 |
|
153 | 161 | fn validate_output_from_treeseq(treeseq: tskit::TreeSequence) {
|
154 | 162 | let treeseq_output = IteratorOutput::new_from_treeseq(&treeseq);
|
155 |
| - let access_output = IteratorOutput::new_from_table_access(&treeseq); |
156 |
| - assert_eq!(treeseq_output, access_output); |
157 |
| - let iteration_output = IteratorOutput::new_from_table_iteration(&treeseq); |
158 |
| - assert_eq!(treeseq_output, iteration_output); |
159 |
| - let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(&treeseq); |
160 |
| - assert_eq!(treeseq_output, impl_syntax_output); |
| 163 | + { |
| 164 | + let access_output = IteratorOutput::new_from_table_access(&treeseq); |
| 165 | + assert_eq!(treeseq_output, access_output); |
| 166 | + } |
| 167 | + { |
| 168 | + let iteration_output = IteratorOutput::new_from_table_iteration(&treeseq); |
| 169 | + assert_eq!(treeseq_output, iteration_output); |
| 170 | + } |
| 171 | + { |
| 172 | + let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(&treeseq); |
| 173 | + assert_eq!(treeseq_output, impl_syntax_output); |
| 174 | + } |
161 | 175 | let boxed = Box::new(treeseq);
|
162 |
| - let dynamic_output = IteratorOutput::new_from_dyn(&boxed); |
163 |
| - assert_eq!(treeseq_output, dynamic_output); |
164 |
| - let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(boxed); |
165 |
| - assert_eq!(treeseq_output, impl_syntax_output); |
| 176 | + { |
| 177 | + let dynamic_output = IteratorOutput::new_from_dyn(&boxed); |
| 178 | + assert_eq!(treeseq_output, dynamic_output); |
| 179 | + } |
| 180 | + { |
| 181 | + let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(boxed); |
| 182 | + assert_eq!(treeseq_output, impl_syntax_output); |
| 183 | + } |
166 | 184 | }
|
167 | 185 |
|
168 | 186 | fn validate_output_from_treeseq_ref(treeseq: tskit::TreeSequence) {
|
169 | 187 | let treeseq_ref = &treeseq;
|
170 | 188 | let treeseq_output = IteratorOutput::new_from_treeseq(treeseq_ref);
|
171 |
| - let access_output = IteratorOutput::new_from_table_access(treeseq_ref); |
172 |
| - assert_eq!(treeseq_output, access_output); |
173 |
| - let iteration_output = IteratorOutput::new_from_table_iteration(treeseq_ref); |
174 |
| - assert_eq!(treeseq_output, iteration_output); |
175 |
| - let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(treeseq_ref); |
176 |
| - assert_eq!(treeseq_output, impl_syntax_output); |
| 189 | + { |
| 190 | + let access_output = IteratorOutput::new_from_table_access(treeseq_ref); |
| 191 | + assert_eq!(treeseq_output, access_output); |
| 192 | + } |
| 193 | + { |
| 194 | + let iteration_output = IteratorOutput::new_from_table_iteration(treeseq_ref); |
| 195 | + assert_eq!(treeseq_output, iteration_output); |
| 196 | + } |
| 197 | + { |
| 198 | + let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(treeseq_ref); |
| 199 | + assert_eq!(treeseq_output, impl_syntax_output); |
| 200 | + } |
177 | 201 | let boxed = Box::new(treeseq_ref);
|
178 |
| - let dynamic_output = IteratorOutput::new_from_dyn(&boxed); |
179 |
| - assert_eq!(treeseq_output, dynamic_output); |
180 |
| - let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(boxed); |
181 |
| - assert_eq!(treeseq_output, impl_syntax_output); |
| 202 | + { |
| 203 | + let dynamic_output = IteratorOutput::new_from_dyn(&boxed); |
| 204 | + assert_eq!(treeseq_output, dynamic_output); |
| 205 | + } |
| 206 | + { |
| 207 | + let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(boxed); |
| 208 | + assert_eq!(treeseq_output, impl_syntax_output); |
| 209 | + } |
182 | 210 | }
|
183 | 211 |
|
184 | 212 | fn make_tables() -> tskit::TableCollection {
|
|
0 commit comments