From ce4af7ac9b0646ddf49649bd1b497b09dcf959fe Mon Sep 17 00:00:00 2001 From: Marcus Kruse Date: Thu, 2 Jan 2025 07:48:59 +0100 Subject: [PATCH] Update tests for Elixir 1.18.1 --- .gha/default.exs | 338 +++++++++++ .github/workflows/ci.yml | 49 +- lib/beam_file/normalizer.ex | 2 +- mix.exs | 2 +- mix.lock | 28 +- test/fixtures/{1.17.2 => 1.17.3}/atom_ast.exs | 0 test/fixtures/{1.17.2 => 1.17.3}/capture.exs | 0 test/fixtures/{1.17.2 => 1.17.3}/comps.exs | 0 .../fixtures/{1.17.2 => 1.17.3}/comps_ast.exs | 0 test/fixtures/{1.17.2 => 1.17.3}/math.erl | 0 test/fixtures/{1.17.2 => 1.17.3}/math.exs | 0 .../{1.17.2 => 1.17.3}/math_abstract_code.exs | 0 .../{1.17.2 => 1.17.3}/math_debug_info.exs | 0 .../fixtures/{1.17.2 => 1.17.3}/math_docs.exs | 0 .../{1.17.2 => 1.17.3}/math_without_docs.exs | 0 .../{1.17.2 => 1.17.3}/multi_when.exs | 0 test/fixtures/1.18.1/atom_ast.exs | 19 + test/fixtures/1.18.1/capture.exs | 9 + test/fixtures/1.18.1/comps.exs | 55 ++ test/fixtures/1.18.1/comps_ast.exs | 574 ++++++++++++++++++ test/fixtures/1.18.1/math.erl | 91 +++ test/fixtures/1.18.1/math.exs | 54 ++ test/fixtures/1.18.1/math_abstract_code.exs | 474 +++++++++++++++ test/fixtures/1.18.1/math_debug_info.exs | 206 +++++++ test/fixtures/1.18.1/math_docs.exs | 22 + test/fixtures/1.18.1/math_without_docs.exs | 38 ++ test/fixtures/1.18.1/multi_when.exs | 13 + 27 files changed, 1937 insertions(+), 37 deletions(-) create mode 100644 .gha/default.exs rename test/fixtures/{1.17.2 => 1.17.3}/atom_ast.exs (100%) rename test/fixtures/{1.17.2 => 1.17.3}/capture.exs (100%) rename test/fixtures/{1.17.2 => 1.17.3}/comps.exs (100%) rename test/fixtures/{1.17.2 => 1.17.3}/comps_ast.exs (100%) rename test/fixtures/{1.17.2 => 1.17.3}/math.erl (100%) rename test/fixtures/{1.17.2 => 1.17.3}/math.exs (100%) rename test/fixtures/{1.17.2 => 1.17.3}/math_abstract_code.exs (100%) rename test/fixtures/{1.17.2 => 1.17.3}/math_debug_info.exs (100%) rename test/fixtures/{1.17.2 => 1.17.3}/math_docs.exs (100%) rename test/fixtures/{1.17.2 => 1.17.3}/math_without_docs.exs (100%) rename test/fixtures/{1.17.2 => 1.17.3}/multi_when.exs (100%) create mode 100644 test/fixtures/1.18.1/atom_ast.exs create mode 100644 test/fixtures/1.18.1/capture.exs create mode 100644 test/fixtures/1.18.1/comps.exs create mode 100644 test/fixtures/1.18.1/comps_ast.exs create mode 100644 test/fixtures/1.18.1/math.erl create mode 100644 test/fixtures/1.18.1/math.exs create mode 100644 test/fixtures/1.18.1/math_abstract_code.exs create mode 100644 test/fixtures/1.18.1/math_debug_info.exs create mode 100644 test/fixtures/1.18.1/math_docs.exs create mode 100644 test/fixtures/1.18.1/math_without_docs.exs create mode 100644 test/fixtures/1.18.1/multi_when.exs diff --git a/.gha/default.exs b/.gha/default.exs new file mode 100644 index 0000000..9a781b3 --- /dev/null +++ b/.gha/default.exs @@ -0,0 +1,338 @@ +defmodule GitHubActions.Default do + use GitHubActions.Workflow + + def workflow do + [ + name: "CI", + env: [ + GITHUB_TOKEN: ~e[secrets.GITHUB_TOKEN] + ], + on: ~w(pull_request push), + jobs: [ + linux: job(:linux), + windows: job(:windows), + macos: job(:macos) + ] + ] + end + + defp elixir_version do + elixir = Config.get(:elixir) + if elixir, do: "~> #{Version.minor(elixir)}", else: Project.elixir() + end + + defp otp_version, do: "> 21.0.0" + + defp matrix do + Versions.matrix( + elixir: elixir_version(), + otp: otp_version() + ) + end + + defp job(:linux = os) do + job(os, + name: """ + Test on #{Config.get([os, :name])} (\ + Elixir #{~e[matrix.elixir]}, \ + OTP #{~e[matrix.otp]})\ + """, + runs_on: Config.get([os, :runs_on]), + strategy: [matrix: matrix()], + steps: [ + checkout(), + setup_elixir(os), + restore(:deps), + restore(:_build), + restore(:dialyxir), + get_deps(), + compile_deps(os), + compile(os), + check_unused_deps(), + check_code_format(), + lint_code(), + run_tests(os), + run_coverage(os), + dialyxir() + ] + ) + end + + defp job(:windows = os) do + job(os, + name: "Test on #{Config.get([os, :name])}", + runs_on: Config.get([os, :runs_on]), + steps: [ + checkout(), + setup_elixir(os), + get_deps(), + compile_deps(os), + compile(os), + run_tests(os), + run_coverage(os) + ] + ) + end + + defp job(:macos = os) do + job(os, + name: "Test on #{Config.get([os, :name])}", + runs_on: Config.get([os, :runs_on]), + steps: [ + checkout(), + setup_elixir(os), + install_hex(), + install_rebar(), + restore(:deps), + restore(:_build), + get_deps(), + compile_deps(os), + compile(os), + run_tests(os), + run_coverage(os) + ] + ) + end + + defp job(os, config) do + case member?(:jobs, os) do + true -> config + false -> :skip + end + end + + defp checkout do + [ + name: "Checkout", + uses: "actions/checkout@v4" + ] + end + + defp setup_elixir(:linux) do + [ + name: "Setup Elixir", + id: "setup-beam", + uses: "erlef/setup-beam@v1", + with: [ + elixir_version: ~e[matrix.elixir], + otp_version: ~e[matrix.otp] + ] + ] + end + + defp setup_elixir(:macos) do + [ + name: "Setup Elixir", + id: "setup-beam", + run: "brew install elixir" + ] + end + + defp setup_elixir(:windows) do + [ + name: "Setup Elixir", + id: "setup-beam", + uses: "erlef/setup-beam@v1", + with: [ + elixir_version: Versions.latest(:elixir), + otp_version: Versions.latest(:otp) + ] + ] + end + + defp install_hex do + [ + name: "Install hex", + run: mix(:local, :hex, force: true) + ] + end + + defp install_rebar do + [ + name: "Install rebar", + run: mix(:local, :rebar, force: true) + ] + end + + defp restore(:dialyxir) do + case Project.has_dep?(:dialyxir) and Config.get([:steps, :dialyxir]) do + false -> + :skip + + true -> + case Project.fetch([:dialyzer, :plt_file]) do + :error -> + :skip + + {:ok, {_, file}} -> + file |> Path.dirname() |> restore(if: latest_version(true)) + end + end + end + + defp restore(path, opts \\ []) do + case Config.fetch!([:steps, :refresh]) do + false -> + :skip + + true -> + {opt_if, opts} = Keyword.pop(opts, :if) + opt_if = if opt_if, do: [if: opt_if], else: [] + + Keyword.merge( + [name: "Restore #{path}"] ++ + opt_if ++ + [ + uses: "actions/cache@v4", + with: [ + path: path, + key: key(path) + ] + ], + opts + ) + end + end + + defp get_deps do + [ + name: "Get dependencies", + run: mix(:deps, :get) + ] + end + + defp compile_deps(os) do + [ + name: "Compile dependencies", + run: mix(:deps, :compile, env: :test, os: os) + ] + end + + defp compile(os) do + [ + name: "Compile project", + run: mix(:compile, warnings_as_errors: true, env: :test, os: os) + ] + end + + defp check_unused_deps do + case Config.get(:check_unused_deps, true) do + false -> + :skip + + true -> + [ + name: "Check unused dependencies", + if: latest_version(true), + run: mix(:deps, :unlock, check_unused: true) + ] + end + end + + defp check_code_format do + case Config.get(:check_code_format, true) do + false -> + :skip + + true -> + [ + name: "Check code format", + if: latest_version(true), + run: mix(:format, check_formatted: true) + ] + end + end + + defp lint_code do + case Project.has_dep?(:credo) do + false -> + :skip + + true -> + [ + name: "Lint code", + if: latest_version(true), + run: mix(:credo, strict: true) + ] + end + end + + defp run_tests(:windows) do + [ + name: "Run tests", + run: mix(:test) + ] + end + + defp run_tests(_nix) do + case Project.has_dep?(:excoveralls) do + true -> + [ + name: "Run tests", + if: latest_version(false), + run: mix(:test) + ] + + false -> + [ + name: "Run tests", + run: mix(:test) + ] + end + end + + defp run_coverage(:windows), do: :skip + + defp run_coverage(_nix) do + case Project.has_dep?(:excoveralls) do + true -> + [ + name: "Run tests with coverage", + if: latest_version(true), + run: mix(:coveralls, Config.get([:steps, :coveralls])) + ] + + false -> + :skip + end + end + + defp dialyxir do + case Project.has_dep?(:dialyxir) do + false -> + :skip + + true -> + [ + name: "Static code analysis", + if: latest_version(true), + run: mix(:dialyzer, force_check: true, format: "github") + ] + end + end + + defp key(key) do + os = ~e[runner.os] + elixir = ~e[matrix.elixir] + otp = ~e[matrix.otp] + setup_beam_version = ~e{steps.setup-beam.outputs.setup-beam-version} + lock = ~e[hashFiles(format('{0}{1}', github.workspace, '/mix.lock'))] + "#{key}-#{os}-#{elixir}-#{otp}-#{lock}-#{setup_beam_version}" + end + + defp latest_version(true) do + ~e""" + matrix.elixir == '#{Versions.latest(:elixir)}' && \ + matrix.otp == '#{Versions.latest(:otp)}'\ + """ + end + + defp latest_version(false) do + ~e""" + !(matrix.elixir == '#{Versions.latest(:elixir)}' && \ + matrix.otp == '#{Versions.latest(:otp)}')\ + """ + end + + defp member?(key, value), do: key |> Config.get() |> Enum.member?(value) +end diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ae7828..80b719d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# Created with GitHubActions version 0.2.24 +# Created with GitHubActions version 0.3.0 name: CI env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -10,52 +10,59 @@ jobs: name: Test on Ubuntu (Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }}) runs-on: ubuntu-20.04 strategy: - fail-fast: false matrix: elixir: - '1.13.4' - '1.14.5' - '1.15.8' - '1.16.3' - - '1.17.2' + - '1.17.3' + - '1.18.1' otp: - '22.3' - '23.3' - '24.3' - '25.3' - '26.2' - - '27.0' + - '27.2' exclude: - elixir: '1.13.4' otp: '26.2' - elixir: '1.13.4' - otp: '27.0' + otp: '27.2' - elixir: '1.14.5' otp: '22.3' - elixir: '1.14.5' - otp: '27.0' + otp: '27.2' - elixir: '1.15.8' otp: '22.3' - elixir: '1.15.8' otp: '23.3' - elixir: '1.15.8' - otp: '27.0' + otp: '27.2' - elixir: '1.16.3' otp: '22.3' - elixir: '1.16.3' otp: '23.3' - elixir: '1.16.3' - otp: '27.0' - - elixir: '1.17.2' + otp: '27.2' + - elixir: '1.17.3' otp: '22.3' - - elixir: '1.17.2' + - elixir: '1.17.3' otp: '23.3' - - elixir: '1.17.2' + - elixir: '1.17.3' + otp: '24.3' + - elixir: '1.18.1' + otp: '22.3' + - elixir: '1.18.1' + otp: '23.3' + - elixir: '1.18.1' otp: '24.3' steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Elixir + id: setup-beam uses: erlef/setup-beam@v1 with: elixir-version: ${{ matrix.elixir }} @@ -64,18 +71,18 @@ jobs: uses: actions/cache@v4 with: path: deps - key: deps-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + key: deps-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ steps.setup-beam.outputs.setup-beam-version }} - name: Restore _build uses: actions/cache@v4 with: path: _build - key: _build-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + key: _build-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ steps.setup-beam.outputs.setup-beam-version }} - name: Restore test/support/plts + if: ${{ matrix.elixir == '1.18.1' && matrix.otp == '27.2' }} uses: actions/cache@v4 with: path: test/support/plts - key: test/support/plts-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - if: ${{ contains(matrix.elixir, '1.17.2') && contains(matrix.otp, '27.0') }} + key: test/support/plts-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ steps.setup-beam.outputs.setup-beam-version }} - name: Get dependencies run: mix deps.get - name: Compile dependencies @@ -83,20 +90,20 @@ jobs: - name: Compile project run: MIX_ENV=test mix compile --warnings-as-errors - name: Check unused dependencies - if: ${{ contains(matrix.elixir, '1.17.2') && contains(matrix.otp, '27.0') }} + if: ${{ matrix.elixir == '1.18.1' && matrix.otp == '27.2' }} run: mix deps.unlock --check-unused - name: Check code format - if: ${{ contains(matrix.elixir, '1.17.2') && contains(matrix.otp, '27.0') }} + if: ${{ matrix.elixir == '1.18.1' && matrix.otp == '27.2' }} run: mix format --check-formatted - name: Lint code - if: ${{ contains(matrix.elixir, '1.17.2') && contains(matrix.otp, '27.0') }} + if: ${{ matrix.elixir == '1.18.1' && matrix.otp == '27.2' }} run: mix credo --strict - name: Run tests + if: ${{ !(matrix.elixir == '1.18.1' && matrix.otp == '27.2') }} run: mix test - if: ${{ !(contains(matrix.elixir, '1.17.2') && contains(matrix.otp, '27.0')) }} - name: Run tests with coverage + if: ${{ matrix.elixir == '1.18.1' && matrix.otp == '27.2' }} run: mix coveralls.github - if: ${{ contains(matrix.elixir, '1.17.2') && contains(matrix.otp, '27.0') }} - name: Static code analysis + if: ${{ matrix.elixir == '1.18.1' && matrix.otp == '27.2' }} run: mix dialyzer --format github --force-check - if: ${{ contains(matrix.elixir, '1.17.2') && contains(matrix.otp, '27.0') }} diff --git a/lib/beam_file/normalizer.ex b/lib/beam_file/normalizer.ex index bbaa8fa..6dae939 100644 --- a/lib/beam_file/normalizer.ex +++ b/lib/beam_file/normalizer.ex @@ -11,7 +11,7 @@ defmodule BeamFile.Normalizer do :/, :!=, :!==, - :"..//", + :..//, :"//", :"::", :"<|>", diff --git a/mix.exs b/mix.exs index c1f719e..06c088c 100644 --- a/mix.exs +++ b/mix.exs @@ -51,7 +51,7 @@ defmodule BeamFile.MixProject do defp aliases do [ - carp: "test --seed 0 --max-failures 1" + carp: "test --seed 0 --max-failures 1 --trace" ] end diff --git a/mix.lock b/mix.lock index 48c18e9..0dbf0df 100644 --- a/mix.lock +++ b/mix.lock @@ -1,20 +1,20 @@ %{ "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, - "credo": {:hex, :credo, "1.7.7", "771445037228f763f9b2afd612b6aa2fd8e28432a95dbbc60d8e03ce71ba4446", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8bc87496c9aaacdc3f90f01b7b0582467b69b4bd2441fe8aae3109d843cc2f2e"}, - "dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"}, + "credo": {:hex, :credo, "1.7.11", "d3e805f7ddf6c9c854fd36f089649d7cf6ba74c42bc3795d587814e3c9847102", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "56826b4306843253a66e47ae45e98e7d284ee1f95d53d1612bb483f88a8cf219"}, + "dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.42", "f23d856f41919f17cd06a493923a722d87a2d684f143a1e663c04a2b93100682", [:mix], [], "hexpm", "6915b6ca369b5f7346636a2f41c6a6d78b5af419d61a611079189233358b8b8b"}, "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, - "escape": {:hex, :escape, "0.1.0", "548edab75e6e6938b1e199ef59cb8e504bcfd3bcf83471d4ae9a3c7a7a3c7d45", [:mix], [], "hexpm", "a5d8e92db4677155df54bc1306d401b5233875d570d474201db03cb3047491cd"}, - "ex_doc": {:hex, :ex_doc, "0.34.1", "9751a0419bc15bc7580c73fde506b17b07f6402a1e5243be9e0f05a68c723368", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d441f1a86a235f59088978eff870de2e815e290e44a8bd976fe5d64470a4c9d2"}, - "excoveralls": {:hex, :excoveralls, "0.18.1", "a6f547570c6b24ec13f122a5634833a063aec49218f6fff27de9df693a15588c", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "d65f79db146bb20399f23046015974de0079668b9abb2f5aac074d078da60b8d"}, - "file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"}, - "glob_ex": {:hex, :glob_ex, "0.1.7", "eae6b6377147fb712ac45b360e6dbba00346689a87f996672fe07e97d70597b1", [:mix], [], "hexpm", "decc1c21c0c73df3c9c994412716345c1692477b9470e337f628a7e08da0da6a"}, - "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, - "makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"}, - "makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"}, + "escape": {:hex, :escape, "0.2.0", "346fced73c28087a42288e164df56ca5ee2966ce2a355b8c6a507a8dbe077353", [:mix], [], "hexpm", "a6fee4fd8c42c85379187edc4b6c69f027fed828ea14283b162bf0e124f6bc8e"}, + "ex_doc": {:hex, :ex_doc, "0.36.1", "4197d034f93e0b89ec79fac56e226107824adcce8d2dd0a26f5ed3a95efc36b1", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d7d26a7cf965dacadcd48f9fa7b5953d7d0cfa3b44fa7a65514427da44eafd89"}, + "excoveralls": {:hex, :excoveralls, "0.18.3", "bca47a24d69a3179951f51f1db6d3ed63bca9017f476fe520eb78602d45f7756", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "746f404fcd09d5029f1b211739afb8fb8575d775b21f6a3908e7ce3e640724c6"}, + "file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"}, + "glob_ex": {:hex, :glob_ex, "0.1.11", "cb50d3f1ef53f6ca04d6252c7fde09fd7a1cf63387714fe96f340a1349e62c93", [:mix], [], "hexpm", "342729363056e3145e61766b416769984c329e4378f1d558b63e341020525de4"}, + "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, + "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, + "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, - "recode": {:hex, :recode, "0.7.2", "aa24873b6eb4c90e635ad1f7e12b8e21575a087698bd6bda6e72a82c1298eca1", [:mix], [{:escape, "~> 0.1", [hex: :escape, repo: "hexpm", optional: false]}, {:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:rewrite, "~> 0.9", [hex: :rewrite, repo: "hexpm", optional: false]}], "hexpm", "d70fc60aae3c42781ec845515c1ddd4fe55218ed3fd8fe52267d338044ec7fb8"}, + "recode": {:hex, :recode, "0.7.3", "aa14fda1ba7771c4d9f393bb5ee5b3ea8ec87e983b3f0032435ffca647123a10", [:mix], [{:escape, "~> 0.1", [hex: :escape, repo: "hexpm", optional: false]}, {:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:rewrite, "~> 0.9", [hex: :rewrite, repo: "hexpm", optional: false]}], "hexpm", "c58cf50ff099b7655dc423b35177dccdbfad9645a2639f7e80a5e340d9c36fd8"}, "rewrite": {:hex, :rewrite, "0.10.5", "6afadeae0b9d843b27ac6225e88e165884875e0aed333ef4ad3bf36f9c101bed", [:mix], [{:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "51cc347a4269ad3a1e7a2c4122dbac9198302b082f5615964358b4635ebf3d4f"}, - "sourceror": {:hex, :sourceror, "1.3.0", "70ab9e8bf6df085a1effba4b49ad621b7153b065f69ef6cdb82e6088f2026029", [:mix], [], "hexpm", "1794c3ceeca4eb3f9437261721e4d9cbf846d7c64c7aee4f64062b18d5ce1eac"}, + "sourceror": {:hex, :sourceror, "1.7.1", "599d78f4cc2be7d55c9c4fd0a8d772fd0478e3a50e726697c20d13d02aa056d4", [:mix], [], "hexpm", "cd6f268fe29fa00afbc535e215158680a0662b357dc784646d7dff28ac65a0fc"}, } diff --git a/test/fixtures/1.17.2/atom_ast.exs b/test/fixtures/1.17.3/atom_ast.exs similarity index 100% rename from test/fixtures/1.17.2/atom_ast.exs rename to test/fixtures/1.17.3/atom_ast.exs diff --git a/test/fixtures/1.17.2/capture.exs b/test/fixtures/1.17.3/capture.exs similarity index 100% rename from test/fixtures/1.17.2/capture.exs rename to test/fixtures/1.17.3/capture.exs diff --git a/test/fixtures/1.17.2/comps.exs b/test/fixtures/1.17.3/comps.exs similarity index 100% rename from test/fixtures/1.17.2/comps.exs rename to test/fixtures/1.17.3/comps.exs diff --git a/test/fixtures/1.17.2/comps_ast.exs b/test/fixtures/1.17.3/comps_ast.exs similarity index 100% rename from test/fixtures/1.17.2/comps_ast.exs rename to test/fixtures/1.17.3/comps_ast.exs diff --git a/test/fixtures/1.17.2/math.erl b/test/fixtures/1.17.3/math.erl similarity index 100% rename from test/fixtures/1.17.2/math.erl rename to test/fixtures/1.17.3/math.erl diff --git a/test/fixtures/1.17.2/math.exs b/test/fixtures/1.17.3/math.exs similarity index 100% rename from test/fixtures/1.17.2/math.exs rename to test/fixtures/1.17.3/math.exs diff --git a/test/fixtures/1.17.2/math_abstract_code.exs b/test/fixtures/1.17.3/math_abstract_code.exs similarity index 100% rename from test/fixtures/1.17.2/math_abstract_code.exs rename to test/fixtures/1.17.3/math_abstract_code.exs diff --git a/test/fixtures/1.17.2/math_debug_info.exs b/test/fixtures/1.17.3/math_debug_info.exs similarity index 100% rename from test/fixtures/1.17.2/math_debug_info.exs rename to test/fixtures/1.17.3/math_debug_info.exs diff --git a/test/fixtures/1.17.2/math_docs.exs b/test/fixtures/1.17.3/math_docs.exs similarity index 100% rename from test/fixtures/1.17.2/math_docs.exs rename to test/fixtures/1.17.3/math_docs.exs diff --git a/test/fixtures/1.17.2/math_without_docs.exs b/test/fixtures/1.17.3/math_without_docs.exs similarity index 100% rename from test/fixtures/1.17.2/math_without_docs.exs rename to test/fixtures/1.17.3/math_without_docs.exs diff --git a/test/fixtures/1.17.2/multi_when.exs b/test/fixtures/1.17.3/multi_when.exs similarity index 100% rename from test/fixtures/1.17.2/multi_when.exs rename to test/fixtures/1.17.3/multi_when.exs diff --git a/test/fixtures/1.18.1/atom_ast.exs b/test/fixtures/1.18.1/atom_ast.exs new file mode 100644 index 0000000..ffd59d8 --- /dev/null +++ b/test/fixtures/1.18.1/atom_ast.exs @@ -0,0 +1,19 @@ +{:defmodule, [context: Elixir, import: Kernel], + [ + {:__aliases__, [alias: false], [Atom]}, + [ + do: + {:__block__, [], + [ + {:def, [line: 2, column: 7], + [ + {:from, [], [{:string, [version: 0, line: 2, column: 12], nil}]}, + [ + do: + {{:., [line: 3, column: 11], [:erlang, :binary_to_atom]}, [line: 3, column: 12], + [{:string, [version: 0, line: 3, column: 20], nil}]} + ] + ]} + ]} + ] + ]} diff --git a/test/fixtures/1.18.1/capture.exs b/test/fixtures/1.18.1/capture.exs new file mode 100644 index 0000000..83e6db5 --- /dev/null +++ b/test/fixtures/1.18.1/capture.exs @@ -0,0 +1,9 @@ +defmodule Elixir.Capture do + def fun do + fn capture3, capture4 -> :erlang.+(:erlang.*(capture3, capture4), capture3) end + end + + def double do + fn capture5 -> :erlang.+(capture5, capture5) end + end +end diff --git a/test/fixtures/1.18.1/comps.exs b/test/fixtures/1.18.1/comps.exs new file mode 100644 index 0000000..aec673b --- /dev/null +++ b/test/fixtures/1.18.1/comps.exs @@ -0,0 +1,55 @@ +defmodule Elixir.Comps do + def one do + for n <- [1, 2, 3], into: [], do: :erlang.*(n, n) + end + + def two do + for n <- [1, 2, 3], into: [], do: :erlang.*(n, n) + end + + def three do + for n <- [1, 2, 3], into: %{}, do: {n, :erlang.*(n, n)} + end + + def four do + for i <- [1, 2, 3], n <- [1, 2, 3], into: %{}, do: {i, n} + end + + def five do + for <<(<> <- "abcabc")>>, uniq: true, into: "", do: <<:erlang.-(x, 32)>> + end + + def six do + for <<(<> <- "AbCabCABc")>>, + :erlang.andalso( + :erlang.is_integer(x), + :erlang.andalso(:erlang.>=(x, 97), :erlang."=<"(x, 122)) + ), + reduce: %{}, + do: (acc -> Map.update(acc, <>, 1, fn capture15 -> :erlang.+(capture15, 1) end)) + end + + def seven do + :erlang.++(for(x <- [1, 2], into: [], do: x), for(y <- [3, 4], into: [], do: y)) + end + + def eight do + :erlang.--(for(x <- [1, 2], into: [], do: x), for(y <- [3, 4], into: [], do: y)) + end + + def nine(list) do + :erlang.++(list, Enum.sort(for x <- [1, 2], into: [], do: x)) + end + + def ten(list) do + :erlang.++(list, Enum.sort(for x <- [1, 2], into: [], do: x)) + end + + def eleven(list) do + :erlang.--(list, Enum.sort(for x <- [1, 2], into: [], do: x)) + end + + def users(users) do + for {type, name} when :erlang."/="(type, :guest) <- users, into: [], do: String.upcase(name) + end +end diff --git a/test/fixtures/1.18.1/comps_ast.exs b/test/fixtures/1.18.1/comps_ast.exs new file mode 100644 index 0000000..9cdefb1 --- /dev/null +++ b/test/fixtures/1.18.1/comps_ast.exs @@ -0,0 +1,574 @@ +{ + :defmodule, + [context: Elixir, import: Kernel], + [ + {:__aliases__, [alias: false], [Comps]}, + [ + do: { + :__block__, + [], + [ + { + :def, + [{:line, 2}, {:column, 7}], + [ + {:one, [], Elixir}, + [ + do: { + :for, + [{:line, 3}, {:column, 5}], + [ + { + :<-, + [{:line, 3}, {:column, 11}], + [{:n, [{:version, 0}, {:line, 3}, {:column, 9}], nil}, [1, 2, 3]] + }, + [ + into: [], + do: { + {:., [{:line, 3}, {:column, 31}], [:erlang, :*]}, + [{:line, 3}, {:column, 31}], + [ + {:n, [{:version, 0}, {:line, 3}, {:column, 29}], nil}, + {:n, [{:version, 0}, {:line, 3}, {:column, 33}], nil} + ] + } + ] + ] + } + ] + ] + }, + { + :def, + [{:line, 6}, {:column, 7}], + [ + {:two, [], Elixir}, + [ + do: { + :for, + [{:line, 7}, {:column, 5}], + [ + { + :<-, + [{:line, 7}, {:column, 11}], + [{:n, [{:version, 0}, {:line, 7}, {:column, 9}], nil}, [1, 2, 3]] + }, + [ + into: [], + do: { + {:., [{:line, 7}, {:column, 41}], [:erlang, :*]}, + [{:line, 7}, {:column, 41}], + [ + {:n, [{:version, 0}, {:line, 7}, {:column, 39}], nil}, + {:n, [{:version, 0}, {:line, 7}, {:column, 43}], nil} + ] + } + ] + ] + } + ] + ] + }, + { + :def, + [{:line, 10}, {:column, 7}], + [ + {:three, [], Elixir}, + [ + do: { + :for, + [{:line, 11}, {:column, 5}], + [ + { + :<-, + [{:line, 11}, {:column, 11}], + [{:n, [{:version, 0}, {:line, 11}, {:column, 9}], nil}, [1, 2, 3]] + }, + [ + into: {:%{}, [{:line, 11}, {:column, 31}], []}, + do: { + {:n, [{:version, 0}, {:line, 11}, {:column, 41}], nil}, + { + {:., [{:line, 11}, {:column, 46}], [:erlang, :*]}, + [{:line, 11}, {:column, 46}], + [ + {:n, [{:version, 0}, {:line, 11}, {:column, 44}], nil}, + {:n, [{:version, 0}, {:line, 11}, {:column, 48}], nil} + ] + } + } + ] + ] + } + ] + ] + }, + { + :def, + [{:line, 14}, {:column, 7}], + [ + {:four, [], Elixir}, + [ + do: { + :for, + [{:line, 15}, {:column, 5}], + [ + { + :<-, + [{:line, 15}, {:column, 11}], + [{:i, [{:version, 0}, {:line, 15}, {:column, 9}], nil}, [1, 2, 3]] + }, + { + :<-, + [{:line, 16}, {:column, 11}], + [{:n, [{:version, 1}, {:line, 16}, {:column, 9}], nil}, [1, 2, 3]] + }, + [ + into: {:%{}, [{:line, 17}, {:column, 15}], []}, + do: { + {:i, [{:version, 0}, {:line, 18}, {:column, 14}], nil}, + {:n, [{:version, 1}, {:line, 18}, {:column, 17}], nil} + } + ] + ] + } + ] + ] + }, + { + :def, + [{:line, 21}, {:column, 7}], + [ + {:five, [], Elixir}, + [ + do: { + :for, + [{:line, 22}, {:column, 5}], + [ + { + :<<>>, + [{:line, 22}, {:column, 9}], + [ + { + :<-, + [{:line, 22}, {:column, 13}], + [ + { + :<<>>, + [{:alignment, 0}, {:line, 22}, {:column, 9}], + [ + { + :"::", + [{:inferred_bitstring_spec, true}, {:line, 22}, {:column, 11}], + [ + {:x, [{:version, 0}, {:line, 22}, {:column, 11}], nil}, + {:integer, [{:line, 22}, {:column, 11}], nil} + ] + } + ] + }, + "abcabc" + ] + } + ] + }, + [ + uniq: true, + into: "", + do: { + :<<>>, + [{:alignment, 0}, {:line, 22}, {:column, 54}], + [ + { + :"::", + [{:inferred_bitstring_spec, true}, {:line, 22}, {:column, 58}], + [ + { + {:., [{:line, 22}, {:column, 58}], [:erlang, :-]}, + [{:line, 22}, {:column, 58}], + [{:x, [{:version, 0}, {:line, 22}, {:column, 56}], nil}, 32] + }, + {:integer, [{:line, 22}, {:column, 58}], nil} + ] + } + ] + } + ] + ] + } + ] + ] + }, + { + :def, + [{:line, 25}, {:column, 7}], + [ + {:six, [], Elixir}, + [ + do: { + :for, + [{:line, 26}, {:column, 5}], + [ + { + :<<>>, + [{:line, 26}, {:column, 9}], + [ + { + :<-, + [{:line, 26}, {:column, 13}], + [ + { + :<<>>, + [{:alignment, 0}, {:line, 26}, {:column, 9}], + [ + { + :"::", + [{:inferred_bitstring_spec, true}, {:line, 26}, {:column, 11}], + [ + {:x, [{:version, 0}, {:line, 26}, {:column, 11}], nil}, + {:integer, [{:line, 26}, {:column, 11}], nil} + ] + } + ] + }, + "AbCabCABc" + ] + } + ] + }, + { + {:., [line: 26], [:erlang, :andalso]}, + [line: 26], + [ + { + {:., [line: 26], [:erlang, :is_integer]}, + [line: 26], + [{:x, [{:version, 0}, {:line, 26}, {:column, 31}], nil}] + }, + { + {:., [line: 26], [:erlang, :andalso]}, + [line: 26], + [ + { + {:., [line: 26], [:erlang, :>=]}, + [line: 26], + [{:x, [{:version, 0}, {:line, 26}, {:column, 31}], nil}, 97] + }, + { + {:., [line: 26], [:erlang, :"=<"]}, + [line: 26], + [{:x, [{:version, 0}, {:line, 26}, {:column, 31}], nil}, 122] + } + ] + } + ] + }, + [ + reduce: {:%{}, [{:line, 26}, {:column, 52}], []}, + do: [ + { + :->, + [{:line, 27}, {:column, 11}], + [ + [{:acc, [{:version, 1}, {:line, 27}, {:column, 7}], nil}], + { + {:., [{:line, 27}, {:column, 17}], [Map, :update]}, + [{:line, 27}, {:column, 18}], + [ + {:acc, [{:version, 1}, {:line, 27}, {:column, 25}], nil}, + { + :<<>>, + [{:alignment, 0}, {:line, 27}, {:column, 30}], + [ + { + :"::", + [ + {:inferred_bitstring_spec, true}, + {:line, 27}, + {:column, 32} + ], + [ + {:x, [{:version, 0}, {:line, 27}, {:column, 32}], nil}, + {:integer, [{:line, 27}, {:column, 32}], nil} + ] + } + ] + }, + 1, + { + :fn, + [{:line, 27}, {:column, 45}], + [ + { + :->, + [{:line, 27}, {:column, 45}], + [ + [ + {:capture, + [ + version: 2, + counter: {Comps, 15}, + line: 27, + column: 42 + ], nil} + ], + { + {:., [{:line, 27}, {:column, 45}], [:erlang, :+]}, + [{:line, 27}, {:column, 45}], + [ + {:capture, + [ + version: 2, + counter: {Comps, 15}, + line: 27, + column: 42 + ], nil}, + 1 + ] + } + ] + } + ] + } + ] + } + ] + } + ] + ] + ] + } + ] + ] + }, + { + :def, + [{:line, 31}, {:column, 7}], + [ + {:seven, [], Elixir}, + [ + do: { + {:., [{:line, 32}, {:column, 29}], [:erlang, :++]}, + [{:line, 32}, {:column, 29}], + [ + { + :for, + [{:line, 32}, {:column, 5}], + [ + { + :<-, + [{:line, 32}, {:column, 11}], + [{:x, [{:version, 0}, {:line, 32}, {:column, 9}], nil}, [1, 2]] + }, + [into: [], do: {:x, [{:version, 0}, {:line, 32}, {:column, 26}], nil}] + ] + }, + { + :for, + [{:line, 32}, {:column, 32}], + [ + { + :<-, + [{:line, 32}, {:column, 38}], + [{:y, [{:version, 1}, {:line, 32}, {:column, 36}], nil}, [3, 4]] + }, + [into: [], do: {:y, [{:version, 1}, {:line, 32}, {:column, 53}], nil}] + ] + } + ] + } + ] + ] + }, + { + :def, + [{:line, 35}, {:column, 7}], + [ + {:eight, [], Elixir}, + [ + do: { + {:., [{:line, 36}, {:column, 29}], [:erlang, :--]}, + [{:line, 36}, {:column, 29}], + [ + { + :for, + [{:line, 36}, {:column, 5}], + [ + { + :<-, + [{:line, 36}, {:column, 11}], + [{:x, [{:version, 0}, {:line, 36}, {:column, 9}], nil}, [1, 2]] + }, + [into: [], do: {:x, [{:version, 0}, {:line, 36}, {:column, 26}], nil}] + ] + }, + { + :for, + [{:line, 36}, {:column, 32}], + [ + { + :<-, + [{:line, 36}, {:column, 38}], + [{:y, [{:version, 1}, {:line, 36}, {:column, 36}], nil}, [3, 4]] + }, + [into: [], do: {:y, [{:version, 1}, {:line, 36}, {:column, 53}], nil}] + ] + } + ] + } + ] + ] + }, + { + :def, + [{:line, 39}, {:column, 7}], + [ + {:nine, [], [{:list, [{:version, 0}, {:line, 39}, {:column, 12}], nil}]}, + [ + do: { + {:., [{:line, 40}, {:column, 10}], [:erlang, :++]}, + [{:line, 40}, {:column, 10}], + [ + {:list, [{:version, 0}, {:line, 40}, {:column, 5}], nil}, + { + {:., [{:line, 40}, {:column, 17}], [Enum, :sort]}, + [{:line, 40}, {:column, 18}], + [ + { + :for, + [{:line, 40}, {:column, 23}], + [ + { + :<-, + [{:line, 40}, {:column, 29}], + [{:x, [{:version, 1}, {:line, 40}, {:column, 27}], nil}, [1, 2]] + }, + [into: [], do: {:x, [{:version, 1}, {:line, 40}, {:column, 44}], nil}] + ] + } + ] + } + ] + } + ] + ] + }, + { + :def, + [{:line, 43}, {:column, 7}], + [ + {:ten, [], [{:list, [{:version, 0}, {:line, 43}, {:column, 11}], nil}]}, + [ + do: { + {:., [{:line, 44}, {:column, 12}], [:erlang, :++]}, + [{:line, 44}, {:column, 13}], + [ + {:list, [{:version, 0}, {:line, 44}, {:column, 16}], nil}, + { + {:., [{:line, 44}, {:column, 26}], [Enum, :sort]}, + [{:line, 44}, {:column, 27}], + [ + { + :for, + [{:line, 44}, {:column, 32}], + [ + { + :<-, + [{:line, 44}, {:column, 38}], + [{:x, [{:version, 1}, {:line, 44}, {:column, 36}], nil}, [1, 2]] + }, + [into: [], do: {:x, [{:version, 1}, {:line, 44}, {:column, 53}], nil}] + ] + } + ] + } + ] + } + ] + ] + }, + { + :def, + [{:line, 47}, {:column, 7}], + [ + {:eleven, [], [{:list, [{:version, 0}, {:line, 47}, {:column, 14}], nil}]}, + [ + do: { + {:., [{:line, 48}, {:column, 12}], [:erlang, :--]}, + [{:line, 48}, {:column, 13}], + [ + {:list, [{:version, 0}, {:line, 48}, {:column, 16}], nil}, + { + {:., [{:line, 48}, {:column, 26}], [Enum, :sort]}, + [{:line, 48}, {:column, 27}], + [ + { + :for, + [{:line, 48}, {:column, 32}], + [ + { + :<-, + [{:line, 48}, {:column, 38}], + [{:x, [{:version, 1}, {:line, 48}, {:column, 36}], nil}, [1, 2]] + }, + [into: [], do: {:x, [{:version, 1}, {:line, 48}, {:column, 53}], nil}] + ] + } + ] + } + ] + } + ] + ] + }, + { + :def, + [{:line, 51}, {:column, 7}], + [ + {:users, [], [{:users, [{:version, 0}, {:line, 51}, {:column, 13}], nil}]}, + [ + do: { + :for, + [{:line, 52}, {:column, 5}], + [ + { + :<-, + [{:line, 52}, {:column, 42}], + [ + { + :when, + [{:line, 52}, {:column, 22}], + [ + { + {:type, [{:version, 1}, {:line, 52}, {:column, 10}], nil}, + {:name, [{:version, 2}, {:line, 52}, {:column, 16}], nil} + }, + { + {:., [{:line, 52}, {:column, 32}], [:erlang, :"/="]}, + [{:line, 52}, {:column, 32}], + [{:type, [{:version, 1}, {:line, 52}, {:column, 27}], nil}, :guest] + } + ] + }, + {:users, [{:version, 0}, {:line, 52}, {:column, 45}], nil} + ] + }, + [ + into: [], + do: { + {:., [{:line, 53}, {:column, 13}], [String, :upcase]}, + [{:line, 53}, {:column, 14}], + [{:name, [{:version, 2}, {:line, 53}, {:column, 21}], nil}] + } + ] + ] + } + ] + ] + } + ] + } + ] + ] +} diff --git a/test/fixtures/1.18.1/math.erl b/test/fixtures/1.18.1/math.erl new file mode 100644 index 0000000..c45b499 --- /dev/null +++ b/test/fixtures/1.18.1/math.erl @@ -0,0 +1,91 @@ +-file("test/fixtures/math.ex", 1). + +-module('Elixir.Math'). + +-compile([no_auto_import]). + +-spec triple(num()) -> x(). + +-spec double(num()) -> x(). + +-spec divide(num(), num()) -> x(). + +-spec add(num() | num_tuple(), num()) -> x(). + +-spec add(num_tuple()) -> x(). + +-type num_tuple() :: {num(), num()}. + +-export_type([x/0]). + +-opaque x() :: num(). + +-export_type([num/0]). + +-type num() :: integer(). + +-export(['MACRO-biggest'/3, + '__info__'/1, + add/2, + divide/2, + double/1, + odd_or_even/1, + pi/0, + triple/1]). + +-spec '__info__'(attributes | + compile | + functions | + macros | + md5 | + exports_md5 | + module | + deprecated | + struct) -> any(). + +'__info__'(module) -> 'Elixir.Math'; +'__info__'(functions) -> + [{add, 2}, + {divide, 2}, + {double, 1}, + {odd_or_even, 1}, + {pi, 0}, + {triple, 1}]; +'__info__'(macros) -> [{biggest, 2}]; +'__info__'(struct) -> nil; +'__info__'(exports_md5) -> + <<"ùÓË\233Ëùï\202$.­o»¸¨\030">>; +'__info__'(Key = attributes) -> + erlang:get_module_info('Elixir.Math', Key); +'__info__'(Key = compile) -> + erlang:get_module_info('Elixir.Math', Key); +'__info__'(Key = md5) -> + erlang:get_module_info('Elixir.Math', Key); +'__info__'(deprecated) -> []. + +add(_nums@1) -> + {_number_a@1, _number_b@1} = _nums@1, + add(_number_a@1, _number_b@1). + +add(_number_a@1, _number_b@1) -> + _number_a@1 + _number_b@1. + +'MACRO-biggest'(_@CALLER, _a@1, _b@1) -> + {max, + [{context, 'Elixir.Math'}, + {imports, [{2, 'Elixir.Kernel'}]}], + [_a@1, _b@1]}. + +divide(_a@1, _b@1) when _b@1 /= 0 -> _a@1 div _b@1. + +double(_number@1) -> add({_number@1, _number@1}). + +odd_or_even(_a@1) -> + case _a@1 rem 2 == 0 of + false -> odd; + true -> even + end. + +pi() -> 'Elixir.Math.Const':pi(). + +triple(_number@1) -> 3 * _number@1. diff --git a/test/fixtures/1.18.1/math.exs b/test/fixtures/1.18.1/math.exs new file mode 100644 index 0000000..fd27e6d --- /dev/null +++ b/test/fixtures/1.18.1/math.exs @@ -0,0 +1,54 @@ +defmodule Elixir.Math do + @moduledoc """ + Math is Fun + """ + + @doc """ + Adds up two numbers. + """ + def add(number_a, number_b) do + :erlang.+(number_a, number_b) + end + + @doc """ + Doubles a number. + """ + def double(number) do + add({number, number}) + end + + @doc """ + Triples a number. + """ + def triple(number) do + :erlang.*(3, number) + end + + defp add(nums) do + {number_a, number_b} = nums + add(number_a, number_b) + end + + def divide(a, b) when :erlang."/="(b, 0) do + :erlang.div(a, b) + end + + @doc """ + Returns the biggest. + """ + defmacro biggest(a, b) do + {:max, [context: Math, imports: [{2, Kernel}]], + [:elixir_quote.shallow_validate_ast(a), :elixir_quote.shallow_validate_ast(b)]} + end + + def odd_or_even(a) do + case :erlang.==(:erlang.rem(a, 2), 0) do + false -> :odd + true -> :even + end + end + + def pi do + Math.Const.pi() + end +end diff --git a/test/fixtures/1.18.1/math_abstract_code.exs b/test/fixtures/1.18.1/math_abstract_code.exs new file mode 100644 index 0000000..f935e22 --- /dev/null +++ b/test/fixtures/1.18.1/math_abstract_code.exs @@ -0,0 +1,474 @@ +{ + :ok, + [ + {:attribute, 1, :file, {~c"test/fixtures/math.ex", 1}}, + {:attribute, 1, :module, Math}, + {:attribute, 1, :compile, [:no_auto_import]}, + { + :attribute, + 33, + :spec, + { + {:triple, 1}, + [ + { + :type, + {33, 23}, + :fun, + [ + {:type, {33, 23}, :product, [{:user_type, {33, 16}, :num, []}]}, + {:user_type, {33, 26}, :x, []} + ] + } + ] + } + }, + { + :attribute, + 27, + :spec, + { + {:double, 1}, + [ + { + :type, + {27, 23}, + :fun, + [ + {:type, {27, 23}, :product, [{:user_type, {27, 16}, :num, []}]}, + {:user_type, {27, 26}, :x, []} + ] + } + ] + } + }, + { + :attribute, + 42, + :spec, + { + {:divide, 2}, + [ + { + :type, + {42, 30}, + :fun, + [ + {:type, {42, 30}, :product, + [{:user_type, {42, 16}, :num, []}, {:user_type, {42, 23}, :num, []}]}, + {:user_type, {42, 33}, :x, []} + ] + } + ] + } + }, + { + :attribute, + 19, + :spec, + { + {:add, 2}, + [ + { + :type, + {19, 41}, + :fun, + [ + { + :type, + {19, 41}, + :product, + [ + { + :type, + {19, 19}, + :union, + [{:user_type, {19, 13}, :num, []}, {:user_type, {19, 21}, :num_tuple, []}] + }, + {:user_type, {19, 34}, :num, []} + ] + }, + {:user_type, {19, 44}, :x, []} + ] + } + ] + } + }, + { + :attribute, + 36, + :spec, + { + {:add, 1}, + [ + { + :type, + {36, 26}, + :fun, + [ + {:type, {36, 26}, :product, [{:user_type, {36, 13}, :num_tuple, []}]}, + {:user_type, {36, 29}, :x, []} + ] + } + ] + } + }, + { + :attribute, + 12, + :type, + { + :num_tuple, + {:type, 0, :tuple, [{:user_type, {12, 24}, :num, []}, {:user_type, {12, 31}, :num, []}]}, + [] + } + }, + {:attribute, 10, :export_type, [x: 0]}, + {:attribute, 10, :opaque, {:x, {:user_type, {10, 16}, :num, []}, []}}, + {:attribute, 9, :export_type, [num: 0]}, + {:attribute, 9, :type, {:num, {:type, {9, 16}, :integer, []}, []}}, + { + :attribute, + 1, + :export, + [ + "MACRO-biggest": 3, + __info__: 1, + add: 2, + divide: 2, + double: 1, + odd_or_even: 1, + pi: 0, + triple: 1 + ] + }, + { + :attribute, + 1, + :spec, + { + {:__info__, 1}, + [ + { + :type, + 1, + :fun, + [ + { + :type, + 1, + :product, + [ + { + :type, + 1, + :union, + [ + {:atom, 1, :attributes}, + {:atom, 1, :compile}, + {:atom, 1, :functions}, + {:atom, 1, :macros}, + {:atom, 1, :md5}, + {:atom, 1, :exports_md5}, + {:atom, 1, :module}, + {:atom, 1, :deprecated}, + {:atom, 1, :struct} + ] + } + ] + }, + {:type, 1, :any, []} + ] + } + ] + } + }, + { + :function, + 0, + :__info__, + 1, + [ + {:clause, 0, [{:atom, 0, :module}], [], [{:atom, 0, Math}]}, + { + :clause, + 0, + [{:atom, 0, :functions}], + [], + [ + { + :cons, + 0, + {:tuple, 0, [{:atom, 0, :add}, {:integer, 0, 2}]}, + { + :cons, + 0, + {:tuple, 0, [{:atom, 0, :divide}, {:integer, 0, 2}]}, + { + :cons, + 0, + {:tuple, 0, [{:atom, 0, :double}, {:integer, 0, 1}]}, + { + :cons, + 0, + {:tuple, 0, [{:atom, 0, :odd_or_even}, {:integer, 0, 1}]}, + { + :cons, + 0, + {:tuple, 0, [{:atom, 0, :pi}, {:integer, 0, 0}]}, + {:cons, 0, {:tuple, 0, [{:atom, 0, :triple}, {:integer, 0, 1}]}, {nil, 0}} + } + } + } + } + } + ] + }, + { + :clause, + 0, + [{:atom, 0, :macros}], + [], + [{:cons, 0, {:tuple, 0, [{:atom, 0, :biggest}, {:integer, 0, 2}]}, {nil, 0}}] + }, + {:clause, 0, [{:atom, 0, :struct}], [], [{:atom, 0, nil}]}, + { + :clause, + 0, + [{:atom, 0, :exports_md5}], + [], + [ + { + :bin, + 0, + [ + { + :bin_element, + 0, + {:string, 0, + [249, 211, 203, 155, 203, 249, 239, 130, 36, 46, 173, 111, 187, 184, 168, 24]}, + :default, + :default + } + ] + } + ] + }, + { + :clause, + 0, + [{:match, 0, {:var, 0, :Key}, {:atom, 0, :attributes}}], + [], + [ + { + :call, + 0, + {:remote, 0, {:atom, 0, :erlang}, {:atom, 0, :get_module_info}}, + [{:atom, 0, Math}, {:var, 0, :Key}] + } + ] + }, + { + :clause, + 0, + [{:match, 0, {:var, 0, :Key}, {:atom, 0, :compile}}], + [], + [ + { + :call, + 0, + {:remote, 0, {:atom, 0, :erlang}, {:atom, 0, :get_module_info}}, + [{:atom, 0, Math}, {:var, 0, :Key}] + } + ] + }, + { + :clause, + 0, + [{:match, 0, {:var, 0, :Key}, {:atom, 0, :md5}}], + [], + [ + { + :call, + 0, + {:remote, 0, {:atom, 0, :erlang}, {:atom, 0, :get_module_info}}, + [{:atom, 0, Math}, {:var, 0, :Key}] + } + ] + }, + {:clause, 0, [{:atom, 0, :deprecated}], [], [nil: 0]} + ] + }, + { + :function, + 37, + :add, + 1, + [ + { + :clause, + 37, + [{:var, 37, :_nums@1}], + [], + [ + { + :match, + 38, + {:tuple, 38, [{:var, 38, :_number_a@1}, {:var, 38, :_number_b@1}]}, + {:var, 38, :_nums@1} + }, + {:call, 39, {:atom, 39, :add}, [{:var, 39, :_number_a@1}, {:var, 39, :_number_b@1}]} + ] + } + ] + }, + { + :function, + 20, + :add, + 2, + [ + { + :clause, + 20, + [{:var, 20, :_number_a@1}, {:var, 20, :_number_b@1}], + [], + [{:op, 21, :+, {:var, 21, :_number_a@1}, {:var, 21, :_number_b@1}}] + } + ] + }, + { + :function, + 50, + :"MACRO-biggest", + 3, + [ + { + :clause, + 50, + [{:var, 50, :_@CALLER}, {:var, 50, :_a@1}, {:var, 50, :_b@1}], + [], + [ + { + :tuple, + 0, + [ + {:atom, 0, :max}, + { + :cons, + 0, + {:tuple, 0, [{:atom, 0, :context}, {:atom, 0, Math}]}, + { + :cons, + 0, + { + :tuple, + 0, + [ + {:atom, 0, :imports}, + {:cons, 0, {:tuple, 0, [{:integer, 0, 2}, {:atom, 0, Kernel}]}, {nil, 0}} + ] + }, + {nil, 0} + } + }, + {:cons, 0, {:var, 52, :_a@1}, {:cons, 0, {:var, 52, :_b@1}, {nil, 0}}} + ] + } + ] + } + ] + }, + { + :function, + 43, + :divide, + 2, + [ + { + :clause, + 43, + [{:var, 43, :_a@1}, {:var, 43, :_b@1}], + [[{:op, 43, :"/=", {:var, 43, :_b@1}, {:integer, 43, 0}}]], + [{:op, 44, :div, {:var, 44, :_a@1}, {:var, 44, :_b@1}}] + } + ] + }, + { + :function, + 28, + :double, + 1, + [ + { + :clause, + 28, + [{:var, 28, :_number@1}], + [], + [ + {:call, 28, {:atom, 28, :add}, + [{:tuple, 28, [{:var, 28, :_number@1}, {:var, 28, :_number@1}]}]} + ] + } + ] + }, + { + :function, + 56, + :odd_or_even, + 1, + [ + { + :clause, + 56, + [{:var, 56, :_a@1}], + [], + [ + { + :case, + 57, + {:op, 57, :==, {:op, 57, :rem, {:var, 57, :_a@1}, {:integer, 57, 2}}, + {:integer, 57, 0}}, + [ + { + :clause, + [generated: true, location: 57], + [{:atom, [generated: true, location: 57], false}], + [], + [{:atom, [generated: true, location: 57], :odd}] + }, + { + :clause, + [generated: true, location: 57], + [{:atom, [generated: true, location: 57], true}], + [], + [{:atom, [generated: true, location: 57], :even}] + } + ] + } + ] + } + ] + }, + { + :function, + 64, + :pi, + 0, + [ + {:clause, 64, [], [], + [{:call, 64, {:remote, 64, {:atom, 64, Math.Const}, {:atom, 64, :pi}}, []}]} + ] + }, + { + :function, + 34, + :triple, + 1, + [ + {:clause, 34, [{:var, 34, :_number@1}], [], + [{:op, 34, :*, {:integer, 34, 3}, {:var, 34, :_number@1}}]} + ] + } + ] +} diff --git a/test/fixtures/1.18.1/math_debug_info.exs b/test/fixtures/1.18.1/math_debug_info.exs new file mode 100644 index 0000000..ad072b1 --- /dev/null +++ b/test/fixtures/1.18.1/math_debug_info.exs @@ -0,0 +1,206 @@ +{:ok, + {:debug_info_v1, :elixir_erl, + {:elixir_v1, + %{ + attributes: [], + module: Math, + file: "/Users/kruse/Projects/hrzndhrn/beam_file/test/fixtures/math.ex", + deprecated: [], + unreachable: [], + anno: {1, 1}, + struct: nil, + after_verify: [], + defines_behaviour: false, + definitions: [ + {{:triple, 1}, :def, [line: 34, column: 7], + [ + {[line: 34, column: 7], [{:number, [version: 0, line: 34, column: 14], nil}], [], + {{:., [line: 34, column: 34], [:erlang, :*]}, [line: 34, column: 34], + [3, {:number, [version: 0, line: 34, column: 36], nil}]}} + ]}, + {{:pi, 0}, :def, [line: 64, column: 7], + [ + {[line: 64, column: 7], [], [], + {{:., [line: 64, column: 20], [Math.Const, :pi]}, [line: 64, column: 21], []}} + ]}, + {{:odd_or_even, 1}, :def, [line: 56, column: 7], + [ + {[line: 56, column: 7], [{:a, [version: 0, line: 56, column: 19], nil}], [], + {:case, [line: 57, optimize_boolean: true], + [ + {{:., [line: 57, column: 18], [:erlang, :==]}, [line: 57, column: 18], + [ + {{:., [line: 57, column: 8], [:erlang, :rem]}, [line: 57, column: 8], + [{:a, [version: 0, line: 57, column: 12], nil}, 2]}, + 0 + ]}, + [ + do: [ + {:->, [line: 57], [[false], :odd]}, + {:->, [line: 57], [[true], :even]} + ] + ] + ]}} + ]}, + {{:double, 1}, :def, [line: 28, column: 7], + [ + {[line: 28, column: 7], [{:number, [version: 0, line: 28, column: 14], nil}], [], + {:add, [line: 28, column: 27], + [ + {{:number, [version: 0, line: 28, column: 32], nil}, + {:number, [version: 0, line: 28, column: 40], nil}} + ]}} + ]}, + {{:divide, 2}, :def, [line: 43, column: 7], + [ + {[line: 43, column: 7], + [ + {:a, [version: 0, line: 43, column: 14], nil}, + {:b, [version: 1, line: 43, column: 17], nil} + ], + [ + {{:., [line: 43, column: 27], [:erlang, :"/="]}, [line: 43, column: 27], + [{:b, [version: 1, line: 43, column: 25], nil}, 0]} + ], + {{:., [line: 44, column: 5], [:erlang, :div]}, [line: 44, column: 5], + [ + {:a, [version: 0, line: 44, column: 9], nil}, + {:b, [version: 1, line: 44, column: 12], nil} + ]}} + ]}, + {{:biggest, 2}, :defmacro, [line: 50, column: 12], + [ + {[line: 50, column: 12], + [ + {:a, [version: 0, line: 50, column: 20], nil}, + {:b, [version: 1, line: 50, column: 23], nil} + ], [], + {:{}, [], + [ + :max, + [context: Math, imports: [{2, Kernel}]], + [ + {{:., [line: 52, column: 11], [:elixir_quote, :shallow_validate_ast]}, + [line: 52, column: 11], [{:a, [version: 0, line: 52, column: 19], nil}]}, + {{:., [line: 52, column: 23], [:elixir_quote, :shallow_validate_ast]}, + [line: 52, column: 23], [{:b, [version: 1, line: 52, column: 31], nil}]} + ] + ]}} + ]}, + {{:add, 2}, :def, [line: 20, column: 7], + [ + {[line: 20, column: 7], + [ + {:number_a, [version: 0, line: 20, column: 11], nil}, + {:number_b, [version: 1, line: 20, column: 21], nil} + ], [], + {{:., [line: 21, column: 14], [:erlang, :+]}, [line: 21, column: 14], + [ + {:number_a, [version: 0, line: 21, column: 5], nil}, + {:number_b, [version: 1, line: 21, column: 16], nil} + ]}} + ]}, + {{:add, 1}, :defp, [line: 37, column: 8], + [ + {[line: 37, column: 8], [{:nums, [version: 0, line: 37, column: 12], nil}], [], + {:__block__, [], + [ + {:=, [line: 38, column: 26], + [ + {{:number_a, [version: 1, line: 38, column: 6], nil}, + {:number_b, [version: 2, line: 38, column: 16], nil}}, + {:nums, [version: 0, line: 38, column: 28], nil} + ]}, + {:add, [line: 39, column: 5], + [ + {:number_a, [version: 1, line: 39, column: 9], nil}, + {:number_b, [version: 2, line: 39, column: 19], nil} + ]} + ]}} + ]} + ], + signatures: %{ + {:add, 2} => + {:infer, [{[%{dynamic: :term}, %{dynamic: :term}], %{dynamic: %{bitmap: 12}}}]}, + {:divide, 2} => + {:infer, [{[%{dynamic: :term}, %{dynamic: :term}], %{dynamic: %{bitmap: 4}}}]}, + {:double, 1} => {:infer, [{[%{dynamic: :term}], %{dynamic: %{bitmap: 12}}}]}, + {:odd_or_even, 1} => + {:infer, + [ + {[%{dynamic: :term}], %{dynamic: %{atom: {:union, %{even: [], odd: []}}}}} + ]}, + {:pi, 0} => {:infer, [{[], %{dynamic: :term}}]}, + {:triple, 1} => {:infer, [{[%{dynamic: :term}], %{dynamic: %{bitmap: 12}}}]} + }, + impls: [], + compile_opts: [], + relative_file: "test/fixtures/math.ex" + }, + [ + {:attribute, 33, :spec, + {{:triple, 1}, + [ + {:type, {33, 9}, :fun, + [ + {:type, {33, 9}, :product, [{:user_type, {33, 16}, :num, []}]}, + {:user_type, {33, 26}, :x, []} + ]} + ]}}, + {:attribute, 27, :spec, + {{:double, 1}, + [ + {:type, {27, 9}, :fun, + [ + {:type, {27, 9}, :product, [{:user_type, {27, 16}, :num, []}]}, + {:user_type, {27, 26}, :x, []} + ]} + ]}}, + {:attribute, 42, :spec, + {{:divide, 2}, + [ + {:type, {42, 9}, :fun, + [ + {:type, {42, 9}, :product, + [ + {:user_type, {42, 16}, :num, []}, + {:user_type, {42, 23}, :num, []} + ]}, + {:user_type, {42, 33}, :x, []} + ]} + ]}}, + {:attribute, 19, :spec, + {{:add, 2}, + [ + {:type, {19, 9}, :fun, + [ + {:type, {19, 9}, :product, + [ + {:type, {19, 19}, :union, + [ + {:user_type, {19, 13}, :num, []}, + {:user_type, {19, 21}, :num_tuple, []} + ]}, + {:user_type, {19, 34}, :num, []} + ]}, + {:user_type, {19, 44}, :x, []} + ]} + ]}}, + {:attribute, 36, :spec, + {{:add, 1}, + [ + {:type, {36, 9}, :fun, + [ + {:type, {36, 9}, :product, [{:user_type, {36, 13}, :num_tuple, []}]}, + {:user_type, {36, 29}, :x, []} + ]} + ]}}, + {:attribute, 12, :type, + {:num_tuple, + {:type, 0, :tuple, [{:user_type, {12, 24}, :num, []}, {:user_type, {12, 31}, :num, []}]}, + []}}, + {:attribute, 10, :export_type, [x: 0]}, + {:attribute, 10, :opaque, {:x, {:user_type, {10, 16}, :num, []}, []}}, + {:attribute, 9, :export_type, [num: 0]}, + {:attribute, 9, :type, {:num, {:type, {9, 16}, :integer, []}, []}} + ]}}} diff --git a/test/fixtures/1.18.1/math_docs.exs b/test/fixtures/1.18.1/math_docs.exs new file mode 100644 index 0000000..9feb35c --- /dev/null +++ b/test/fixtures/1.18.1/math_docs.exs @@ -0,0 +1,22 @@ +{:ok, + {%{"en" => "Math is Fun\n"}, + %{ + behaviours: [], + source_annos: [{1, 1}], + source_path: ~c"/Users/kruse/Projects/hrzndhrn/beam_file/test/fixtures/math.ex" + }, + [ + {{:function, :add, 2}, 16, ["add(number_a, number_b)"], %{"en" => "Adds up two numbers.\n"}, + %{source_annos: [{20, 7}]}}, + {{:function, :divide, 2}, 43, ["divide(a, b)"], :none, %{source_annos: [{43, 7}]}}, + {{:function, :double, 1}, 24, ["double(number)"], %{"en" => "Doubles a number.\n"}, + %{source_annos: [{28, 7}]}}, + {{:function, :odd_or_even, 1}, 56, ["odd_or_even(a)"], :none, %{source_annos: [{56, 7}]}}, + {{:function, :pi, 0}, 64, ["pi()"], :none, %{source_annos: [{64, 7}]}}, + {{:function, :triple, 1}, 30, ["triple(number)"], %{"en" => "Triples a number.\n"}, + %{source_annos: [{34, 7}]}}, + {{:macro, :biggest, 2}, 47, ["biggest(a, b)"], %{"en" => "Returns the biggest.\n"}, + %{source_annos: [{50, 12}]}}, + {{:type, :num, 0}, 8, [], %{"en" => "number"}, %{source_annos: [{9, 9}]}}, + {{:type, :x, 0}, 10, [], :none, %{opaque: true, source_annos: [{10, 11}]}} + ]}} diff --git a/test/fixtures/1.18.1/math_without_docs.exs b/test/fixtures/1.18.1/math_without_docs.exs new file mode 100644 index 0000000..33558c1 --- /dev/null +++ b/test/fixtures/1.18.1/math_without_docs.exs @@ -0,0 +1,38 @@ +defmodule Elixir.Math do + def add(number_a, number_b) do + :erlang.+(number_a, number_b) + end + + def double(number) do + add({number, number}) + end + + def triple(number) do + :erlang.*(3, number) + end + + defp add(nums) do + {number_a, number_b} = nums + add(number_a, number_b) + end + + def divide(a, b) when :erlang."/="(b, 0) do + :erlang.div(a, b) + end + + defmacro biggest(a, b) do + {:max, [context: Math, imports: [{2, Kernel}]], + [:elixir_quote.shallow_validate_ast(a), :elixir_quote.shallow_validate_ast(b)]} + end + + def odd_or_even(a) do + case :erlang.==(:erlang.rem(a, 2), 0) do + false -> :odd + true -> :even + end + end + + def pi do + Math.Const.pi() + end +end diff --git a/test/fixtures/1.18.1/multi_when.exs b/test/fixtures/1.18.1/multi_when.exs new file mode 100644 index 0000000..a651df9 --- /dev/null +++ b/test/fixtures/1.18.1/multi_when.exs @@ -0,0 +1,13 @@ +defmodule Elixir.MultiWhen do + def call(x) when :erlang.>(x, 0) when :erlang.<(x, 0) do + x + end + + def call2(x) + when :erlang.>(x, 0) + when :erlang.<(x, 0) + when :erlang.<(x, 10) + when :erlang.>(x, -10) do + x + end +end