Bug #15926 » str-uminus-freeze-fix-v2.patch
string.c | ||
---|---|---|
static VALUE
|
||
str_uminus(VALUE str)
|
||
{
|
||
if (!BARE_STRING_P(str) && !rb_obj_frozen_p(str)) {
|
||
str = rb_str_dup(str);
|
||
}
|
||
return rb_fstring(str);
|
||
}
|
||
test/ruby/test_string.rb | ||
---|---|---|
assert_same(str, -bar, "uminus deduplicates [Feature #13077]")
|
||
end
|
||
def test_uminus_no_freeze_not_bare
|
||
str = @cls.new("foo")
|
||
-str
|
||
assert_equal(false, str.frozen?)
|
||
str = @cls.new("foo")
|
||
str.instance_variable_set(:@iv, 1)
|
||
-str
|
||
assert_equal(false, str.frozen?)
|
||
str = @cls.new("foo")
|
||
str.taint
|
||
-str
|
||
assert_equal(false, str.frozen?)
|
||
end
|
||
def test_ord
|
||
assert_equal(97, "a".ord)
|
||
assert_equal(97, "abc".ord)
|
- « Previous
- 1
- 2
- Next »