Bug #15926 » str-uminus-freeze-fix.patch
| string.c | ||
|---|---|---|
|
static VALUE
|
||
|
str_uminus(VALUE str)
|
||
|
{
|
||
|
if (CLASS_OF(str) != rb_cString && !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_subclass_instance
|
||
|
str = @cls.new("foo")
|
||
|
-str
|
||
|
assert_equal(false, str.frozen?)
|
||
|
end
|
||
|
def test_ord
|
||
|
assert_equal(97, "a".ord)
|
||
|
assert_equal(97, "abc".ord)
|
||