Assert that two module IRs are the same (*). * Or rather, as much as we care about preserving across serialization. We drop the actual IR bodies of functions but try to preserve everything else.
(ir1: ModuleIR, ir2: ModuleIR)
| 70 | |
| 71 | |
| 72 | def assert_modules_same(ir1: ModuleIR, ir2: ModuleIR) -> None: |
| 73 | """Assert that two module IRs are the same (*). |
| 74 | |
| 75 | * Or rather, as much as we care about preserving across |
| 76 | serialization. We drop the actual IR bodies of functions but try |
| 77 | to preserve everything else. |
| 78 | """ |
| 79 | assert ir1.fullname == ir2.fullname |
| 80 | |
| 81 | assert ir1.imports == ir2.imports |
| 82 | |
| 83 | for cls1, cls2 in zip(ir1.classes, ir2.classes): |
| 84 | assert_blobs_same(get_dict(cls1), get_dict(cls2), (ir1.fullname, cls1.fullname)) |
| 85 | |
| 86 | for fn1, fn2 in zip(ir1.functions, ir2.functions): |
| 87 | assert_blobs_same( |
| 88 | get_function_dict(fn1), get_function_dict(fn2), (ir1.fullname, fn1.fullname) |
| 89 | ) |
| 90 | assert_blobs_same(get_dict(fn1.decl), get_dict(fn2.decl), (ir1.fullname, fn1.fullname)) |
| 91 | |
| 92 | assert_blobs_same(ir1.final_names, ir2.final_names, (ir1.fullname, "final_names")) |
| 93 | |
| 94 | assert ir1.dependencies == ir2.dependencies |
| 95 | |
| 96 | |
| 97 | def check_serialization_roundtrip(irs: dict[str, ModuleIR]) -> None: |
no test coverage detected
searching dependent graphs…