File tree Expand file tree Collapse file tree 3 files changed +24
-9
lines changed Expand file tree Collapse file tree 3 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -1558,12 +1558,14 @@ defmodule Kernel do
1558
1558
case __CALLER__ . in_guard? do
1559
1559
true ->
1560
1560
quote do
1561
- is_tuple ( unquote ( thing ) ) and :erlang . element ( 1 , unquote ( thing ) ) == unquote ( kind )
1561
+ is_tuple ( unquote ( thing ) ) and tuple_size ( unquote ( thing ) ) > 0
1562
+ and :erlang . element ( 1 , unquote ( thing ) ) == unquote ( kind )
1562
1563
end
1563
1564
false ->
1564
1565
quote do
1565
1566
result = unquote ( thing )
1566
- is_tuple ( result ) and :erlang . element ( 1 , result ) == unquote ( kind )
1567
+ is_tuple ( result ) and tuple_size ( unquote ( thing ) ) > 0
1568
+ and :erlang . element ( 1 , result ) == unquote ( kind )
1567
1569
end
1568
1570
end
1569
1571
end
@@ -1575,12 +1577,14 @@ defmodule Kernel do
1575
1577
case __CALLER__ . in_guard? do
1576
1578
true ->
1577
1579
quote do
1578
- is_tuple ( unquote ( thing ) ) and is_atom ( :erlang . element ( 1 , unquote ( thing ) ) )
1580
+ is_tuple ( unquote ( thing ) ) and tuple_size ( unquote ( thing ) ) > 0
1581
+ and is_atom ( :erlang . element ( 1 , unquote ( thing ) ) )
1579
1582
end
1580
1583
false ->
1581
1584
quote do
1582
1585
result = unquote ( thing )
1583
- is_tuple ( result ) and is_atom ( :erlang . element ( 1 , result ) )
1586
+ is_tuple ( result ) and tuple_size ( unquote ( thing ) ) > 0
1587
+ and is_atom ( :erlang . element ( 1 , result ) )
1584
1588
end
1585
1589
end
1586
1590
end
Original file line number Diff line number Diff line change @@ -5,7 +5,9 @@ defmodule Kernel.ExceptionTest do
5
5
6
6
test :is_exception do
7
7
assert is_exception ( RuntimeError . new )
8
- refute is_exception ( { :foo , :bar } )
8
+ refute is_exception ( empty_tuple )
9
+ refute is_exception ( a_tuple )
10
+ refute is_exception ( a_list )
9
11
end
10
12
11
13
test :format_entry_with_no_file_or_line do
@@ -74,4 +76,8 @@ defmodule Kernel.ExceptionTest do
74
76
test :erlang_error_message do
75
77
assert ErlangError . new ( original: :sample ) . message == "erlang error: :sample"
76
78
end
77
- end
79
+
80
+ defp empty_tuple , do: { }
81
+ defp a_tuple, do: { :foo , :bar , :baz }
82
+ defp a_list, do: [ :foo , :bar , :baz ]
83
+ end
Original file line number Diff line number Diff line change @@ -103,6 +103,11 @@ defmodule RecordTest do
103
103
104
104
test :is_record do
105
105
assert is_record ( RecordTest.FileInfo . new , RecordTest.FileInfo )
106
+ assert is_record ( RecordTest.WithNoField . new )
107
+ refute is_record ( empty_tuple )
108
+ refute is_record ( a_list )
109
+ refute is_record ( empty_tuple , RecordTest.FileInfo )
110
+ refute is_record ( a_tuple , RecordTest.FileInfo )
106
111
refute is_record ( a_list , RecordTest.FileInfo )
107
112
refute is_record ( RecordTest.FileInfo . new , List )
108
113
end
@@ -177,7 +182,7 @@ defmodule RecordTest do
177
182
file_info
178
183
end
179
184
180
- defp a_list do
181
- [ :a , :b , :c ]
182
- end
185
+ defp empty_tuple , do: { }
186
+ defp a_tuple , do: { :foo , :bar , :baz }
187
+ defp a_list , do: [ :foo , :bar , :baz ]
183
188
end
You can’t perform that action at this time.
0 commit comments