|
199 | 199 | @test @inferred(1:2:StaticInt(10)) == 1:2:10
|
200 | 200 | @test @inferred(1:StaticInt(2):10) == 1:2:10
|
201 | 201 | @test @inferred(StaticInt(1):2:10) == 1:2:10
|
| 202 | + @test @inferred(StaticInt(1):UInt(10)) === StaticInt(1):10 |
| 203 | + @test @inferred(UInt(1):StaticInt(1):StaticInt(10)) === 1:StaticInt(10) |
| 204 | + @test @inferred(ArrayInterface.OptionallyStaticUnitRange{Int,Int}(1:10)) == 1:10 |
| 205 | + @test @inferred(ArrayInterface.OptionallyStaticUnitRange(1:10)) == 1:10 |
| 206 | + |
| 207 | + @inferred(ArrayInterface.OptionallyStaticUnitRange(1:10)) |
| 208 | + |
| 209 | + @test @inferred(ArrayInterface.OptionallyStaticStepRange(StaticInt(1), 1, UInt(10))) == StaticInt(1):1:10 |
| 210 | + @test @inferred(ArrayInterface.OptionallyStaticStepRange(UInt(1), 1, StaticInt(10))) == StaticInt(1):1:10 |
| 211 | + @test @inferred(ArrayInterface.OptionallyStaticStepRange(1:10)) == 1:1:10 |
| 212 | + |
| 213 | + @test_throws ArgumentError ArrayInterface.OptionallyStaticUnitRange(1:2:10) |
| 214 | + @test_throws ArgumentError ArrayInterface.OptionallyStaticUnitRange{Int,Int}(1:2:10) |
| 215 | + @test_throws ArgumentError ArrayInterface.OptionallyStaticStepRange(1, 0, 10) |
202 | 216 |
|
203 | 217 | @test @inferred(StaticInt(1):StaticInt(1):StaticInt(10)) === ArrayInterface.OptionallyStaticUnitRange(StaticInt(1), StaticInt(10))
|
204 | 218 | @test @inferred(StaticInt(1):StaticInt(1):10) === ArrayInterface.OptionallyStaticUnitRange(StaticInt(1), 10)
|
@@ -226,13 +240,16 @@ end
|
226 | 240 | @test isnothing(@inferred(ArrayInterface.known_first(typeof(1:4))))
|
227 | 241 | @test isone(@inferred(ArrayInterface.known_first(Base.OneTo(4))))
|
228 | 242 | @test isone(@inferred(ArrayInterface.known_first(typeof(Base.OneTo(4)))))
|
| 243 | + @test isone(@inferred(ArrayInterface.known_first(typeof(StaticInt(1):2:10)))) |
229 | 244 |
|
230 | 245 | @test isnothing(@inferred(ArrayInterface.known_last(1:4)))
|
231 | 246 | @test isnothing(@inferred(ArrayInterface.known_last(typeof(1:4))))
|
| 247 | + @test isone(@inferred(ArrayInterface.known_last(typeof(StaticInt(-1):StaticInt(2):StaticInt(1))))) |
232 | 248 |
|
233 | 249 | @test isnothing(@inferred(ArrayInterface.known_step(typeof(1:0.2:4))))
|
234 | 250 | @test isone(@inferred(ArrayInterface.known_step(1:4)))
|
235 | 251 | @test isone(@inferred(ArrayInterface.known_step(typeof(1:4))))
|
| 252 | + @test isone(@inferred(ArrayInterface.known_step(typeof(Base.Slice(1:4))))) |
236 | 253 |
|
237 | 254 | @testset "length" begin
|
238 | 255 | @test @inferred(length(ArrayInterface.OptionallyStaticUnitRange(1, 0))) == 0
|
|
244 | 261 |
|
245 | 262 | @test @inferred(length(StaticInt(1):StaticInt(2):StaticInt(0))) == 0
|
246 | 263 | @test @inferred(length(StaticInt(0):StaticInt(-2):StaticInt(1))) == 0
|
| 264 | + |
| 265 | + @test @inferred(ArrayInterface.known_length(typeof(ArrayInterface.OptionallyStaticStepRange(StaticInt(1), 2, 10)))) === nothing |
| 266 | + @test @inferred(ArrayInterface.known_length(typeof(ArrayInterface.OptionallyStaticStepRange(StaticInt(1), StaticInt(1), StaticInt(10))))) === 10 |
| 267 | + @test @inferred(ArrayInterface.known_length(typeof(ArrayInterface.OptionallyStaticStepRange(StaticInt(2), StaticInt(1), StaticInt(10))))) === 9 |
| 268 | + @test @inferred(ArrayInterface.known_length(typeof(ArrayInterface.OptionallyStaticStepRange(StaticInt(2), StaticInt(2), StaticInt(10))))) === 5 |
| 269 | + |
| 270 | + @test @inferred(length(ArrayInterface.OptionallyStaticStepRange(StaticInt(1), 2, 10))) == 5 |
| 271 | + @test @inferred(length(ArrayInterface.OptionallyStaticStepRange(StaticInt(1), StaticInt(1), StaticInt(10)))) == 10 |
| 272 | + @test @inferred(length(ArrayInterface.OptionallyStaticStepRange(StaticInt(2), StaticInt(1), StaticInt(10)))) == 9 |
| 273 | + @test @inferred(length(ArrayInterface.OptionallyStaticStepRange(StaticInt(2), StaticInt(2), StaticInt(10)))) == 5 |
247 | 274 | end
|
248 | 275 |
|
249 | 276 | @test @inferred(getindex(ArrayInterface.OptionallyStaticUnitRange(StaticInt(1), 10), 1)) == 1
|
|
0 commit comments