MCPcopy Create free account
hub / github.com/argumentcomputer/ix / test_analyze_simple

Function test_analyze_simple

crates/ixon/src/sharing.rs:963–983  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

961
962 #[test]
963 fn test_analyze_simple() {
964 // Create a simple expression: App(Var(0), Var(0))
965 // Var(0) should have usage_count = 2
966 let var0 = Expr::var(0);
967 let app = Expr::app(var0.clone(), var0);
968
969 let (info_map, ptr_to_hash, _topo_order) = analyze_block(&[app], false);
970
971 // Should have 2 unique subterms: Var(0) and App(Var(0), Var(0))
972 assert_eq!(info_map.len(), 2);
973
974 // Find Var(0) info - it should have usage_count = 2
975 let var_hash = ptr_to_hash.values().find(|h| {
976 info_map
977 .get(*h)
978 .is_some_and(|info| matches!(info.expr.as_ref(), Expr::Var(0)))
979 });
980 assert!(var_hash.is_some());
981 let var_info = info_map.get(var_hash.unwrap()).unwrap();
982 assert_eq!(var_info.usage_count, 2);
983 }
984
985 #[test]
986 fn test_decide_sharing_simple() {

Callers

nothing calls this directly

Calls 6

analyze_blockFunction · 0.85
varFunction · 0.50
appFunction · 0.50
cloneMethod · 0.45
findMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected