diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2021-06-18 17:11:39 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2021-06-29 23:45:49 +0900 |
commit | e94604966572bb43fc887856d54aa54b8e9f7719 (patch) | |
tree | 789d92c232f671c6620af5c4bfd1a3fc0d9d26b3 /test/ruby | |
parent | 03dc66449326ce0945c1ccad7f51e57125b2b854 (diff) | |
download | ruby-e94604966572bb43fc887856d54aa54b8e9f7719.tar.gz |
[WIP] add error_squiggle gem
```
$ ./local/bin/ruby -e '1.time {}'
-e:1:in `<main>': undefined method `time' for 1:Integer (NoMethodError)
1.time {}
^^^^^
Did you mean? times
```
https://bugs.ruby-lang.org/issues/17930
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/marshaltestlib.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_marshal.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_name_error.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_nomethod_error.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_object.rb | 2 |
6 files changed, 6 insertions, 6 deletions
diff --git a/test/ruby/marshaltestlib.rb b/test/ruby/marshaltestlib.rb index 5c48a8d853..7f100b7873 100644 --- a/test/ruby/marshaltestlib.rb +++ b/test/ruby/marshaltestlib.rb @@ -112,7 +112,7 @@ module MarshalTestLib marshal_equal(Exception.new('foo')) {|o| o.message} obj = Object.new e = assert_raise(NoMethodError) {obj.no_such_method()} - marshal_equal(e) {|o| o.message} + marshal_equal(e) {|o| o.message.lines.first.chomp} end def test_exception_subclass diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index d2b4ec169f..5e6891a6a0 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -817,7 +817,7 @@ class TestMarshal < Test::Unit::TestCase nameerror_test rescue NameError => e e2 = Marshal.load(Marshal.dump(e)) - assert_equal(e.message, e2.message) + assert_equal(e.message.lines.first.chomp, e2.message.lines.first) assert_equal(e.name, e2.name) assert_equal(e.backtrace, e2.backtrace) assert_nil(e2.backtrace_locations) # temporal diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 84e74693aa..3411c3d701 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -267,7 +267,7 @@ class TestModule < Test::Unit::TestCase ].each do |name, msg| expected = "wrong constant name %s" % name msg = "#{msg}#{': ' if msg}wrong constant name #{name.dump}" - assert_raise_with_message(NameError, expected, "#{msg} to #{m}") do + assert_raise_with_message(NameError, Regexp.compile(Regexp.quote(expected)), "#{msg} to #{m}") do yield name end end diff --git a/test/ruby/test_name_error.rb b/test/ruby/test_name_error.rb index 813a976e96..8fcc2dcb26 100644 --- a/test/ruby/test_name_error.rb +++ b/test/ruby/test_name_error.rb @@ -151,6 +151,6 @@ class TestNameError < Test::Unit::TestCase error = assert_raise(NameError) do receiver::FOO end - assert_equal "uninitialized constant #{'A' * 120}::FOO", error.message + assert_match /\Auninitialized constant #{'A' * 120}::FOO$/, error.message end end diff --git a/test/ruby/test_nomethod_error.rb b/test/ruby/test_nomethod_error.rb index 8b81052905..321b7ccab2 100644 --- a/test/ruby/test_nomethod_error.rb +++ b/test/ruby/test_nomethod_error.rb @@ -86,7 +86,7 @@ class TestNoMethodError < Test::Unit::TestCase str = "\u2600" id = :"\u2604" msg = "undefined method `#{id}' for \"#{str}\":String" - assert_raise_with_message(NoMethodError, msg, bug3237) do + assert_raise_with_message(NoMethodError, Regexp.compile(Regexp.quote(msg)), bug3237) do str.__send__(id) end end diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 774b707742..83208bbcdb 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -777,7 +777,7 @@ class TestObject < Test::Unit::TestCase e = assert_raise(NoMethodError) { o.never_defined_test_no_superclass_method } - assert_equal(m1, e.message, bug2312) + assert_equal(m1.lines.first, e.message.lines.first, bug2312) end def test_superclass_method |