mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (str_gsub): internal buffer should not be listed by
ObjectSpace.each_object(). [ruby-dev:24919] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5e2fdf0163
commit
5e2c8a40c3
3 changed files with 58 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Nov 19 00:59:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (str_gsub): internal buffer should not be listed by
|
||||
ObjectSpace.each_object(). [ruby-dev:24919]
|
||||
|
||||
Thu Nov 18 23:42:36 2004 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* ext/ripper/depend: Never regenerate lib/ripper/core.rb
|
||||
|
|
3
string.c
3
string.c
|
@ -2076,6 +2076,9 @@ str_gsub(argc, argv, str, bang)
|
|||
|
||||
blen = RSTRING(str)->len + 30; /* len + margin */
|
||||
dest = rb_str_new5(str, 0, blen);
|
||||
if (bang) {
|
||||
RBASIC(dest)->klass = 0;
|
||||
}
|
||||
buf = RSTRING(dest)->ptr;
|
||||
bp = buf;
|
||||
sp = cp = RSTRING(str)->ptr;
|
||||
|
|
|
@ -113,4 +113,54 @@ EOS
|
|||
}
|
||||
assert_equal(0, a.size)
|
||||
end
|
||||
|
||||
def test_bang
|
||||
s = "aBc"
|
||||
s.upcase
|
||||
assert_equal("aBc", s)
|
||||
s.upcase!
|
||||
assert_equal("ABC", s)
|
||||
|
||||
s = "aBc"
|
||||
s.downcase
|
||||
assert_equal("aBc", s)
|
||||
s.downcase!
|
||||
assert_equal("abc", s)
|
||||
|
||||
s = "aBc"
|
||||
s.swapcase
|
||||
assert_equal("aBc", s)
|
||||
s.swapcase!
|
||||
assert_equal("AbC", s)
|
||||
|
||||
s = "aBc"
|
||||
s.capitalize
|
||||
assert_equal("aBc", s)
|
||||
s.capitalize!
|
||||
assert_equal("Abc", s)
|
||||
|
||||
s = "aBc"
|
||||
s.tr("a-z", "A-Z")
|
||||
assert_equal("aBc", s)
|
||||
s.tr!("a-z", "A-Z")
|
||||
assert_equal("ABC", s)
|
||||
|
||||
s = "aaBBcc"
|
||||
s.tr_s("a-z", "A-Z")
|
||||
assert_equal("aaBBcc", s)
|
||||
s.tr_s!("a-z", "A-Z")
|
||||
assert_equal("ABBC", s)
|
||||
|
||||
s = "aaBBcc"
|
||||
s.squeeze("a-z")
|
||||
assert_equal("aaBBcc", s)
|
||||
s.squeeze!("a-z")
|
||||
assert_equal("aBBc", s)
|
||||
|
||||
s = "aaBBcc"
|
||||
s.delete("a-z")
|
||||
assert_equal("aaBBcc", s)
|
||||
s.delete!("a-z")
|
||||
assert_equal("BB", s)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue