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 @@ -1581,12 +1581,14 @@ defmodule Kernel do
1581
1581
case __CALLER__ . in_guard? do
1582
1582
true ->
1583
1583
quote do
1584
- is_tuple ( unquote ( thing ) ) and :erlang . element ( 1 , unquote ( thing ) ) == unquote ( kind )
1584
+ is_tuple ( unquote ( thing ) ) and tuple_size ( unquote ( thing ) ) > 0
1585
+ and :erlang . element ( 1 , unquote ( thing ) ) == unquote ( kind )
1585
1586
end
1586
1587
false ->
1587
1588
quote do
1588
1589
result = unquote ( thing )
1589
- is_tuple ( result ) and :erlang . element ( 1 , result ) == unquote ( kind )
1590
+ is_tuple ( result ) and tuple_size ( unquote ( thing ) ) > 0
1591
+ and :erlang . element ( 1 , result ) == unquote ( kind )
1590
1592
end
1591
1593
end
1592
1594
end
@@ -1598,12 +1600,14 @@ defmodule Kernel do
1598
1600
case __CALLER__ . in_guard? do
1599
1601
true ->
1600
1602
quote do
1601
- is_tuple ( unquote ( thing ) ) and is_atom ( :erlang . element ( 1 , unquote ( thing ) ) )
1603
+ is_tuple ( unquote ( thing ) ) and tuple_size ( unquote ( thing ) ) > 0
1604
+ and is_atom ( :erlang . element ( 1 , unquote ( thing ) ) )
1602
1605
end
1603
1606
false ->
1604
1607
quote do
1605
1608
result = unquote ( thing )
1606
- is_tuple ( result ) and is_atom ( :erlang . element ( 1 , result ) )
1609
+ is_tuple ( result ) and tuple_size ( unquote ( thing ) ) > 0
1610
+ and is_atom ( :erlang . element ( 1 , result ) )
1607
1611
end
1608
1612
end
1609
1613
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