зеркало из https://github.com/github/ruby.git
[Bug #20389] Chilled string cannot be a shared root
This commit is contained in:
Родитель
95864a6e35
Коммит
fdd7ffb70c
2
string.c
2
string.c
|
@ -1340,7 +1340,7 @@ rb_str_new_shared(VALUE str)
|
|||
VALUE
|
||||
rb_str_new_frozen(VALUE orig)
|
||||
{
|
||||
if (OBJ_FROZEN(orig)) return orig;
|
||||
if (RB_FL_TEST_RAW(orig, FL_FREEZE | STR_CHILLED) == FL_FREEZE) return orig;
|
||||
return str_new_frozen(rb_obj_class(orig), orig);
|
||||
}
|
||||
|
||||
|
|
|
@ -3648,6 +3648,18 @@ CODE
|
|||
Warning[:deprecated] = deprecated
|
||||
end
|
||||
|
||||
def test_chilled_string_substring
|
||||
deprecated = Warning[:deprecated]
|
||||
Warning[:deprecated] = false
|
||||
chilled_string = eval('"a chilled string."')
|
||||
substring = chilled_string[0..-1]
|
||||
assert_equal("a chilled string.", substring)
|
||||
chilled_string[0..-1] = "This string is defrosted."
|
||||
assert_equal("a chilled string.", substring)
|
||||
ensure
|
||||
Warning[:deprecated] = deprecated
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_bytesplice_result(expected, s, *args)
|
||||
|
|
Загрузка…
Ссылка в новой задаче