From 73a1031626e75205c6c834067aedeb57fc31a454 Mon Sep 17 00:00:00 2001 From: Simon Byrne Date: Fri, 25 Sep 2020 11:53:34 -0700 Subject: [PATCH 1/3] Partially fix #9 --- .gitignore | 1 + src/KeywordDispatch.jl | 2 +- test/runtests.jl | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba39cc5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Manifest.toml diff --git a/src/KeywordDispatch.jl b/src/KeywordDispatch.jl index d54b83f..cefbf65 100644 --- a/src/KeywordDispatch.jl +++ b/src/KeywordDispatch.jl @@ -54,7 +54,7 @@ argtype(x::Expr) = x.head == :(::) ? x.args[end] : error("unexpected expression function unwrap_where(expr) stack = Any[] while expr isa Expr && expr.head == :where - push!(stack, expr.args[2]) + append!(stack, expr.args[2:end]) expr = expr.args[1] end expr, stack diff --git a/test/runtests.jl b/test/runtests.jl index 2ad6e98..50beba0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -251,3 +251,15 @@ end @test f(alpha=0,beta=0) == 3 end + +@testset "multiple where clauses" begin + # based on https://github.com/simonbyrne/KeywordDispatch.jl/issues/9 + @kwdispatch f(x::T) where {T} + + @kwmethod f(x::T; y::TI) where {T, TI <: Vector{T}} = y + + @test f(1.0,y=[1.0,2.0]) == [1.0,2.0] + @test f(1,y=[1,2]) == [1,2] + + @test_throws KeywordMethodError f(1,y=[1.0,2.0]) +end From fc535997cc5ad77998d9a8c4fd0372e20794e149 Mon Sep 17 00:00:00 2001 From: Simon Byrne Date: Fri, 25 Sep 2020 12:00:20 -0700 Subject: [PATCH 2/3] move Test to test dependencies, switch from Travis to GitHub Actions --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 10 ---------- Project.toml | 5 ++++- 3 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4b185dd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI +on: + - pull_request +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + version: + - '1.0' + - '1.4' + - '1.5' + - 'nightly' + os: + - ubuntu-latest + - macOS-latest + - windows-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 486f305..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: julia -os: - - linux -julia: - - 1.0 - - 1.1 - - 1.2 - - 1.3 -notifications: - email: false diff --git a/Project.toml b/Project.toml index c1df0bf..81b3421 100644 --- a/Project.toml +++ b/Project.toml @@ -3,5 +3,8 @@ uuid = "5888135b-5456-5c80-a1b6-c91ef8180460" authors = ["Simon Byrne "] version = "0.3.0" -[deps] +[extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Test"] \ No newline at end of file From a3449e17989d5213f787fc68a11334bfbeade0f6 Mon Sep 17 00:00:00 2001 From: Simon Byrne Date: Fri, 25 Sep 2020 12:03:01 -0700 Subject: [PATCH 3/3] add julia compat, bump version --- Project.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 81b3421..baa1d24 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,10 @@ name = "KeywordDispatch" uuid = "5888135b-5456-5c80-a1b6-c91ef8180460" authors = ["Simon Byrne "] -version = "0.3.0" +version = "0.3.1" + +[compat] +julia = "1.0" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"