diff --git a/test/norm/contract_test.exs b/test/norm/contract_test.exs index 4004a07..e5cc721 100644 --- a/test/norm/contract_test.exs +++ b/test/norm/contract_test.exs @@ -39,7 +39,10 @@ defmodule Norm.ContractTest do end test "bad contract" do - assert_raise ArgumentError, ~r/got: `@contract\(foo\(n\)\)`/, fn -> + expected = if version().minor >= 13, + do: ~r/got: `@contract foo\(n\)`/, else: ~r/got: `@contract\(foo\(n\)\)`/ + + assert_raise ArgumentError, expected, fn -> defmodule BadContract do use Norm @@ -105,4 +108,6 @@ defmodule Norm.ContractTest do assert inspect(contract) == "%Norm.Contract{args: [a: #Norm.Spec, arg2: #Norm.Spec], result: #Norm.Spec}" end + + defp version, do: Version.parse!(System.version()) end diff --git a/test/norm/core/spec_test.exs b/test/norm/core/spec_test.exs index c70b553..4d19e5a 100644 --- a/test/norm/core/spec_test.exs +++ b/test/norm/core/spec_test.exs @@ -15,7 +15,9 @@ defmodule Norm.Core.SpecTest do assert {:error, errors} = conform(nil, hex) assert errors == [%{spec: "is_binary()", input: nil, path: []}] assert {:error, errors} = conform("bad", hex) - assert errors == [%{spec: "&(String.starts_with?(&1, \"#\"))", input: "bad", path: []}] + + spec = if version().minor >= 13, do: "&String.starts_with?(&1, \"#\")", else: "&(String.starts_with?(&1, \"#\"))" + assert errors == [%{spec: spec, input: "bad", path: []}] end test "'and' and 'or' can be chained" do @@ -144,4 +146,6 @@ defmodule Norm.Core.SpecTest do "#Norm.Spec" end end + + defp version, do: Version.parse!(System.version()) end