From 69c7e5db768bdcb6ce9635d4592e6c10b26a7831 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 3 Oct 2025 22:24:00 +0200 Subject: [PATCH 1/3] add Colon dispatch and tests --- src/TracedRange.jl | 9 +++++++++ test/ranges.jl | 7 +++++++ test/runtests.jl | 1 + 3 files changed, 17 insertions(+) create mode 100644 test/ranges.jl diff --git a/src/TracedRange.jl b/src/TracedRange.jl index c432499f73..6da8ccf812 100644 --- a/src/TracedRange.jl +++ b/src/TracedRange.jl @@ -177,4 +177,13 @@ function Base._reshape(parent::TracedUnitRange, dims::Dims) return Base.__reshape((parent, IndexStyle(parent)), dims) end +function (C::Base.Colon)(start::TracedRNumber{T},stop::TracedRNumber{T}) where T + TracedUnitRange(start,stop) +end +function (C::Base.Colon)(start::TracedRNumber{T},stop::T) where T + C(start,TracedRNumber{T}(stop)) +end +function (C::Base.Colon)(start::T,stop::TracedRNumber{T}) where T + C(TracedRNumber{T}(start),stop) +end end diff --git a/test/ranges.jl b/test/ranges.jl new file mode 100644 index 0000000000..9394a22a9c --- /dev/null +++ b/test/ranges.jl @@ -0,0 +1,7 @@ +@testset "ranges" begin + i = Reactant.to_rarray(5,track_numbers=true) + @test Array{Int64}(@jit(1:i)) == collect(1:5) + @test Array{Int64}(@jit(i:10)) == collect(5:10) + j = Reactant.to_rarray(10,track_numbers=true) + @test Array{Int64}(@jit(i:j)) == collect(5:10) +end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 5edaa478e5..f812deee5c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -29,6 +29,7 @@ const REACTANT_TEST_GROUP = lowercase(get(ENV, "REACTANT_TEST_GROUP", "all")) @safetestset "Sorting" include("sorting.jl") @safetestset "Shortcuts to MLIR ops" include("ops.jl") @safetestset "Indexing" include("indexing.jl") + @safetestset "Ranges" include("ranges.jl") if !Sys.isapple() @safetestset "Custom Number Types" include("custom_number_types.jl") end From f6ad5e4fbaad2e7c3824e2a63650142d812e4445 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 3 Oct 2025 22:28:44 +0200 Subject: [PATCH 2/3] vscode linebreak --- test/ranges.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ranges.jl b/test/ranges.jl index 9394a22a9c..5a84b583f0 100644 --- a/test/ranges.jl +++ b/test/ranges.jl @@ -4,4 +4,4 @@ @test Array{Int64}(@jit(i:10)) == collect(5:10) j = Reactant.to_rarray(10,track_numbers=true) @test Array{Int64}(@jit(i:j)) == collect(5:10) -end \ No newline at end of file +end From ba8ae7207ac35dc49fc7310798df46a46d73df74 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 3 Oct 2025 23:36:01 +0200 Subject: [PATCH 3/3] make sure reactant is loaded --- test/ranges.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/ranges.jl b/test/ranges.jl index 5a84b583f0..949bb00627 100644 --- a/test/ranges.jl +++ b/test/ranges.jl @@ -1,3 +1,5 @@ +using Reactant,Test + @testset "ranges" begin i = Reactant.to_rarray(5,track_numbers=true) @test Array{Int64}(@jit(1:i)) == collect(1:5)