diff options
author | Masataka Pocke Kuwabara <kuwabara@pocke.me> | 2021-07-08 20:13:42 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-07-31 22:15:16 +0900 |
commit | 242f024bcbff6c46edd84a03365fa99ebd8eb524 (patch) | |
tree | 8f736ddd8f381c7ed347a14c83412e7ad3751ac7 /test/error_highlight | |
parent | 4ab5281601c7c652db749d79b4833d755d563b09 (diff) |
[ruby/error_highlight] Keep it work if paren exists after receiver
https://github.com/ruby/error_highlight/commit/b79d679bbd
Diffstat (limited to 'test/error_highlight')
-rw-r--r-- | test/error_highlight/test_error_highlight.rb | 162 |
1 files changed, 161 insertions, 1 deletions
diff --git a/test/error_highlight/test_error_highlight.rb b/test/error_highlight/test_error_highlight.rb index 49bfee8f6c..5d90f75bbb 100644 --- a/test/error_highlight/test_error_highlight.rb +++ b/test/error_highlight/test_error_highlight.rb @@ -66,6 +66,18 @@ undefined method `foo' for nil:NilClass end end + def test_CALL_noarg_4 + assert_error_message(NoMethodError, <<~END) do +undefined method `foo' for nil:NilClass + + (nil).foo + 1 + ^^^^ + END + + (nil).foo + 1 + end + end + def test_CALL_arg_1 assert_error_message(NoMethodError, <<~END) do undefined method `foo' for nil:NilClass @@ -222,6 +234,18 @@ undefined method `[]' for #{ v.inspect } end end + def test_CALL_aref_5 + assert_error_message(NoMethodError, <<~END) do +undefined method `[]' for nil:NilClass + + (nil)[ ] + ^^^ + END + + (nil)[ ] + end + end + def test_CALL_aset assert_error_message(NoMethodError, <<~END) do undefined method `[]=' for nil:NilClass @@ -313,6 +337,30 @@ undefined method `foo=' for nil:NilClass end end + def test_ATTRASGN_4 + assert_error_message(NoMethodError, <<~END) do +undefined method `[]=' for nil:NilClass + + (nil)[0] = 42 + ^^^^^ + END + + (nil)[0] = 42 + end + end + + def test_ATTRASGN_5 + assert_error_message(NoMethodError, <<~END) do +undefined method `foo=' for nil:NilClass + + (nil).foo = 42 + ^^^^^^ + END + + (nil).foo = 42 + end + end + def test_OPCALL_binary_1 assert_error_message(NoMethodError, <<~END) do undefined method `+' for nil:NilClass @@ -338,7 +386,19 @@ undefined method `+' for nil:NilClass end end - def test_OPCALL_unary + def test_OPCALL_binary_3 + assert_error_message(NoMethodError, <<~END) do +undefined method `+' for nil:NilClass + + (nil) + 42 + ^ + END + + (nil) + 42 + end + end + + def test_OPCALL_unary_1 assert_error_message(NoMethodError, <<~END) do undefined method `+@' for nil:NilClass @@ -350,6 +410,18 @@ undefined method `+@' for nil:NilClass end end + def test_OPCALL_unary_2 + assert_error_message(NoMethodError, <<~END) do +undefined method `+@' for nil:NilClass + + +(nil) + ^ + END + + +(nil) + end + end + def test_FCALL_1 assert_error_message(NoMethodError, <<~END) do undefined method `foo' for nil:NilClass @@ -429,6 +501,20 @@ undefined method `[]' for nil:NilClass end end + def test_OP_ASGN1_aref_4 + v = nil + + assert_error_message(NoMethodError, <<~END) do +undefined method `[]' for nil:NilClass + + (v)[0] += 42 + ^^^ + END + + (v)[0] += 42 + end + end + def test_OP_ASGN1_op_1 v = Object.new def v.[](x); nil; end @@ -475,6 +561,21 @@ undefined method `+' for nil:NilClass end end + def test_OP_ASGN1_op_4 + v = Object.new + def v.[](x); nil; end + + assert_error_message(NoMethodError, <<~END) do +undefined method `+' for nil:NilClass + + (v)[0] += 42 + ^ + END + + (v)[0] += 42 + end + end + def test_OP_ASGN1_aset_1 v = Object.new def v.[](x); 1; end @@ -521,6 +622,21 @@ undefined method `[]=' for #{ v.inspect } end end + def test_OP_ASGN1_aset_4 + v = Object.new + def v.[](x); 1; end + + assert_error_message(NoMethodError, <<~END) do +undefined method `[]=' for #{ v.inspect } + + (v)[0] += 42 + ^^^^^^ + END + + (v)[0] += 42 + end + end + def test_OP_ASGN2_read_1 v = nil @@ -550,6 +666,20 @@ undefined method `foo' for nil:NilClass end end + def test_OP_ASGN2_read_3 + v = nil + + assert_error_message(NoMethodError, <<~END) do +undefined method `foo' for nil:NilClass + + (v).foo += 42 + ^^^^ + END + + (v).foo += 42 + end + end + def test_OP_ASGN2_op_1 v = Object.new def v.foo; nil; end @@ -581,6 +711,21 @@ undefined method `+' for nil:NilClass end end + def test_OP_ASGN2_op_3 + v = Object.new + def v.foo; nil; end + + assert_error_message(NoMethodError, <<~END) do +undefined method `+' for nil:NilClass + + (v).foo += 42 + ^ + END + + (v).foo += 42 + end + end + def test_OP_ASGN2_write_1 v = Object.new def v.foo; 1; end @@ -612,6 +757,21 @@ undefined method `foo=' for #{ v.inspect } end end + def test_OP_ASGN2_write_3 + v = Object.new + def v.foo; 1; end + + assert_error_message(NoMethodError, <<~END) do +undefined method `foo=' for #{ v.inspect } + + (v).foo += 42 + ^^^^^^^ + END + + (v).foo += 42 + end + end + def test_CONST assert_error_message(NameError, <<~END) do uninitialized constant ErrorHighlightTest::NotDefined |