Skip to content

Commit 13fb77b

Browse files
committed
Update tests involving slice comparison
1 parent eac1d63 commit 13fb77b

File tree

4 files changed

+19
-30
lines changed
  • library
  • src/tools/rust-analyzer/crates/test-utils/src

4 files changed

+19
-30
lines changed

library/alloc/src/collections/vec_deque/tests.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,12 @@ fn make_contiguous_big_head() {
479479

480480
// 012......9876543
481481
assert_eq!(tester.capacity(), 15);
482-
assert_eq!((&[9, 8, 7, 6, 5, 4, 3] as &[_], &[0, 1, 2] as &[_]), tester.as_slices());
482+
assert_eq!(tester.as_slices(), ([9, 8, 7, 6, 5, 4, 3], [0, 1, 2]));
483483

484484
let expected_start = tester.as_slices().1.len();
485485
tester.make_contiguous();
486486
assert_eq!(tester.head, expected_start);
487-
assert_eq!((&[9, 8, 7, 6, 5, 4, 3, 0, 1, 2] as &[_], &[] as &[_]), tester.as_slices());
487+
assert_eq!(tester.as_slices(), ([9, 8, 7, 6, 5, 4, 3, 0, 1, 2], []));
488488
}
489489

490490
#[test]
@@ -503,7 +503,7 @@ fn make_contiguous_big_tail() {
503503
let expected_start = 0;
504504
tester.make_contiguous();
505505
assert_eq!(tester.head, expected_start);
506-
assert_eq!((&[9, 8, 0, 1, 2, 3, 4, 5, 6, 7] as &[_], &[] as &[_]), tester.as_slices());
506+
assert_eq!(tester.as_slices(), ([9, 8, 0, 1, 2, 3, 4, 5, 6, 7], []));
507507
}
508508

509509
#[test]
@@ -525,8 +525,8 @@ fn make_contiguous_small_free() {
525525
tester.make_contiguous();
526526
assert_eq!(tester.head, expected_start);
527527
assert_eq!(
528-
(&['M', 'L', 'K', 'J', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as &[_], &[] as &[_]),
529-
tester.as_slices()
528+
tester.as_slices(),
529+
(['M', 'L', 'K', 'J', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'], [])
530530
);
531531

532532
tester.clear();
@@ -543,8 +543,8 @@ fn make_contiguous_small_free() {
543543
tester.make_contiguous();
544544
assert_eq!(tester.head, expected_start);
545545
assert_eq!(
546-
(&['H', 'G', 'F', 'E', 'D', 'C', 'B', 'A', 'I', 'J', 'K', 'L', 'M'] as &[_], &[] as &[_]),
547-
tester.as_slices()
546+
tester.as_slices(),
547+
(['H', 'G', 'F', 'E', 'D', 'C', 'B', 'A', 'I', 'J', 'K', 'L', 'M'], [])
548548
);
549549
}
550550

@@ -570,12 +570,8 @@ fn make_contiguous_head_to_end() {
570570
tester.make_contiguous();
571571
assert_eq!(tester.head, expected_start);
572572
assert_eq!(
573-
(
574-
&['P', 'O', 'N', 'M', 'L', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K']
575-
as &[_],
576-
&[] as &[_]
577-
),
578-
tester.as_slices()
573+
tester.as_slices(),
574+
(['P', 'O', 'N', 'M', 'L', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'], [])
579575
);
580576

581577
tester.clear();
@@ -592,12 +588,8 @@ fn make_contiguous_head_to_end() {
592588
tester.make_contiguous();
593589
assert_eq!(tester.head, expected_start);
594590
assert_eq!(
595-
(
596-
&['K', 'J', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A', 'L', 'M', 'N', 'O', 'P']
597-
as &[_],
598-
&[] as &[_]
599-
),
600-
tester.as_slices()
591+
tester.as_slices(),
592+
(['K', 'J', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A', 'L', 'M', 'N', 'O', 'P'], [])
601593
);
602594
}
603595

library/alloctests/tests/vec.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,10 @@ fn zero_sized_values() {
505505

506506
#[test]
507507
fn test_partition() {
508-
assert_eq!([].into_iter().partition(|x: &i32| *x < 3), (vec![], vec![]));
509-
assert_eq!([1, 2, 3].into_iter().partition(|x| *x < 4), (vec![1, 2, 3], vec![]));
510-
assert_eq!([1, 2, 3].into_iter().partition(|x| *x < 2), (vec![1], vec![2, 3]));
511-
assert_eq!([1, 2, 3].into_iter().partition(|x| *x < 0), (vec![], vec![1, 2, 3]));
508+
assert_eq!([].into_iter().partition::<Vec<_>, _>(|x: &i32| *x < 3), ([], []));
509+
assert_eq!([1, 2, 3].into_iter().partition::<Vec<_>, _>(|x| *x < 4), ([1, 2, 3], []));
510+
assert_eq!([1, 2, 3].into_iter().partition::<Vec<_>, _>(|x| *x < 2), ([1], [2, 3]));
511+
assert_eq!([1, 2, 3].into_iter().partition::<Vec<_>, _>(|x| *x < 0), ([], [1, 2, 3]));
512512
}
513513

514514
#[test]

library/coretests/tests/num/flt2dec/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ where
194194
let v: T = TestableFloat::ldexpi(x, e);
195195
let decoded = decode_finite(v);
196196

197-
try_exact!(f(&decoded) => &mut buf, &expected, expectedk;
197+
try_exact!(f(&decoded) => &mut buf, expected, expectedk;
198198
"exact mismatch for v={x}p{e}{t}: actual {actual:?}, expected {expected:?}",
199199
x = x, e = e, t = tstr);
200-
try_fixed!(f(&decoded) => &mut buf, expectedk - expected.len() as i16, &expected, expectedk;
200+
try_fixed!(f(&decoded) => &mut buf, expectedk - expected.len() as i16, expected, expectedk;
201201
"fixed mismatch for v={x}p{e}{t}: actual {actual:?}, expected {expected:?}",
202202
x = x, e = e, t = tstr);
203203
}

src/tools/rust-analyzer/crates/test-utils/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,7 @@ fn main() {
361361
.map(|(range, ann)| (&text[range], ann))
362362
.collect::<Vec<_>>();
363363

364-
assert_eq!(
365-
res[..3],
366-
[("x", "def".into()), ("y", "def".into()), ("zoo", "type:\ni32\n".into())]
367-
);
364+
assert_eq!(res[..3], [("x", "def"), ("y", "def"), ("zoo", "type:\ni32\n")]);
368365
assert_eq!(res[3].0.len(), 115);
369366
}
370367

@@ -384,7 +381,7 @@ fn main() {
384381
.map(|(range, ann)| (&text[range], ann))
385382
.collect::<Vec<_>>();
386383

387-
assert_eq!(res, [("x", "a".into()), ("y", "b".into()), ("(x, y)", "c".into())]);
384+
assert_eq!(res, [("x", "a"), ("y", "b"), ("(x, y)", "c")]);
388385
}
389386

390387
/// Returns `false` if slow tests should not run, otherwise returns `true` and

0 commit comments

Comments
 (0)