Test stmt_expr_mutator
()
| 309 | |
| 310 | |
| 311 | def test_complex_mutator(): |
| 312 | """Test stmt_expr_mutator""" |
| 313 | x = Var("x", dtype="int32") |
| 314 | y = Var("y", dtype="int32") |
| 315 | |
| 316 | # Expression with Add operations |
| 317 | expr = Add(x, y) |
| 318 | stmt = Evaluate(expr) |
| 319 | |
| 320 | mutator = ComplexMutator() |
| 321 | result = mutator.visit_stmt(stmt) |
| 322 | print(type(mutator)) |
| 323 | |
| 324 | assert mutator.modifications == 1 # One Add operation modified |
| 325 | assert isinstance(result, Evaluate) |
| 326 | |
| 327 | # Check that the expression was modified |
| 328 | modified_expr = result.value |
| 329 | assert isinstance(modified_expr, Add) |
| 330 | assert isinstance(modified_expr.a, Mul) # First operand should be multiplied by 2 |
| 331 | |
| 332 | |
| 333 | def test_different_expr_types(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…