MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / diamond_inheritance

Function diamond_inheritance

src/toposort.rs:370–399  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

368
369 #[test]
370 fn diamond_inheritance() {
371 // D extends B and C, both extend A.
372 let a = make_class("A");
373 let mut b = make_class("B");
374 b.parent_class = Some(crate::atom::atom("A"));
375 let mut c = make_class("C");
376 c.parent_class = Some(crate::atom::atom("A"));
377 let mut d = make_class("D");
378 d.parent_class = Some(crate::atom::atom("B"));
379 d.interfaces = vec![crate::atom::atom("C")];
380
381 let classes = vec![
382 ("D".to_string(), &d),
383 ("C".to_string(), &c),
384 ("B".to_string(), &b),
385 ("A".to_string(), &a),
386 ];
387
388 let sorted = toposort_classes(classes.into_iter());
389
390 let pos_a = sorted.iter().position(|s| s == "A").unwrap();
391 let pos_b = sorted.iter().position(|s| s == "B").unwrap();
392 let pos_c = sorted.iter().position(|s| s == "C").unwrap();
393 let pos_d = sorted.iter().position(|s| s == "D").unwrap();
394
395 assert!(pos_a < pos_b, "A must come before B");
396 assert!(pos_a < pos_c, "A must come before C");
397 assert!(pos_b < pos_d, "B must come before D");
398 assert!(pos_c < pos_d, "C must come before D");
399 }
400
401 #[test]
402 fn extends_generics_dependency() {

Callers

nothing calls this directly

Calls 6

atomFunction · 0.85
toposort_classesFunction · 0.85
into_iterMethod · 0.80
iterMethod · 0.80
make_classFunction · 0.70
unwrapMethod · 0.45

Tested by

no test coverage detected