Skip to content

Commit fa6d00d

Browse files
committed
Enable tests for TypeError and ArgumentError
These tests were unintentionally disabled by `if false`
1 parent 39aa897 commit fa6d00d

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

test/test_error_highlight.rb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ def teardown
2525

2626
if Exception.method_defined?(:detailed_message)
2727
def assert_error_message(klass, expected_msg, &blk)
28+
omit unless klass < ErrorHighlight::CoreExt
2829
err = assert_raise(klass, &blk)
2930
assert_equal(expected_msg.chomp, err.detailed_message(highlight: false).sub(/ \((?:NoMethod|Name)Error\)/, ""))
3031
end
3132
else
3233
def assert_error_message(klass, expected_msg, &blk)
34+
omit unless klass < ErrorHighlight::CoreExt
3335
err = assert_raise(klass, &blk)
3436
assert_equal(expected_msg.chomp, err.message)
3537
end
@@ -987,11 +989,9 @@ def test_multibyte
987989
end
988990
end
989991

990-
if false
991-
992992
def test_args_CALL_1
993993
assert_error_message(TypeError, <<~END) do
994-
nil can't be coerced into Integer
994+
nil can't be coerced into Integer (TypeError)
995995
996996
1.+(nil)
997997
^^^
@@ -1004,7 +1004,7 @@ def test_args_CALL_1
10041004
def test_args_CALL_2
10051005
v = []
10061006
assert_error_message(TypeError, <<~END) do
1007-
no implicit conversion from nil to integer
1007+
no implicit conversion from nil to integer (TypeError)
10081008
10091009
v[nil]
10101010
^^^
@@ -1017,7 +1017,7 @@ def test_args_CALL_2
10171017
def test_args_ATTRASGN_1
10181018
v = []
10191019
assert_error_message(ArgumentError, <<~END) do
1020-
wrong number of arguments (given 1, expected 2..3)
1020+
wrong number of arguments (given 1, expected 2..3) (ArgumentError)
10211021
10221022
v [ ] = 1
10231023
^^^^^^
@@ -1030,7 +1030,7 @@ def test_args_ATTRASGN_1
10301030
def test_args_ATTRASGN_2
10311031
v = []
10321032
assert_error_message(TypeError, <<~END) do
1033-
no implicit conversion from nil to integer
1033+
no implicit conversion from nil to integer (TypeError)
10341034
10351035
v [nil] = 1
10361036
^^^^^^^^
@@ -1042,7 +1042,7 @@ def test_args_ATTRASGN_2
10421042

10431043
def test_args_ATTRASGN_3
10441044
assert_error_message(TypeError, <<~END) do
1045-
no implicit conversion of String into Integer
1045+
no implicit conversion of String into Integer (TypeError)
10461046
10471047
$stdin.lineno = "str"
10481048
^^^^^
@@ -1054,7 +1054,7 @@ def test_args_ATTRASGN_3
10541054

10551055
def test_args_OPCALL
10561056
assert_error_message(TypeError, <<~END) do
1057-
nil can't be coerced into Integer
1057+
nil can't be coerced into Integer (TypeError)
10581058
10591059
1 + nil
10601060
^^^
@@ -1066,7 +1066,7 @@ def test_args_OPCALL
10661066

10671067
def test_args_FCALL_1
10681068
assert_error_message(TypeError, <<~END) do
1069-
no implicit conversion of Symbol into String
1069+
no implicit conversion of Symbol into String (TypeError)
10701070
10711071
"str".instance_eval { gsub("foo", :sym) }
10721072
^^^^^^^^^^^
@@ -1078,7 +1078,7 @@ def test_args_FCALL_1
10781078

10791079
def test_args_FCALL_2
10801080
assert_error_message(TypeError, <<~END) do
1081-
no implicit conversion of Symbol into String
1081+
no implicit conversion of Symbol into String (TypeError)
10821082
10831083
"str".instance_eval { gsub "foo", :sym }
10841084
^^^^^^^^^^^
@@ -1092,7 +1092,7 @@ def test_args_OP_ASGN1_aref_1
10921092
v = []
10931093

10941094
assert_error_message(TypeError, <<~END) do
1095-
no implicit conversion from nil to integer
1095+
no implicit conversion from nil to integer (TypeError)
10961096
10971097
v [nil] += 42
10981098
^^^^^^^^^^
@@ -1106,7 +1106,7 @@ def test_args_OP_ASGN1_aref_2
11061106
v = []
11071107

11081108
assert_error_message(ArgumentError, <<~END) do
1109-
wrong number of arguments (given 0, expected 1..2)
1109+
wrong number of arguments (given 0, expected 1..2) (ArgumentError)
11101110
11111111
v [ ] += 42
11121112
^^^^^^^^
@@ -1120,7 +1120,7 @@ def test_args_OP_ASGN1_op
11201120
v = [1]
11211121

11221122
assert_error_message(TypeError, <<~END) do
1123-
nil can't be coerced into Integer
1123+
nil can't be coerced into Integer (TypeError)
11241124
11251125
v [0] += nil
11261126
^^^^^^^^^
@@ -1135,7 +1135,7 @@ def test_args_OP_ASGN2
11351135
def v.foo; 1; end
11361136

11371137
assert_error_message(TypeError, <<~END) do
1138-
nil can't be coerced into Integer
1138+
nil can't be coerced into Integer (TypeError)
11391139
11401140
v.foo += nil
11411141
^^^
@@ -1145,8 +1145,6 @@ def v.foo; 1; end
11451145
end
11461146
end
11471147

1148-
end
1149-
11501148
def test_custom_formatter
11511149
custom_formatter = Object.new
11521150
def custom_formatter.message_for(spot)

0 commit comments

Comments
 (0)