mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 20:44:00 +02:00
Show the previous definition location,
when reopened class/module redefinition mismatched the previous definition. [Feature #11460]
This commit is contained in:
parent
d3e0bc07e2
commit
761346a960
3 changed files with 36 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue