mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 20:19:19 +00:00
Refine non-nil warnings for the deprecated variables
This commit is contained in:
parent
cf12aff059
commit
29a12297c3
2
string.c
2
string.c
@ -11378,7 +11378,7 @@ rb_str_setter(VALUE val, ID id, VALUE *var)
|
||||
static void
|
||||
nil_setter_warning(ID id)
|
||||
{
|
||||
rb_warn_deprecated("'%"PRIsVALUE"'", NULL, rb_id2str(id));
|
||||
rb_warn_deprecated("non-nil '%"PRIsVALUE"'", NULL, rb_id2str(id));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@ -2907,10 +2907,10 @@ class TestIO < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_print_separators
|
||||
EnvUtil.suppress_warning {
|
||||
$, = ':'
|
||||
$\ = "\n"
|
||||
}
|
||||
assert_deprecated_warning(/non-nil '\$,'/) {$, = ":"}
|
||||
assert_raise(TypeError) {$, = 1}
|
||||
assert_deprecated_warning(/non-nil '\$\\'/) {$\ = "\n"}
|
||||
assert_raise(TypeError) {$/ = 1}
|
||||
pipe(proc do |w|
|
||||
w.print('a')
|
||||
EnvUtil.suppress_warning {w.print('a','b','c')}
|
||||
|
||||
@ -1883,9 +1883,13 @@ CODE
|
||||
def test_fs
|
||||
return unless @cls == String
|
||||
|
||||
assert_raise_with_message(TypeError, /\$;/) {
|
||||
$; = []
|
||||
}
|
||||
begin
|
||||
fs = $;
|
||||
assert_deprecated_warning(/non-nil '\$;'/) {$; = "x"}
|
||||
assert_raise_with_message(TypeError, /\$;/) {$; = []}
|
||||
ensure
|
||||
EnvUtil.suppress_warning {$; = fs}
|
||||
end
|
||||
name = "\u{5206 5217}"
|
||||
assert_separately([], "#{<<~"do;"}\n#{<<~"end;"}")
|
||||
do;
|
||||
@ -2775,7 +2779,13 @@ CODE
|
||||
def test_rs
|
||||
return unless @cls == String
|
||||
|
||||
assert_raise(TypeError) { $/ = 1 }
|
||||
begin
|
||||
rs = $/
|
||||
assert_deprecated_warning(/non-nil '\$\/'/) { $/ = "" }
|
||||
assert_raise(TypeError) { $/ = 1 }
|
||||
ensure
|
||||
EnvUtil.suppress_warning { $/ = rs }
|
||||
end
|
||||
name = "\u{5206 884c}"
|
||||
assert_separately([], "#{<<~"do;"}\n#{<<~"end;"}")
|
||||
do;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user