diff --git a/test/elixir/eex/tokenizer_test.exs b/test/elixir/eex/tokenizer_test.exs index 99c4ea6c81..3fda367810 100644 --- a/test/elixir/eex/tokenizer_test.exs +++ b/test/elixir/eex/tokenizer_test.exs @@ -71,8 +71,8 @@ baz %> end test "raise syntax error when there is start mark and no end mark" do - T.tokenize('foo <% :bar', 1) - rescue: error in [EEx::SyntaxError] - assert_equal "invalid token: ' :bar'", error.message + assert_raises EEx::SyntaxError, "invalid token: ' :bar'", fn -> + T.tokenize('foo <% :bar', 1) + end end end diff --git a/test/elixir/eex_test.exs b/test/elixir/eex_test.exs index 4e26eaa25b..cc52e1b8bb 100644 --- a/test/elixir/eex_test.exs +++ b/test/elixir/eex_test.exs @@ -57,27 +57,27 @@ defmodule EExTest do end test "raises a syntax error when the token is invalid" do - EEx.compile "foo <%= bar" - rescue: error in [EEx::SyntaxError] - assert_equal "invalid token: ' bar'", error.message + assert_raises EEx::SyntaxError, "invalid token: ' bar'", fn -> + EEx.compile "foo <%= bar" + end end test "raises a syntax error when end expression is found without a start expression" do - EEx.compile "foo <% end %>" - rescue: error in [EEx::SyntaxError] - assert_equal "unexpected token: ' end ' at line 1", error.message + assert_raises EEx::SyntaxError, "unexpected token: ' end ' at line 1", fn -> + EEx.compile "foo <% end %>" + end end test "raises a syntax error when start expression is found without an end expression" do - EEx.compile "foo <% if true do %>" - rescue: error in [EEx::SyntaxError] - assert_equal "unexpected end of string. expecting a closing <% end %>.", error.message + assert_raises EEx::SyntaxError, "unexpected end of string. expecting a closing <% end %>.", fn -> + EEx.compile "foo <% if true do %>" + end end test "raises a syntax error when nested end expression is found without an start expression" do - EEx.compile "foo <%if true do %><% end %><% end %>" - rescue: error in [EEx::SyntaxError] - assert_equal "unexpected token: ' end ' at line 1", error.message + assert_raises EEx::SyntaxError, "unexpected token: ' end ' at line 1", fn -> + EEx.compile "foo <%if true do %><% end %><% end %>" + end end test "respects line numbers" do diff --git a/test/elixir/protocol_test.exs b/test/elixir/protocol_test.exs index 1ba6727d86..a7dc7e7d88 100644 --- a/test/elixir/protocol_test.exs +++ b/test/elixir/protocol_test.exs @@ -54,10 +54,8 @@ defmodule ProtocolTest do test :protocol_with_only_with_undefined do assert_equal nil, ProtocolTest::WithOnly.__protocol_for__(:foo) - assert_equal "protocol ::ProtocolTest::WithOnly not implemented for :foo", try -> + assert_raises Protocol::UndefinedError, "protocol ::ProtocolTest::WithOnly not implemented for :foo", fn -> ProtocolTest::WithOnly.blank(:foo) - rescue: x in [Protocol::UndefinedError] - x.message end end diff --git a/test/elixir/string/chars_test.exs b/test/elixir/string/chars_test.exs index 6fa81804d9..d51292a902 100644 --- a/test/elixir/string/chars_test.exs +++ b/test/elixir/string/chars_test.exs @@ -30,10 +30,10 @@ end defmodule String::Chars::BitStringTest do use ExUnit::Case - # TODO: Use flunk or assert_raises test :bitstring do - assert_equal "<<0,1|4>>", to_binary(<<1|12-integer-signed>>) - rescue: FunctionClauseError + assert_raises FunctionClauseError, fn -> + to_binary(<<1|12-integer-signed>>) + end end test :binary do @@ -71,4 +71,4 @@ defmodule String::Chars::ListTest do test :empty do assert_equal "", to_binary([]) end -end \ No newline at end of file +end