From 9b3aa591cd0672e9b7bdf3e5aab630cd09a4d546 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 17 Jun 2021 11:18:37 +0300 Subject: internal: switch some tests to minicore --- crates/test_utils/src/fixture.rs | 2 +- crates/test_utils/src/minicore.rs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'crates/test_utils/src') 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 { let components = meta.split_ascii_whitespace().collect::>(); let path = components[0].to_string(); - assert!(path.starts_with('/')); + assert!(path.starts_with('/'), "fixture path does not start with `/`: {:?}", path); let mut krate = None; let mut deps = Vec::new(); diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs index 2f0da7fe5..1a0573d7a 100644 --- a/crates/test_utils/src/minicore.rs +++ b/crates/test_utils/src/minicore.rs @@ -228,6 +228,28 @@ pub mod iter { } pub use self::adapters::Take; + mod sources { + mod repeat { + pub fn repeat(elt: T) -> Repeat { + loop {} + } + + pub struct Repeat { + element: A, + } + + impl Iterator for Repeat { + type Item = A; + + fn next(&mut self) -> Option { + loop {} + } + } + } + pub use self::repeat::{repeat, Repeat}; + } + pub use self::sources::{repeat, Repeat}; + mod traits { mod iterator { use super::super::Take; @@ -242,6 +264,18 @@ pub mod iter { fn take(self, n: usize) -> crate::iter::Take { loop {} } + fn by_ref(&mut self) -> &mut Self + where + Self: Sized, + { + self + } + } + impl Iterator for &mut I { + type Item = I::Item; + fn next(&mut self) -> Option { + (**self).next() + } } } pub use self::iterator::Iterator; -- cgit v1.2.3 From c42cdff3d2ed2e30add09dd0d602181b6f83534d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 17 Jun 2021 11:28:44 +0300 Subject: internal: minimize minicore We want to keep minicore small, so let's split out iterator adapters and sources into a separate `iterators` region, and use them only when needed. --- crates/test_utils/src/minicore.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'crates/test_utils/src') diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs index 1a0573d7a..e6d2301c7 100644 --- a/crates/test_utils/src/minicore.rs +++ b/crates/test_utils/src/minicore.rs @@ -21,6 +21,7 @@ //! option: //! result: //! iterator: option +//! iterators: iterator pub mod marker { // region:sized @@ -209,6 +210,7 @@ pub mod task { // region:iterator pub mod iter { + // region:iterators mod adapters { pub struct Take { iter: I, @@ -249,6 +251,7 @@ pub mod iter { pub use self::repeat::{repeat, Repeat}; } pub use self::sources::{repeat, Repeat}; + // endregion:iterators mod traits { mod iterator { @@ -261,15 +264,17 @@ pub mod iter { fn nth(&mut self, n: usize) -> Option { loop {} } - fn take(self, n: usize) -> crate::iter::Take { - loop {} - } fn by_ref(&mut self) -> &mut Self where Self: Sized, { self } + // region:iterators + fn take(self, n: usize) -> crate::iter::Take { + loop {} + } + // endregion:iterators } impl Iterator for &mut I { type Item = I::Item; -- cgit v1.2.3