Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions test/test_error_highlight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ def teardown

if Exception.method_defined?(:detailed_message)
def assert_error_message(klass, expected_msg, &blk)
omit unless klass < ErrorHighlight::CoreExt
err = assert_raise(klass, &blk)
assert_equal(expected_msg.chomp, err.detailed_message(highlight: false).sub(/ \((?:NoMethod|Name)Error\)/, ""))
end
else
def assert_error_message(klass, expected_msg, &blk)
omit unless klass < ErrorHighlight::CoreExt
err = assert_raise(klass, &blk)
assert_equal(expected_msg.chomp, err.message)
end
Expand Down Expand Up @@ -987,11 +989,9 @@ def test_multibyte
end
end

if false

def test_args_CALL_1
assert_error_message(TypeError, <<~END) do
nil can't be coerced into Integer
nil can't be coerced into Integer (TypeError)

1.+(nil)
^^^
Expand All @@ -1004,7 +1004,7 @@ def test_args_CALL_1
def test_args_CALL_2
v = []
assert_error_message(TypeError, <<~END) do
no implicit conversion from nil to integer
no implicit conversion from nil to integer (TypeError)

v[nil]
^^^
Expand All @@ -1017,7 +1017,7 @@ def test_args_CALL_2
def test_args_ATTRASGN_1
v = []
assert_error_message(ArgumentError, <<~END) do
wrong number of arguments (given 1, expected 2..3)
wrong number of arguments (given 1, expected 2..3) (ArgumentError)

v [ ] = 1
^^^^^^
Expand All @@ -1030,7 +1030,7 @@ def test_args_ATTRASGN_1
def test_args_ATTRASGN_2
v = []
assert_error_message(TypeError, <<~END) do
no implicit conversion from nil to integer
no implicit conversion from nil to integer (TypeError)

v [nil] = 1
^^^^^^^^
Expand All @@ -1042,7 +1042,7 @@ def test_args_ATTRASGN_2

def test_args_ATTRASGN_3
assert_error_message(TypeError, <<~END) do
no implicit conversion of String into Integer
no implicit conversion of String into Integer (TypeError)

$stdin.lineno = "str"
^^^^^
Expand All @@ -1054,7 +1054,7 @@ def test_args_ATTRASGN_3

def test_args_OPCALL
assert_error_message(TypeError, <<~END) do
nil can't be coerced into Integer
nil can't be coerced into Integer (TypeError)

1 + nil
^^^
Expand All @@ -1066,7 +1066,7 @@ def test_args_OPCALL

def test_args_FCALL_1
assert_error_message(TypeError, <<~END) do
no implicit conversion of Symbol into String
no implicit conversion of Symbol into String (TypeError)

"str".instance_eval { gsub("foo", :sym) }
^^^^^^^^^^^
Expand All @@ -1078,7 +1078,7 @@ def test_args_FCALL_1

def test_args_FCALL_2
assert_error_message(TypeError, <<~END) do
no implicit conversion of Symbol into String
no implicit conversion of Symbol into String (TypeError)

"str".instance_eval { gsub "foo", :sym }
^^^^^^^^^^^
Expand All @@ -1092,7 +1092,7 @@ def test_args_OP_ASGN1_aref_1
v = []

assert_error_message(TypeError, <<~END) do
no implicit conversion from nil to integer
no implicit conversion from nil to integer (TypeError)

v [nil] += 42
^^^^^^^^^^
Expand All @@ -1106,7 +1106,7 @@ def test_args_OP_ASGN1_aref_2
v = []

assert_error_message(ArgumentError, <<~END) do
wrong number of arguments (given 0, expected 1..2)
wrong number of arguments (given 0, expected 1..2) (ArgumentError)

v [ ] += 42
^^^^^^^^
Expand All @@ -1120,7 +1120,7 @@ def test_args_OP_ASGN1_op
v = [1]

assert_error_message(TypeError, <<~END) do
nil can't be coerced into Integer
nil can't be coerced into Integer (TypeError)

v [0] += nil
^^^^^^^^^
Expand All @@ -1135,7 +1135,7 @@ def test_args_OP_ASGN2
def v.foo; 1; end

assert_error_message(TypeError, <<~END) do
nil can't be coerced into Integer
nil can't be coerced into Integer (TypeError)

v.foo += nil
^^^
Expand All @@ -1145,8 +1145,6 @@ def v.foo; 1; end
end
end

end

def test_custom_formatter
custom_formatter = Object.new
def custom_formatter.message_for(spot)
Expand Down