mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
Remove the uninitialized instance variable verbose mode warning
This speeds up all instance variable access, even when not in verbose mode. Uninitialized instance variable warnings were rarely helpful, and resulted in slower code if you wanted to avoid warnings when run in verbose mode. Implements [Feature #17055]
This commit is contained in:
parent
4a559aa225
commit
01b7d5acc7
Notes:
git
2020-12-11 03:16:30 +09:00
7 changed files with 12 additions and 24 deletions
|
@ -955,8 +955,8 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
|||
end
|
||||
|
||||
def test_warning_warn
|
||||
warning = capture_warning_warn {@a}
|
||||
assert_match(/instance variable @a not initialized/, warning[0])
|
||||
warning = capture_warning_warn {$asdfasdsda_test_warning_warn}
|
||||
assert_match(/global variable `\$asdfasdsda_test_warning_warn' not initialized/, warning[0])
|
||||
|
||||
assert_equal(["a\nz\n"], capture_warning_warn {warn "a\n", "z"})
|
||||
assert_equal([], capture_warning_warn {warn})
|
||||
|
@ -1040,7 +1040,7 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
|||
end
|
||||
|
||||
def test_warning_warn_super
|
||||
assert_in_out_err(%[-W0], "#{<<~"{#"}\n#{<<~'};'}", [], /instance variable @a not initialized/)
|
||||
assert_in_out_err(%[-W0], "#{<<~"{#"}\n#{<<~'};'}", [], /global variable `\$asdfiasdofa_test_warning_warn_super' not initialized/)
|
||||
{#
|
||||
module Warning
|
||||
def warn(message)
|
||||
|
@ -1049,7 +1049,7 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
|||
end
|
||||
|
||||
$VERBOSE = true
|
||||
@a
|
||||
$asdfiasdofa_test_warning_warn_super
|
||||
};
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue