Skip to content

Commit 9e469a8

Browse files
committed
Tweaks to test implementation (not content)
Mostly, don't make inference pick container types.
1 parent ce64427 commit 9e469a8

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

test/runtests.jl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -198,24 +198,24 @@ end
198198

199199
@testset "OffsetVector" begin
200200
# initialization
201-
one_based_axes = [
202-
(Base.OneTo(4), ),
203-
(1:4, ),
204-
(CartesianIndex(1):CartesianIndex(4), ),
205-
(IdentityUnitRange(1:4), ),
206-
(IdOffsetRange(1:4),),
201+
one_based_axes = Any[
202+
(Base.OneTo(4), ),
203+
(1:4, ),
204+
(CartesianIndex(1):CartesianIndex(4), ),
205+
(IdentityUnitRange(1:4), ),
206+
(IdOffsetRange(1:4),),
207207
(IdOffsetRange(3:6, -2),)
208208
]
209209

210-
offset_axes = [
211-
(-1:2, ),
212-
(CartesianIndex(-1):CartesianIndex(2), ),
213-
(IdentityUnitRange(-1:2), ),
214-
(IdOffsetRange(-1:2),),
210+
offset_axes = Any[
211+
(-1:2, ),
212+
(CartesianIndex(-1):CartesianIndex(2), ),
213+
(IdentityUnitRange(-1:2), ),
214+
(IdOffsetRange(-1:2),),
215215
(IdOffsetRange(3:6, -4),)
216216
]
217217

218-
for inds in [size.(one_based_axes[1], 1), one_based_axes...]
218+
for inds in Any[size.(one_based_axes[1], 1), one_based_axes...]
219219
# test indices API
220220
a = OffsetVector{Float64}(undef, inds)
221221
@test eltype(a) === Float64
@@ -248,7 +248,7 @@ end
248248
a = OffsetVector{Missing}(missing, inds)
249249
@test axes(a) === ax
250250

251-
for (T, t) in [(Nothing, nothing), (Missing, missing)]
251+
for (T, t) in Any[(Nothing, nothing), (Missing, missing)]
252252
a = OffsetVector{Union{T, Vector{Int}}}(undef, inds)
253253
@test !isassigned(a, -1)
254254
@test eltype(a) === Union{T, Vector{Int}}
@@ -282,7 +282,7 @@ end
282282
# nested offset array
283283
a = rand(4)
284284
oa = OffsetArray(a, -1)
285-
for inds in [.-oa.offsets, one_based_axes...]
285+
for inds in Any[.-oa.offsets, one_based_axes...]
286286
ooa = OffsetArray(oa, inds)
287287
@test typeof(parent(ooa)) <: Vector
288288
@test ooa === OffsetArray(oa, inds...) === OffsetVector(oa, inds) === OffsetVector(oa, inds...)
@@ -324,8 +324,8 @@ end
324324

325325
@testset "OffsetMatrix" begin
326326
# initialization
327-
328-
one_based_axes = [
327+
328+
one_based_axes = Any[
329329
(Base.OneTo(4), Base.OneTo(3)),
330330
(1:4, 1:3),
331331
(CartesianIndex(1, 1):CartesianIndex(4, 3), ),
@@ -338,7 +338,7 @@ end
338338
(IdOffsetRange(3:6, -2), 1:3),
339339
]
340340

341-
offset_axes = [
341+
offset_axes = Any[
342342
(-1:2, 0:2),
343343
(CartesianIndex(-1, 0):CartesianIndex(2, 2), ),
344344
(-1:2, CartesianIndex(0):CartesianIndex(2)),
@@ -351,7 +351,7 @@ end
351351
(IdOffsetRange(-1:2), 0:2),
352352
]
353353

354-
for inds in [size.(one_based_axes[1], 1), one_based_axes...]
354+
for inds in Any[size.(one_based_axes[1], 1), one_based_axes...]
355355
# test API
356356
a = OffsetMatrix{Float64}(undef, inds)
357357
ax = (IdOffsetRange(Base.OneTo(4), 0), IdOffsetRange(Base.OneTo(3), 0))
@@ -385,7 +385,7 @@ end
385385
a = OffsetMatrix{Missing}(missing, inds)
386386
@test axes(a) === ax
387387

388-
for (T, t) in [(Nothing, nothing), (Missing, missing)]
388+
for (T, t) in Any[(Nothing, nothing), (Missing, missing)]
389389
a = OffsetMatrix{Union{T, Vector{Int}}}(undef, inds)
390390
@test !isassigned(a, -1, 0)
391391
@test eltype(a) === Union{T, Vector{Int}}
@@ -421,7 +421,7 @@ end
421421
# nested offset array
422422
a = rand(4, 3)
423423
oa = OffsetArray(a, -1, -2)
424-
for inds in [.-oa.offsets, one_based_axes...]
424+
for inds in Any[.-oa.offsets, one_based_axes...]
425425
ooa = OffsetArray(oa, inds)
426426
@test ooa === OffsetArray(oa, inds...) === OffsetMatrix(oa, inds) === OffsetMatrix(oa, inds...)
427427
@test typeof(parent(ooa)) <: Matrix
@@ -496,13 +496,13 @@ end
496496
@testset "convenience constructors" begin
497497
ax = (2:3, 4:5)
498498

499-
for f in [zeros, ones]
499+
for f in (zeros, ones)
500500
a = f(Float64, ax)
501501
@test axes(a) == ax
502502
@test eltype(a) == Float64
503503
end
504504

505-
for f in [trues, falses]
505+
for f in (trues, falses)
506506
a = f(ax)
507507
@test axes(a) == ax
508508
@test eltype(a) == Bool
@@ -573,7 +573,7 @@ end
573573
end
574574
@testset "TupleOfRanges" begin
575575
Base.to_indices(A, inds, t::Tuple{TupleOfRanges{N}}) where {N} = t
576-
OffsetArrays.AxisConversionStyle(::Type{TupleOfRanges{N}}) where {N} =
576+
OffsetArrays.AxisConversionStyle(::Type{TupleOfRanges{N}}) where {N} =
577577
OffsetArrays.TupleOfRanges()
578578

579579
Base.convert(::Type{Tuple{Vararg{AbstractUnitRange{Int}}}}, t::TupleOfRanges) = t.x
@@ -584,7 +584,7 @@ end
584584
@test axes(oa) == inds.x
585585
end
586586
@testset "NewColon" begin
587-
Base.to_indices(A, inds, t::Tuple{NewColon,Vararg{Any}}) =
587+
Base.to_indices(A, inds, t::Tuple{NewColon,Vararg{Any}}) =
588588
(_uncolon(inds, t), to_indices(A, Base.tail(inds), Base.tail(t))...)
589589

590590
_uncolon(inds::Tuple{}, I::Tuple{NewColon, Vararg{Any}}) = OneTo(1)
@@ -598,7 +598,7 @@ end
598598

599599
@testset "Offset range construction" begin
600600
r = -2:5
601-
for AT in [OffsetArray, OffsetVector]
601+
for AT in Any[OffsetArray, OffsetVector]
602602
y = AT(r, r)
603603
@test axes(y) == (r,)
604604
@test step(y) == step(r)
@@ -1236,8 +1236,8 @@ end
12361236
@test sort(A, dims = 1) == OffsetArray(sort(parent(A), dims = 1), A.offsets)
12371237
@test sort(A, dims = 2) == OffsetArray(sort(parent(A), dims = 2), A.offsets)
12381238

1239-
@test mapslices(v->sort(v), A, dims = 1) == OffsetArray(mapslices(v->sort(v), parent(A), dims = 1), A.offsets)
1240-
@test mapslices(v->sort(v), A, dims = 2) == OffsetArray(mapslices(v->sort(v), parent(A), dims = 2), A.offsets)
1239+
@test mapslices(sort, A, dims = 1) == OffsetArray(mapslices(sort, parent(A), dims = 1), A.offsets)
1240+
@test mapslices(sort, A, dims = 2) == OffsetArray(mapslices(sort, parent(A), dims = 2), A.offsets)
12411241
end
12421242

12431243
@testset "rot/reverse" begin

0 commit comments

Comments
 (0)