aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_class.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-04 16:54:34 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-29 13:24:00 +0900
commit761346a9604ca2c79777d1d67fb5dcc3c30dbf69 (patch)
treea06734056a992fdbb3ffa8c8d0ae5ce4e0a639aa /test/ruby/test_class.rb
parentd3e0bc07e2909f1105dcde4febb0e120eaea30b6 (diff)
downloadruby-761346a9604ca2c79777d1d67fb5dcc3c30dbf69.tar.gz
Show the previous definition location,
when reopened class/module redefinition mismatched the previous definition. [Feature #11460]
Diffstat (limited to 'test/ruby/test_class.rb')
-rw-r--r--test/ruby/test_class.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb
index f07a1cdc40..6960ab5971 100644
--- a/test/ruby/test_class.rb
+++ b/test/ruby/test_class.rb
@@ -591,15 +591,17 @@ class TestClass < Test::Unit::TestCase
def test_redefinition_mismatch
m = Module.new
- m.module_eval "A = 1"
- assert_raise_with_message(TypeError, /is not a class/) {
+ m.module_eval "A = 1", __FILE__, line = __LINE__
+ e = assert_raise_with_message(TypeError, /is not a class/) {
m.module_eval "class A; end"
}
+ assert_include(e.message, "#{__FILE__}:#{line}: previous definition")
n = "M\u{1f5ff}"
- m.module_eval "#{n} = 42"
- assert_raise_with_message(TypeError, "#{n} is not a class") {
+ m.module_eval "#{n} = 42", __FILE__, line = __LINE__
+ e = assert_raise_with_message(TypeError, /#{n} is not a class/) {
m.module_eval "class #{n}; end"
}
+ assert_include(e.message, "#{__FILE__}:#{line}: previous definition")
assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}")
begin;