|
65 | 65 | # Check that the result of direct evaluation agrees with selective evaluation
|
66 | 66 | Core.eval(ModEval, ex)
|
67 | 67 | isrequired = lines_required(:x, src, edges)
|
68 |
| - @test sum(isrequired) == 1 |
| 68 | + @test sum(isrequired) == 1 + isdefined(Core, :get_binding_type) * 3 # get_binding_type + convert + typeassert |
69 | 69 | selective_eval_fromstart!(frame, isrequired)
|
70 | 70 | @test ModSelective.x === ModEval.x
|
71 | 71 | @test allmissing(ModSelective, (:y, :z, :a, :b, :k))
|
|
204 | 204 | frame = Frame(ModSelective, ex)
|
205 | 205 | src = frame.framecode.src
|
206 | 206 | edges = CodeEdges(src)
|
207 |
| - isrequired = minimal_evaluation(stmt->(LoweredCodeUtils.ismethod3(stmt)&&stmt.args[1]===:NoParam,false), src, edges) # initially mark only the constructor |
| 207 | + isrequired = minimal_evaluation(stmt->(LoweredCodeUtils.ismethod_with_name(src, stmt, "NoParam"),false), src, edges) # initially mark only the constructor |
208 | 208 | selective_eval_fromstart!(frame, isrequired, true)
|
209 | 209 | @test isa(ModSelective.NoParam(), ModSelective.NoParam)
|
210 | 210 | # Parametric
|
|
216 | 216 | frame = Frame(ModSelective, ex)
|
217 | 217 | src = frame.framecode.src
|
218 | 218 | edges = CodeEdges(src)
|
219 |
| - isrequired = minimal_evaluation(stmt->(LoweredCodeUtils.ismethod3(stmt)&&stmt.args[1]===:Struct,false), src, edges) # initially mark only the constructor |
| 219 | + isrequired = minimal_evaluation(stmt->(LoweredCodeUtils.ismethod_with_name(src, stmt, "Struct"),false), src, edges) # initially mark only the constructor |
220 | 220 | selective_eval_fromstart!(frame, isrequired, true)
|
221 | 221 | @test isa(ModSelective.Struct([1,2,3]), ModSelective.Struct{Int})
|
222 | 222 | # Keyword constructor (this generates :copyast expressions)
|
@@ -341,29 +341,42 @@ end
|
341 | 341 | str = String(take!(io))
|
342 | 342 | @test occursin(r"slot 1:\n preds: ssas: \[\d+, \d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d+, \d+\]", str)
|
343 | 343 | @test occursin(r"succs: ssas: ∅, slots: \[\d+\], names: ∅;", str)
|
344 |
| - @test occursin(r"s:\n preds: ssas: \[\d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d, \d+\]", str) |
345 |
| - @test occursin(r"\d+ preds: ssas: \[\d+\], slots: ∅, names: \[:s\];\n\d+ succs: ssas: ∅, slots: ∅, names: \[:s\];", str) |
| 344 | + @test occursin(r"s:\n preds: ssas: \[\d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d, \d+\]", str) || |
| 345 | + occursin(r"s:\n preds: ssas: \[\d+, \d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d, \d+\]", str) # with global var inference |
| 346 | + if Base.VERSION < v"1.8" # changed by global var inference |
| 347 | + @test occursin(r"\d+ preds: ssas: \[\d+\], slots: ∅, names: \[:s\];\n\d+ succs: ssas: ∅, slots: ∅, names: \[:s\];", str) |
| 348 | + end |
346 | 349 | LoweredCodeUtils.print_with_code(io, src, cl)
|
347 | 350 | str = String(take!(io))
|
348 | 351 | if isdefined(Base.IRShow, :show_ir_stmt)
|
349 | 352 | @test occursin(r"slot 1:\n preds: ssas: \[\d+, \d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d+, \d+\]", str)
|
350 | 353 | @test occursin("# see name s", str)
|
351 | 354 | @test occursin("# see slot 1", str)
|
352 |
| - @test occursin(r"# preds: ssas: \[\d+\], slots: ∅, names: \[:s\]; succs: ssas: ∅, slots: ∅, names: \[:s\];", str) |
| 355 | + if Base.VERSION < v"1.8" # changed by global var inference |
| 356 | + @test occursin(r"# preds: ssas: \[\d+\], slots: ∅, names: \[:s\]; succs: ssas: ∅, slots: ∅, names: \[:s\];", str) |
| 357 | + end |
353 | 358 | else
|
354 | 359 | @test occursin("No IR statement printer", str)
|
355 | 360 | end
|
356 | 361 | # CodeEdges
|
357 | 362 | edges = CodeEdges(src)
|
358 | 363 | show(io, edges)
|
359 | 364 | str = String(take!(io))
|
360 |
| - @test occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+\], and used by \[\d+, \d+, \d+\]", str) |
361 |
| - @test count(occursin("statement $i depends on [1, $(i-1), $(i+1)] and is used by [1, $(i+1)]", str) for i = 1:length(src.code)) == 1 |
| 365 | + @test occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+\], and used by \[\d+, \d+, \d+\]", str) || |
| 366 | + occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+, \d+\], and used by \[\d+, \d+, \d+\]", str) # global var inference |
| 367 | + if Base.VERSION < v"1.9" |
| 368 | + @test (count(occursin("statement $i depends on [1, $(i-1), $(i+1)] and is used by [1, $(i+1)]", str) for i = 1:length(src.code)) == 1) || |
| 369 | + (count(occursin("statement $i depends on [4, $(i-1), $(i+4)] and is used by [$(i+2)]", str) for i = 1:length(src.code)) == 1) |
| 370 | + end |
362 | 371 | LoweredCodeUtils.print_with_code(io, src, edges)
|
363 | 372 | str = String(take!(io))
|
364 | 373 | if isdefined(Base.IRShow, :show_ir_stmt)
|
365 |
| - @test occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+\], and used by \[\d+, \d+, \d+\]", str) |
366 |
| - @test count(occursin("preds: [1, $(i-1), $(i+1)], succs: [1, $(i+1)]", str) for i = 1:length(src.code)) == 1 |
| 374 | + @test occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+\], and used by \[\d+, \d+, \d+\]", str) || |
| 375 | + occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+, \d+\], and used by \[\d+, \d+, \d+\]", str) |
| 376 | + if Base.VERSION < v"1.9" |
| 377 | + @test (count(occursin("preds: [1, $(i-1), $(i+1)], succs: [1, $(i+1)]", str) for i = 1:length(src.code)) == 1) || |
| 378 | + (count(occursin("preds: [4, $(i-1), $(i+4)], succs: [$(i+2)]", str) for i = 1:length(src.code)) == 1) # global var inference |
| 379 | + end |
367 | 380 | else
|
368 | 381 | @test occursin("No IR statement printer", str)
|
369 | 382 | end
|
|
373 | 386 | LoweredCodeUtils.print_with_code(io, frame, edges)
|
374 | 387 | str = String(take!(io))
|
375 | 388 | if isdefined(Base.IRShow, :show_ir_stmt)
|
376 |
| - @test occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+\], and used by \[\d+, \d+, \d+\]", str) |
377 |
| - @test count(occursin("preds: [1, $(i-1), $(i+1)], succs: [1, $(i+1)]", str) for i = 1:length(src.code)) == 1 |
| 389 | + @test occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+\], and used by \[\d+, \d+, \d+\]", str) || |
| 390 | + occursin(r"s: assigned on \[\d, \d+\], depends on \[\d, \d+\], and used by \[\d+, \d+, \d+\]", str) # global var inference |
| 391 | + if Base.VERSION < v"1.9" |
| 392 | + @test (count(occursin("preds: [1, $(i-1), $(i+1)], succs: [1, $(i+1)]", str) for i = 1:length(src.code)) == 1) || |
| 393 | + (count(occursin("preds: [4, $(i-1), $(i+4)], succs: [$(i+2)]", str) for i = 1:length(src.code)) == 1) # global var inference |
| 394 | + end |
378 | 395 | else
|
379 | 396 | @test occursin("No IR statement printer", str)
|
380 | 397 | end
|
|
0 commit comments