Skip to content

Commit d90c2e2

Browse files
author
Priynsh
authored
Added test for resolving array references in exprresolve (#56471)
added test to take care of non-real-index handling while resolving array references in exprresolve to test julia/base/cartesian.jl - line 427 to 432
1 parent efc43cb commit d90c2e2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/cartesian.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
@test Base.Cartesian.exprresolve(:(1 + 3)) == 4
3+
44
ex = Base.Cartesian.exprresolve(:(if 5 > 4; :x; else :y; end))
55
@test ex.args[2] == QuoteNode(:x)
66

77
@test Base.Cartesian.lreplace!("val_col", Base.Cartesian.LReplace{String}(:col, "col", 1)) == "val_1"
88
@test Base.setindex(CartesianIndex(1,5,4),3,2) == CartesianIndex(1, 3, 4)
9-
9+
@testset "Expression Resolve" begin
10+
@test Base.Cartesian.exprresolve(:(1 + 3)) == 4
11+
ex1 = Expr(:ref, [1, 2, 3], 2)
12+
result1 = Base.Cartesian.exprresolve(ex1)
13+
@test result1 == 2
14+
ex2 = Expr(:ref, [1, 2, 3], "non-real-index")
15+
result2 = Base.Cartesian.exprresolve(ex2)
16+
@test result2 == ex2
17+
end
1018
@testset "CartesianIndices constructions" begin
1119
@testset "AbstractUnitRange" begin
1220
for oinds in [

0 commit comments

Comments
 (0)