Skip to content

Commit 8667272

Browse files
authored
Small test cleanup (#43831)
Deconflict some identifiers, make test run properly in Main module.
1 parent dd0c14b commit 8667272

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

test/compiler/codegen.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,16 @@ macro aliasscope(body)
364364
end)
365365
end
366366

367-
struct Const{T<:Array}
367+
struct ConstAliasScope{T<:Array}
368368
a::T
369369
end
370370

371-
@eval Base.getindex(A::Const, i1::Int) = Core.const_arrayref($(Expr(:boundscheck)), A.a, i1)
372-
@eval Base.getindex(A::Const, i1::Int, i2::Int, I::Int...) = (@inline; Core.const_arrayref($(Expr(:boundscheck)), A.a, i1, i2, I...))
371+
@eval Base.getindex(A::ConstAliasScope, i1::Int) = Core.const_arrayref($(Expr(:boundscheck)), A.a, i1)
372+
@eval Base.getindex(A::ConstAliasScope, i1::Int, i2::Int, I::Int...) = (@inline; Core.const_arrayref($(Expr(:boundscheck)), A.a, i1, i2, I...))
373373

374374
function foo31018!(a, b)
375375
@aliasscope for i in eachindex(a, b)
376-
a[i] = Const(b)[i]
376+
a[i] = ConstAliasScope(b)[i]
377377
end
378378
end
379379
io = IOBuffer()
@@ -588,7 +588,9 @@ struct A40855
588588
b::Union{Nothing, Int}
589589
end
590590
g() = string(A40855(X40855, 1))
591-
@test g() == "$(@__MODULE__).A40855($(@__MODULE__).X40855, 1)"
591+
let mod_prefix = (@__MODULE__) == Core.Main ? "" : "$(@__MODULE__)."
592+
@test g() == "$(mod_prefix)A40855($(mod_prefix)X40855, 1)"
593+
end
592594

593595
# issue #40612
594596
f40612(a, b) = a|b === a|b

test/compiler/inline.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -667,41 +667,41 @@ begin
667667
end
668668
@noinline a::Point +ₚ b::Point = Point(a.x + b.x, a.y + b.y)
669669

670-
function compute(n)
670+
function compute_idem_n(n)
671671
a = Point(1.5, 2.5)
672672
b = Point(2.25, 4.75)
673673
for i in 0:(n-1)
674674
a = @inline (a +ₚ b) +ₚ b
675675
end
676676
return a.x, a.y
677677
end
678-
let src = code_typed1(compute, (Int,))
678+
let src = code_typed1(compute_idem_n, (Int,))
679679
@test count(isinvoke(:+ₚ), src.code) == 0 # successful inlining
680680
end
681681

682-
function compute(n)
682+
function compute_idem_n(n)
683683
a = Point(1.5, 2.5)
684684
b = Point(2.25, 4.75)
685685
for i in 0:(n-1)
686686
a = (a +ₚ b) +ₚ b
687687
end
688688
return a.x, a.y
689689
end
690-
let src = code_typed1(compute, (Int,))
690+
let src = code_typed1(compute_idem_n, (Int,))
691691
@test count(isinvoke(:+ₚ), src.code) == 2 # no inlining
692692
end
693693

694-
compute(42) # this execution should discard the cache of `+ₚ` since it's declared as `@noinline`
694+
compute_idem_n(42) # this execution should discard the cache of `+ₚ` since it's declared as `@noinline`
695695

696-
function compute(n)
696+
function compute_idem_n(n)
697697
a = Point(1.5, 2.5)
698698
b = Point(2.25, 4.75)
699699
for i in 0:(n-1)
700700
@inline a = (a +ₚ b) +ₚ b
701701
end
702702
return a.x, a.y
703703
end
704-
let src = code_typed1(compute, (Int,))
704+
let src = code_typed1(compute_idem_n, (Int,))
705705
@test count(isinvoke(:+ₚ), src.code) == 0 # no inlining !?
706706
end
707707
end

test/compiler/irpasses.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,15 @@ struct Point
284284
y::Float64
285285
end
286286
#=@inline=# add(a::Point, b::Point) = Point(a.x + b.x, a.y + b.y)
287-
function compute()
287+
function compute_points()
288288
a = Point(1.5, 2.5)
289289
b = Point(2.25, 4.75)
290290
for i in 0:(100000000-1)
291291
a = add(add(a, b), b)
292292
end
293293
a.x, a.y
294294
end
295-
let src = code_typed1(compute)
295+
let src = code_typed1(compute_points)
296296
@test !any(isnew, src.code)
297297
end
298298

0 commit comments

Comments
 (0)