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

Function linear_chain

src/toposort.rs:260–282  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

258
259 #[test]
260 fn linear_chain() {
261 // C extends B extends A
262 let a = make_class("A");
263 let mut b = make_class("B");
264 b.parent_class = Some(crate::atom::atom("A"));
265 let mut c = make_class("C");
266 c.parent_class = Some(crate::atom::atom("B"));
267
268 let classes = vec![
269 ("C".to_string(), &c),
270 ("B".to_string(), &b),
271 ("A".to_string(), &a),
272 ];
273
274 let sorted = toposort_classes(classes.into_iter());
275
276 let pos_a = sorted.iter().position(|s| s == "A").unwrap();
277 let pos_b = sorted.iter().position(|s| s == "B").unwrap();
278 let pos_c = sorted.iter().position(|s| s == "C").unwrap();
279
280 assert!(pos_a < pos_b, "A must come before B");
281 assert!(pos_b < pos_c, "B must come before C");
282 }
283
284 #[test]
285 fn trait_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