Show the previous definition location,

when reopened class/module redefinition mismatched the previous
definition.  [Feature #11460]
This commit is contained in:
Nobuyoshi Nakada 2019-07-04 16:54:34 +09:00
parent d3e0bc07e2
commit 761346a960
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
3 changed files with 36 additions and 12 deletions

View file

@ -2383,15 +2383,17 @@ class TestModule < Test::Unit::TestCase
def test_redefinition_mismatch
m = Module.new
m.module_eval "A = 1"
assert_raise_with_message(TypeError, /is not a module/) {
m.module_eval "A = 1", __FILE__, line = __LINE__
e = assert_raise_with_message(TypeError, /is not a module/) {
m.module_eval "module 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 module") {
m.module_eval "#{n} = 42", __FILE__, line = __LINE__
e = assert_raise_with_message(TypeError, /#{n} is not a module/) {
m.module_eval "module #{n}; end"
}
assert_include(e.message, "#{__FILE__}:#{line}: previous definition")
assert_separately([], <<-"end;")
Etc = (class C\u{1f5ff}; self; end).new