diff options
author | Andrea Leopardi <an.leopardi@gmail.com> | 2018-05-04 03:01:05 -0300 |
---|---|---|
committer | Andrea Leopardi <an.leopardi@gmail.com> | 2018-05-04 03:01:05 -0300 |
commit | 5facf07200ad1e190e9f59fe5e2682483aa67c78 (patch) | |
tree | bc99ea3e8a14dba889caa49f8124d867b9e1f026 | |
parent | 608d7f814fd87b359d92b3bb7b55bd1261ecce24 (diff) | |
download | elixir-5facf07200ad1e190e9f59fe5e2682483aa67c78.tar.gz |
Add a test for rescuing one of multiple exceptions
We were not testing "var in [Alias1, Alias2]" but only "var in
[Alias1]". I noticed because changing the compiler to compile that to
var.__struct__ == Alias1 and var.__struct__ == Alias2
would still pass tests for Kernel.RaiseTest.
-rw-r--r-- | lib/elixir/test/elixir/kernel/raise_test.exs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/elixir/test/elixir/kernel/raise_test.exs b/lib/elixir/test/elixir/kernel/raise_test.exs index 29caaf248..f4986df2e 100644 --- a/lib/elixir/test/elixir/kernel/raise_test.exs +++ b/lib/elixir/test/elixir/kernel/raise_test.exs @@ -171,6 +171,19 @@ defmodule Kernel.RaiseTest do assert result == "an exception" end + test "named runtime or argument error" do + result = + try do + raise "an exception" + rescue + x in [ArgumentError, RuntimeError] -> Exception.message(x) + catch + :error, _ -> false + end + + assert result == "an exception" + end + test "with higher precedence than catch" do result = try do |