diff options
Diffstat (limited to 'crates/test_utils')
-rw-r--r-- | crates/test_utils/src/fixture.rs | 2 | ||||
-rw-r--r-- | crates/test_utils/src/minicore.rs | 101 |
2 files changed, 102 insertions, 1 deletions
diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs index 005a5c092..8d8f3b560 100644 --- a/crates/test_utils/src/fixture.rs +++ b/crates/test_utils/src/fixture.rs | |||
@@ -154,7 +154,7 @@ impl Fixture { | |||
154 | let components = meta.split_ascii_whitespace().collect::<Vec<_>>(); | 154 | let components = meta.split_ascii_whitespace().collect::<Vec<_>>(); |
155 | 155 | ||
156 | let path = components[0].to_string(); | 156 | let path = components[0].to_string(); |
157 | assert!(path.starts_with('/')); | 157 | assert!(path.starts_with('/'), "fixture path does not start with `/`: {:?}", path); |
158 | 158 | ||
159 | let mut krate = None; | 159 | let mut krate = None; |
160 | let mut deps = Vec::new(); | 160 | let mut deps = Vec::new(); |
diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs index e04ca58d2..e6d2301c7 100644 --- a/crates/test_utils/src/minicore.rs +++ b/crates/test_utils/src/minicore.rs | |||
@@ -20,6 +20,8 @@ | |||
20 | //! future: pin | 20 | //! future: pin |
21 | //! option: | 21 | //! option: |
22 | //! result: | 22 | //! result: |
23 | //! iterator: option | ||
24 | //! iterators: iterator | ||
23 | 25 | ||
24 | pub mod marker { | 26 | pub mod marker { |
25 | // region:sized | 27 | // region:sized |
@@ -206,9 +208,108 @@ pub mod task { | |||
206 | } | 208 | } |
207 | // endregion:future | 209 | // endregion:future |
208 | 210 | ||
211 | // region:iterator | ||
212 | pub mod iter { | ||
213 | // region:iterators | ||
214 | mod adapters { | ||
215 | pub struct Take<I> { | ||
216 | iter: I, | ||
217 | n: usize, | ||
218 | } | ||
219 | |||
220 | impl<I> Iterator for Take<I> | ||
221 | where | ||
222 | I: Iterator, | ||
223 | { | ||
224 | type Item = <I as Iterator>::Item; | ||
225 | |||
226 | fn next(&mut self) -> Option<<I as Iterator>::Item> { | ||
227 | loop {} | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | pub use self::adapters::Take; | ||
232 | |||
233 | mod sources { | ||
234 | mod repeat { | ||
235 | pub fn repeat<T>(elt: T) -> Repeat<T> { | ||
236 | loop {} | ||
237 | } | ||
238 | |||
239 | pub struct Repeat<A> { | ||
240 | element: A, | ||
241 | } | ||
242 | |||
243 | impl<A> Iterator for Repeat<A> { | ||
244 | type Item = A; | ||
245 | |||
246 | fn next(&mut self) -> Option<A> { | ||
247 | loop {} | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | pub use self::repeat::{repeat, Repeat}; | ||
252 | } | ||
253 | pub use self::sources::{repeat, Repeat}; | ||
254 | // endregion:iterators | ||
255 | |||
256 | mod traits { | ||
257 | mod iterator { | ||
258 | use super::super::Take; | ||
259 | |||
260 | pub trait Iterator { | ||
261 | type Item; | ||
262 | #[lang = "next"] | ||
263 | fn next(&mut self) -> Option<Self::Item>; | ||
264 | fn nth(&mut self, n: usize) -> Option<Self::Item> { | ||
265 | loop {} | ||
266 | } | ||
267 | fn by_ref(&mut self) -> &mut Self | ||
268 | where | ||
269 | Self: Sized, | ||
270 | { | ||
271 | self | ||
272 | } | ||
273 | // region:iterators | ||
274 | fn take(self, n: usize) -> crate::iter::Take<Self> { | ||
275 | loop {} | ||
276 | } | ||
277 | // endregion:iterators | ||
278 | } | ||
279 | impl<I: Iterator + ?Sized> Iterator for &mut I { | ||
280 | type Item = I::Item; | ||
281 | fn next(&mut self) -> Option<I::Item> { | ||
282 | (**self).next() | ||
283 | } | ||
284 | } | ||
285 | } | ||
286 | pub use self::iterator::Iterator; | ||
287 | |||
288 | mod collect { | ||
289 | pub trait IntoIterator { | ||
290 | type Item; | ||
291 | type IntoIter: Iterator<Item = Self::Item>; | ||
292 | #[lang = "into_iter"] | ||
293 | fn into_iter(self) -> Self::IntoIter; | ||
294 | } | ||
295 | impl<I: Iterator> IntoIterator for I { | ||
296 | type Item = I::Item; | ||
297 | type IntoIter = I; | ||
298 | fn into_iter(self) -> I { | ||
299 | self | ||
300 | } | ||
301 | } | ||
302 | } | ||
303 | pub use self::collect::IntoIterator; | ||
304 | } | ||
305 | pub use self::traits::{IntoIterator, Iterator}; | ||
306 | } | ||
307 | // endregion:iterator | ||
308 | |||
209 | pub mod prelude { | 309 | pub mod prelude { |
210 | pub mod v1 { | 310 | pub mod v1 { |
211 | pub use crate::{ | 311 | pub use crate::{ |
312 | iter::{IntoIterator, Iterator}, // :iterator | ||
212 | marker::Sized, // :sized | 313 | marker::Sized, // :sized |
213 | ops::{Fn, FnMut, FnOnce}, // :fn | 314 | ops::{Fn, FnMut, FnOnce}, // :fn |
214 | option::Option::{self, None, Some}, // :option | 315 | option::Option::{self, None, Some}, // :option |