diff --git a/lib/elixir_analyzer/test_suite/two_fer.ex b/lib/elixir_analyzer/test_suite/two_fer.ex index 3ce8d935..501d83a8 100644 --- a/lib/elixir_analyzer/test_suite/two_fer.ex +++ b/lib/elixir_analyzer/test_suite/two_fer.ex @@ -45,19 +45,19 @@ defmodule ElixirAnalyzer.TestSuite.TwoFer do # function header form do - def two_fer(_ignore \\ "you") + def two_fer(_ignore \\ _ignore) end # function without a guard and with a do block form do - def two_fer(_ignore \\ "you") do + def two_fer(_ignore \\ _ignore) do _ignore end end # function with do block form do - def two_fer(_ignore \\ "you") when _ignore do + def two_fer(_ignore \\ _ignore) when _ignore do _ignore end end diff --git a/test/elixir_analyzer/test_suite/two_fer_test.exs b/test/elixir_analyzer/test_suite/two_fer_test.exs index 3cfc41be..c366d99a 100644 --- a/test/elixir_analyzer/test_suite/two_fer_test.exs +++ b/test/elixir_analyzer/test_suite/two_fer_test.exs @@ -91,9 +91,6 @@ defmodule ElixirAnalyzer.TestSuite.TwoFerTest do defmodule TwoFer do def two_fer(_) end, - defmodule TwoFer do - def two_fer(name \\ "wrong default value") - end, defmodule TwoFer do def two_fer(name) do "One for #{name}, one for me." @@ -114,6 +111,21 @@ defmodule ElixirAnalyzer.TestSuite.TwoFerTest do end end + test_exercise_analysis "accepts any value as the default parameter", + comments_exclude: [Constants.two_fer_use_default_parameter()] do + [ + defmodule TwoFer do + def two_fer(name \\ "you") + end, + defmodule TwoFer do + def two_fer(name \\ "wrong default value") + end, + defmodule TwoFer do + def two_fer(name \\ nil) + end + ] + end + describe "function header" do test_exercise_analysis "refer when using a function header", comments_include: [Constants.two_fer_use_of_function_header()] do