RecursiveEq should return True for two distinct but structurally equivalent cyclic graphs.
()
| 136 | |
| 137 | |
| 138 | def test_recursive_eq_mutual_cycle() -> None: |
| 139 | """RecursiveEq should return True for two distinct but structurally equivalent cyclic graphs.""" |
| 140 | v_map = tvm_ffi.Map({}) |
| 141 | |
| 142 | def make_cyclic(v_i64: int) -> object: |
| 143 | o = tvm_ffi.testing.create_object( |
| 144 | "testing.TestObjectDerived", |
| 145 | v_i64=v_i64, |
| 146 | v_f64=0.0, |
| 147 | v_str="x", |
| 148 | v_map=v_map, |
| 149 | v_array=tvm_ffi.Array([]), |
| 150 | ) |
| 151 | o.v_array = tvm_ffi.Array([o]) # type: ignore[unresolved-attribute] |
| 152 | return o |
| 153 | |
| 154 | a = make_cyclic(42) |
| 155 | b = make_cyclic(42) |
| 156 | # Two distinct objects with identical structure and self-referencing cycles. |
| 157 | assert _recursive_eq(a, b) |
| 158 | # Different content should not be equal. |
| 159 | c = make_cyclic(99) |
| 160 | assert not _recursive_eq(a, c) |
nothing calls this directly
no test coverage detected