()
| 1030 | |
| 1031 | #[test] |
| 1032 | fn test_build_sharing_vec() { |
| 1033 | // Create expression with a shared subterm: App(App(var0, var0), var0) |
| 1034 | // var0 appears 3 times, should be shared |
| 1035 | let var0 = Expr::var(0); |
| 1036 | let app1 = Expr::app(var0.clone(), var0.clone()); |
| 1037 | let app2 = Expr::app(app1, var0); |
| 1038 | |
| 1039 | let (info_map, ptr_to_hash, topo_order) = |
| 1040 | analyze_block(std::slice::from_ref(&app2), false); |
| 1041 | let shared = decide_sharing(&info_map, &topo_order); |
| 1042 | |
| 1043 | // If var0 is shared, verify it |
| 1044 | if !shared.is_empty() { |
| 1045 | let (rewritten, sharing_vec) = build_sharing_vec( |
| 1046 | &[app2], |
| 1047 | &shared, |
| 1048 | &ptr_to_hash, |
| 1049 | &info_map, |
| 1050 | &topo_order, |
| 1051 | ); |
| 1052 | |
| 1053 | // Sharing vec should have the shared expressions |
| 1054 | assert_eq!(sharing_vec.len(), shared.len()); |
| 1055 | |
| 1056 | // Rewritten should have at least one Share reference if sharing happened |
| 1057 | assert_eq!(rewritten.len(), 1); |
| 1058 | } |
| 1059 | } |
| 1060 | |
| 1061 | #[test] |
| 1062 | fn test_roundtrip_with_sharing() { |
nothing calls this directly
no test coverage detected