Skip to content
Myr

Make ensure tests work on old rustc

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 74c153d · Browse files · 1 file+15 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+15 added−3 removed

  • tests:+15 added−3 removed

1 file+15 added−3 removed

modified:tests/test_ensure.rs+15 added-3 removed
30 unmodified lines
31impl<T> Trait for T {}3233#[track_caller]34fn assert_err<T: Debug>(result: impl FnOnce() -> Result<T>, expected: &'static str) {35 assert_eq!(result().unwrap_err().to_string(), expected);35 let actual = result().unwrap_err().to_string();3637 let mut accepted_alternatives = expected.split('\n');38 let expected = accepted_alternatives.next_back().unwrap();39 if accepted_alternatives.any(|alternative| actual == alternative) {40 return;41 }4243 assert_eq!(actual, expected);44}4546#[test]47fn test_low_precedence_control_flow() {
112 unmodified lines
160 #[rustfmt::skip]161 let test = || Ok(ensure!(1 + loop { break 1 } == 1));162 assert_err(163 test,164 // 1.54 puts a double space after loop165 "Condition failed: `1 + loop { break 1 } == 1` (2 vs 1)\n\156 "Condition failed: `1 + loop { break 1 } == 1` (2 vs 1)",166 Condition failed: `1 + loop { break 1 } == 1` (2 vs 1)",167 );168169 #[rustfmt::skip]170 let test = || Ok(ensure!(1 + 'a: loop { break 'a 1 } == 1));171 assert_err(172 test,173 // 1.54 puts a double space after loop174 "Condition failed: `1 + 'a: loop { break 'a 1 } == 1` (2 vs 1)\n\163 "Condition failed: `1 + 'a: loop { break 'a 1 } == 1` (2 vs 1)",175 Condition failed: `1 + 'a: loop { break 'a 1 } == 1` (2 vs 1)",176 );177178 #[rustfmt::skip]179 let test = || Ok(ensure!(while false {}.t(1) == 2));
171 unmodified lines