From cb8debbe2fef2b2be62e35afb6bfd71d412d7926 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sat, 4 Feb 2023 08:03:44 -0600 Subject: [PATCH 1/3] Support anonymous functions Closes #80 --- src/utils.jl | 1 + test/runtests.jl | 8 +++++++- test/script.jl | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index d0b2b0b..1736a33 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -20,6 +20,7 @@ checkname(fname::Symbol, name::Symbol) = begin fname === name && return true startswith(string(name), string('#', fname, '#')) && return true string(name) == string(fname, "##kw") && return true + match(r"^#\d+$", string(name)) !== nothing && return true # support `f = x -> 2x` return false end checkname(fname::Symbol, ::Nothing) = true diff --git a/test/runtests.jl b/test/runtests.jl index cedb165..8c4ccd5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -163,6 +163,12 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j eval(ex) @test code_string(f_no_linenum, (Int,)) === nothing + # Issue #80 + m = only(methods(f80)) + src, line = definition(String, m) + @test occursin("x^3", src) + @test line == 52 + # Invalidation-insulating methods used by Revise and perhaps others d = IdDict{Union{String,Symbol},Union{Function,Vector{Function}}}() CodeTracking.invoked_setindex!(d, sin, "sin") @@ -286,7 +292,7 @@ struct Functor end @test body == "(::Functor)(x, y) = x+y" end -if v"1.6" <= VERSION < v"1.9" +if v"1.6" <= VERSION < v"1.9-beta" @testset "kwfuncs" begin body, _ = CodeTracking.definition(String, @which fkw(; x=1)) @test body == """ diff --git a/test/script.jl b/test/script.jl index 4ed17ee..06f9d91 100644 --- a/test/script.jl +++ b/test/script.jl @@ -47,3 +47,6 @@ end function fkw(; x=1) x end + +# Issue #80 +f80 = x -> 2 * x^3 + 1 From cf835c6115d692e5bae5da69c9b0ef96fd4287d2 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sat, 4 Feb 2023 08:19:28 -0600 Subject: [PATCH 2/3] Fix `CI Revise tests must be run with -i` --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 053acd9..f365069 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: TERM="xterm" julia --project -i --code-coverage -e ' using InteractiveUtils, REPL, Revise, Pkg Pkg.add("ColorTypes") - # @async(Base.run_main_repl(true, true, false, true, false)) + @async(Base.run_main_repl(true, true, false, true, false)) sleep(2) cd("test") include("runtests.jl") From 236dadcf2ca9529219a97318151d9604bc777572 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sat, 4 Feb 2023 08:41:31 -0600 Subject: [PATCH 3/3] More CI fix --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f365069..b52d805 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,11 @@ jobs: sleep(2) cd("test") include("runtests.jl") - REPL.eval_user_input(:(exit()), Base.active_repl_backend) + if Base.VERSION.major == 1 && Base.VERSION.minor >= 9 + REPL.eval_user_input(:(exit()), Base.active_repl_backend, Main) + else + REPL.eval_user_input(:(exit()), Base.active_repl_backend) + end ' - uses: julia-actions/julia-processcoverage@latest - uses: codecov/codecov-action@v3