MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_linearise

Function test_linearise

crates/vm/src/builtins/type.rs:2943–2981  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2941
2942 #[test]
2943 fn test_linearise() {
2944 let context = Context::genesis();
2945 let object = context.types.object_type.to_owned();
2946 let type_type = context.types.type_type.to_owned();
2947
2948 let a = PyType::new_heap(
2949 "A",
2950 vec![object.clone()],
2951 PyAttributes::default(),
2952 Default::default(),
2953 type_type.clone(),
2954 context,
2955 )
2956 .unwrap();
2957 let b = PyType::new_heap(
2958 "B",
2959 vec![object.clone()],
2960 PyAttributes::default(),
2961 Default::default(),
2962 type_type,
2963 context,
2964 )
2965 .unwrap();
2966
2967 assert_eq!(
2968 map_ids(linearise_mro(vec![
2969 vec![object.clone()],
2970 vec![object.clone()]
2971 ])),
2972 map_ids(Ok(vec![object.clone()]))
2973 );
2974 assert_eq!(
2975 map_ids(linearise_mro(vec![
2976 vec![a.clone(), object.clone()],
2977 vec![b.clone(), object.clone()],
2978 ])),
2979 map_ids(Ok(vec![a, b, object]))
2980 );
2981 }
2982}

Callers

nothing calls this directly

Calls 3

to_ownedMethod · 0.45
unwrapMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected