Skip to content

Commit

Permalink
failing tests should pass now
Browse files Browse the repository at this point in the history
  • Loading branch information
milmazz committed May 30, 2024
1 parent f33dead commit 698c913
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion test/norm/contract_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -105,4 +108,6 @@ defmodule Norm.ContractTest do
assert inspect(contract) ==
"%Norm.Contract{args: [a: #Norm.Spec<is_integer()>, arg2: #Norm.Spec<is_integer()>], result: #Norm.Spec<is_integer()>}"
end

defp version, do: Version.parse!(System.version())
end
6 changes: 5 additions & 1 deletion test/norm/core/spec_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -144,4 +146,6 @@ defmodule Norm.Core.SpecTest do
"#Norm.Spec<is_integer() or is_float()>"
end
end

defp version, do: Version.parse!(System.version())
end

0 comments on commit 698c913

Please sign in to comment.