Skip to content

Commit 4a6bc65

Browse files
committed
Test reverse coercion by indirect dep
1 parent c97b7a7 commit 4a6bc65

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

crates/resolver-tests/tests/resolve.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,50 @@ fn test_wildcard_major_coerced_by_subdepdency() {
529529
);
530530
}
531531

532+
#[test]
533+
fn test_wildcard_major_coerced_by_indirect_subdepdency() {
534+
let reg = registry(vec![
535+
pkg!("foo" => [dep_req("util", "0.1")]),
536+
pkg!("bar" => [dep_req("car", "1.0.0")]),
537+
pkg!("car" => [dep_req("util", "0.2")]),
538+
pkg!(("util", "0.1.0")),
539+
pkg!(("util", "0.2.0")),
540+
pkg!(("util", "0.3.0")),
541+
]);
542+
543+
let res = resolve_with_global_context_raw(
544+
vec![
545+
dep_req("foo", "1.0.0"),
546+
dep_req("bar", "1.0.0"),
547+
dep_req("util", "0.*"),
548+
],
549+
&reg,
550+
&GlobalContext::default().unwrap(),
551+
)
552+
.unwrap();
553+
554+
// In this case, 0.1.0, 0.2.0 and 0.3.0 satisfy root. It should pick the highest
555+
// version that exists in the dependency tree.
556+
assert_eq!(
557+
res.deps(pkg_id("root")).skip(2).next().unwrap().0,
558+
("util", "0.2.0").to_pkgid()
559+
);
560+
561+
let res = res.sort();
562+
563+
assert_same(
564+
&res,
565+
&names(&[
566+
("root", "1.0.0"),
567+
("foo", "1.0.0"),
568+
("bar", "1.0.0"),
569+
("car", "1.0.0"),
570+
("util", "0.1.0"),
571+
("util", "0.2.0"),
572+
]),
573+
);
574+
}
575+
532576
#[test]
533577
fn test_range_major() {
534578
let reg = registry(vec![

0 commit comments

Comments
 (0)