From 60e84e78b780bc38df99de691960f85e13343766 Mon Sep 17 00:00:00 2001 From: Jeremie Gillet Date: Fri, 14 Jun 2024 11:35:05 +0900 Subject: [PATCH 1/2] update to 1.17 --- .github/workflows/ci.yml | 10 +-- README.md | 2 +- .../concept/rpn-calculator/.meta/exemplar.ex | 2 +- .../top-secret/test/top_secret_test.exs | 73 ++++++++++--------- .../practice/atbash-cipher/.meta/example.ex | 2 +- exercises/practice/beer-song/.meta/example.ex | 2 +- .../practice/isbn-verifier/.meta/example.ex | 2 +- .../kindergarten-garden/.meta/example.ex | 4 +- .../pascals-triangle/.meta/example.ex | 2 +- .../practice/sgf-parsing/.meta/example.ex | 2 +- 10 files changed, 53 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e972dfe58..54a3b2858b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ name: elixir / main ci on: push: - branches: [ main ] + branches: [main] pull_request: workflow_dispatch: @@ -17,8 +17,8 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - elixir: [1.16] - otp: [26.2] + elixir: [1.17] + otp: [27.0] steps: - name: Checkout code @@ -76,8 +76,6 @@ jobs: strategy: matrix: include: - - elixir: '1.11.0' - otp: '23.2' - elixir: '1.12.0' otp: '24.0' - elixir: '1.13.0' @@ -88,6 +86,8 @@ jobs: otp: '26.0' - elixir: '1.16.0' otp: '26.2' + - elixir: '1.17.0' + otp: '27.0' steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 diff --git a/README.md b/README.md index 5cd48f7a9e..7cbc883f7b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Setup -The exercises currently target Elixir versions from 1.11 to 1.16 and Erlang/OTP versions from 21 to 26. Detailed installation instructions can be found at +The exercises currently target Elixir versions from 1.12 to 1.17 and Erlang/OTP versions from 24 to 27. Detailed installation instructions can be found at [https://elixir-lang.org/install.html](https://elixir-lang.org/install.html). We recommend using the [asdf version manager](https://github.com/asdf-vm/asdf) to manage multiple Elixir versions. ## Testing diff --git a/exercises/concept/rpn-calculator/.meta/exemplar.ex b/exercises/concept/rpn-calculator/.meta/exemplar.ex index 945d41640d..85c2105480 100644 --- a/exercises/concept/rpn-calculator/.meta/exemplar.ex +++ b/exercises/concept/rpn-calculator/.meta/exemplar.ex @@ -15,7 +15,7 @@ defmodule RPNCalculator do try do {:ok, operation.(stack)} rescue - e -> {:error, e.message} + e -> {:error, Exception.message(e)} end end end diff --git a/exercises/concept/top-secret/test/top_secret_test.exs b/exercises/concept/top-secret/test/top_secret_test.exs index a102489b78..82c9687a07 100644 --- a/exercises/concept/top-secret/test/top_secret_test.exs +++ b/exercises/concept/top-secret/test/top_secret_test.exs @@ -37,41 +37,46 @@ defmodule TopSecretTest do end """ - ast = { - :defmodule, - [line: 1], - [ - {:__aliases__, [line: 1], [:List]}, - [ - do: { - :__block__, - [], - [ - {:@, [line: 2], + assert { + :defmodule, + [line: 1], + [ + {:__aliases__, [line: 1], [:List]}, [ - {:spec, [line: 2], - [{:"::", [line: 2], [{:delete, [line: 2], [[], {:any, [line: 2], nil}]}, []]}]} - ]}, - {:@, [line: 3], - [ - {:spec, [line: 3], - [ - {:"::", [line: 3], - [ - {:delete, [line: 3], [[{:..., [line: 3], nil}], {:any, [line: 3], nil}]}, - {:list, [line: 3], nil} - ]} - ]} - ]}, - {:def, [line: 4], - [{:delete, [line: 4], [{:list, [line: 4], nil}, {:element, [line: 4], nil}]}]} - ] - } - ] - ] - } - - assert TopSecret.to_ast(string) == ast + do: { + :__block__, + [], + [ + {:@, [line: 2], + [ + {:spec, [line: 2], + [ + {:"::", [line: 2], + [{:delete, [line: 2], [[], {:any, [line: 2], nil}]}, []]} + ]} + ]}, + {:@, [line: 3], + [ + {:spec, [line: 3], + [ + {:"::", [line: 3], + [ + {:delete, [line: 3], + [[{:..., [line: 3], _nil_or_empty_list}], {:any, [line: 3], nil}]}, + {:list, [line: 3], nil} + ]} + ]} + ]}, + {:def, [line: 4], + [ + {:delete, [line: 4], + [{:list, [line: 4], nil}, {:element, [line: 4], nil}]} + ]} + ] + } + ] + ] + } = TopSecret.to_ast(string) end end diff --git a/exercises/practice/atbash-cipher/.meta/example.ex b/exercises/practice/atbash-cipher/.meta/example.ex index 760cf42087..619670288c 100644 --- a/exercises/practice/atbash-cipher/.meta/example.ex +++ b/exercises/practice/atbash-cipher/.meta/example.ex @@ -1,5 +1,5 @@ defmodule Atbash do - @key Enum.zip(?a..?z, ?z..?a) |> Enum.into(%{}) + @key Enum.zip(?a..?z, ?z..?a//-1) |> Enum.into(%{}) @doc """ Encode a given plaintext to the corresponding ciphertext diff --git a/exercises/practice/beer-song/.meta/example.ex b/exercises/practice/beer-song/.meta/example.ex index 2400ec8829..9e9c654044 100644 --- a/exercises/practice/beer-song/.meta/example.ex +++ b/exercises/practice/beer-song/.meta/example.ex @@ -15,7 +15,7 @@ defmodule BeerSong do "#{number} bottles of beer on the wall, #{number} bottles of beer.\nTake one down and pass it around, #{number - 1} bottles of beer on the wall.\n" end - def lyrics(range \\ 99..0) do + def lyrics(range \\ 99..0//-1) do range |> Enum.map(&verse/1) |> Enum.join("\n") diff --git a/exercises/practice/isbn-verifier/.meta/example.ex b/exercises/practice/isbn-verifier/.meta/example.ex index c29359581f..2c35f0964e 100644 --- a/exercises/practice/isbn-verifier/.meta/example.ex +++ b/exercises/practice/isbn-verifier/.meta/example.ex @@ -18,7 +18,7 @@ defmodule IsbnVerifier do isbn |> String.replace("-", "") |> String.graphemes() - |> Enum.zip(10..1) + |> Enum.zip(10..1//-1) |> Enum.map(&checksum_weighting/1) |> Enum.sum() diff --git a/exercises/practice/kindergarten-garden/.meta/example.ex b/exercises/practice/kindergarten-garden/.meta/example.ex index 2cf47fe59c..3d4db7bd37 100644 --- a/exercises/practice/kindergarten-garden/.meta/example.ex +++ b/exercises/practice/kindergarten-garden/.meta/example.ex @@ -51,8 +51,8 @@ defmodule Garden do letters = "#{first_row_letters}#{second_row_letters}" map = add_to_map(map, current_name, letters) - first_row = String.slice(first_row, 2..-1) - second_row = String.slice(second_row, 2..-1) + first_row = String.slice(first_row, 2..-1//-1) + second_row = String.slice(second_row, 2..-1//-1) populate_map(first_row, second_row, map, student_names) end diff --git a/exercises/practice/pascals-triangle/.meta/example.ex b/exercises/practice/pascals-triangle/.meta/example.ex index eafd8df45a..f824b1a702 100644 --- a/exercises/practice/pascals-triangle/.meta/example.ex +++ b/exercises/practice/pascals-triangle/.meta/example.ex @@ -24,7 +24,7 @@ defmodule PascalsTriangle do defp each_cons(list) do list |> Enum.flat_map(&[&1, &1]) - |> Enum.slice(1..-2) + |> Enum.slice(1..-2//-1) |> Enum.chunk_every(2) end diff --git a/exercises/practice/sgf-parsing/.meta/example.ex b/exercises/practice/sgf-parsing/.meta/example.ex index 41c12c0c88..be2c1f100d 100644 --- a/exercises/practice/sgf-parsing/.meta/example.ex +++ b/exercises/practice/sgf-parsing/.meta/example.ex @@ -134,7 +134,7 @@ defmodule SgfParsing do with {:ok, result, rest} <- some(parser).(input) do {:ok, result, rest} else - {:error, _err, ^input} -> {:ok, [], input} + {:error, _err, rest} when rest == input -> {:ok, [], input} err -> err end end From 36bb80d336c079e60bc685599ac9bbd4e6b5dce9 Mon Sep 17 00:00:00 2001 From: Jie Date: Mon, 1 Jul 2024 07:47:26 +0800 Subject: [PATCH 2/2] Update exercises/concept/rpn-calculator/.meta/exemplar.ex Co-authored-by: Angelika Tyborska --- exercises/concept/rpn-calculator/.meta/exemplar.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/concept/rpn-calculator/.meta/exemplar.ex b/exercises/concept/rpn-calculator/.meta/exemplar.ex index 85c2105480..1a3765058e 100644 --- a/exercises/concept/rpn-calculator/.meta/exemplar.ex +++ b/exercises/concept/rpn-calculator/.meta/exemplar.ex @@ -15,7 +15,7 @@ defmodule RPNCalculator do try do {:ok, operation.(stack)} rescue - e -> {:error, Exception.message(e)} + e in ArgumentError -> {:error, e.message} end end end