|
1 | 1 | # This file is a part of Julia. License is MIT: https://julialang.org/license
|
2 | 2 |
|
| 3 | +isdefined(Main, :OffsetArrays) || @eval Main include("testhelpers/OffsetArrays.jl") |
| 4 | +using .Main.OffsetArrays |
| 5 | + |
3 | 6 | struct BitPerm_19352
|
4 | 7 | p::NTuple{8,UInt8}
|
5 | 8 | function BitPerm(p::NTuple{8,UInt8})
|
|
598 | 601 | # issue #38837
|
599 | 602 | f38837(xs) = map((F,x)->F(x), (Float32, Float64), xs)
|
600 | 603 | @test @inferred(f38837((1,2))) === (1.0f0, 2.0)
|
| 604 | + |
| 605 | +@testset "indexing with UnitRanges" begin |
| 606 | + f(t) = t[3:end-2] |
| 607 | + @test @inferred(f(Tuple(1:10))) === Tuple(3:8) |
| 608 | + @test @inferred(f((true, 2., 3, 4f0, 0x05, 6, 7.))) === (3, 4f0, 0x05) |
| 609 | + |
| 610 | + f(t) = t[Base.OneTo(5)] |
| 611 | + @test @inferred(f(Tuple(1:10))) === Tuple(1:5) |
| 612 | + @test @inferred(f((true, 2., 3, 4f0, 0x05, 6, 7.))) === (true, 2., 3, 4f0, 0x05) |
| 613 | + |
| 614 | + @test @inferred((t -> t[1:end])(Tuple(1:15))) === Tuple(1:15) |
| 615 | + @test @inferred((t -> t[2:end])(Tuple(1:15))) === Tuple(2:15) |
| 616 | + @test @inferred((t -> t[3:end])(Tuple(1:15))) === Tuple(3:15) |
| 617 | + @test @inferred((t -> t[1:end-1])(Tuple(1:15))) === Tuple(1:14) |
| 618 | + @test @inferred((t -> t[1:end-2])(Tuple(1:15))) === Tuple(1:13) |
| 619 | + @test @inferred((t -> t[3:2])(Tuple(1:15))) === () |
| 620 | + |
| 621 | + @test_throws BoundsError (1, 2)[1:4] |
| 622 | + @test_throws BoundsError (1, 2)[0:2] |
| 623 | + @test_throws ArgumentError (1, 2)[OffsetArrays.IdOffsetRange(1:2, -1)] |
| 624 | +end |
0 commit comments