|
199 | 199 | b = @allocated MA.operate(LinearAlgebra.dot, x, y) |
200 | 200 | @test a == b |
201 | 201 | end |
| 202 | + |
| 203 | +@testset "test_multiply_expr_MA_Zero" begin |
| 204 | + x = DummyBigInt(1) |
| 205 | + f = DummyBigInt(2) |
| 206 | + @test MA.@rewrite( |
| 207 | + f * sum(x for i in 1:0), |
| 208 | + move_factors_into_sums = false |
| 209 | + ) == MA.Zero() |
| 210 | + @test MA.@rewrite( |
| 211 | + sum(x for i in 1:0) * f, |
| 212 | + move_factors_into_sums = false |
| 213 | + ) == MA.Zero() |
| 214 | + @test MA.@rewrite( |
| 215 | + -f * sum(x for i in 1:0), |
| 216 | + move_factors_into_sums = false |
| 217 | + ) == MA.Zero() |
| 218 | + @test MA.@rewrite( |
| 219 | + sum(x for i in 1:0) * -f, |
| 220 | + move_factors_into_sums = false |
| 221 | + ) == MA.Zero() |
| 222 | + @test MA.@rewrite( |
| 223 | + (f + f) * sum(x for i in 1:0), |
| 224 | + move_factors_into_sums = false |
| 225 | + ) == MA.Zero() |
| 226 | + @test MA.@rewrite( |
| 227 | + sum(x for i in 1:0) * (f + f), |
| 228 | + move_factors_into_sums = false |
| 229 | + ) == MA.Zero() |
| 230 | + @test MA.@rewrite( |
| 231 | + -[f] * sum(x for i in 1:0), |
| 232 | + move_factors_into_sums = false |
| 233 | + ) == MA.Zero() |
| 234 | + @test MA.@rewrite( |
| 235 | + sum(x for i in 1:0) * -[f], |
| 236 | + move_factors_into_sums = false |
| 237 | + ) == MA.Zero() |
| 238 | + @test MA.isequal_canonical( |
| 239 | + MA.@rewrite(f + sum(x for i in 1:0), move_factors_into_sums = false), |
| 240 | + f, |
| 241 | + ) |
| 242 | + @test MA.isequal_canonical( |
| 243 | + MA.@rewrite(sum(x for i in 1:0) + f, move_factors_into_sums = false), |
| 244 | + f, |
| 245 | + ) |
| 246 | + @test MA.isequal_canonical( |
| 247 | + MA.@rewrite(-f + sum(x for i in 1:0), move_factors_into_sums = false), |
| 248 | + -f, |
| 249 | + ) |
| 250 | + @test MA.isequal_canonical( |
| 251 | + MA.@rewrite(sum(x for i in 1:0) + -f, move_factors_into_sums = false), |
| 252 | + -f, |
| 253 | + ) |
| 254 | + @test MA.isequal_canonical( |
| 255 | + MA.@rewrite( |
| 256 | + (f + f) + sum(x for i in 1:0), |
| 257 | + move_factors_into_sums = false |
| 258 | + ), |
| 259 | + f + f, |
| 260 | + ) |
| 261 | + @test MA.isequal_canonical( |
| 262 | + MA.@rewrite( |
| 263 | + sum(x for i in 1:0) + (f + f), |
| 264 | + move_factors_into_sums = false |
| 265 | + ), |
| 266 | + f + f, |
| 267 | + ) |
| 268 | +end |
0 commit comments