mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/strscan/strscan.c (strscan_set_string): set string should not be
dupped or frozen, because freezing it causes #concat method failure, and unnecessary to dup without freezing. a patch from Aaron Patterson at [ruby-core:25145]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6cd8f907cf
commit
2ef382231f
3 changed files with 28 additions and 2 deletions
|
@ -1,3 +1,10 @@
|
|||
Thu Aug 27 08:16:34 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/strscan/strscan.c (strscan_set_string): set string should not be
|
||||
dupped or frozen, because freezing it causes #concat method failure,
|
||||
and unnecessary to dup without freezing. a patch from Aaron
|
||||
Patterson at [ruby-core:25145].
|
||||
|
||||
Thu Aug 27 02:06:11 2009 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* Makefile.in (enc/unicode/name2ctype.kwd):
|
||||
|
|
|
@ -321,8 +321,7 @@ strscan_set_string(VALUE self, VALUE str)
|
|||
|
||||
Data_Get_Struct(self, struct strscanner, p);
|
||||
StringValue(str);
|
||||
p->str = rb_str_dup(str);
|
||||
rb_obj_freeze(p->str);
|
||||
p->str = str;
|
||||
p->curr = 0;
|
||||
CLEAR_MATCH_STATUS(p);
|
||||
return str;
|
||||
|
|
|
@ -168,6 +168,26 @@ class TestStringScanner < Test::Unit::TestCase
|
|||
assert_equal 0, s.pos
|
||||
end
|
||||
|
||||
def test_string_set_is_equal
|
||||
name = 'tenderlove'
|
||||
|
||||
s = StringScanner.new(name)
|
||||
assert_equal name.object_id, s.string.object_id
|
||||
|
||||
s.string = name
|
||||
assert_equal name.object_id, s.string.object_id
|
||||
end
|
||||
|
||||
def test_string_append
|
||||
s = StringScanner.new('tender')
|
||||
s << 'love'
|
||||
assert_equal 'tenderlove', s.string
|
||||
|
||||
s.string = 'tender'
|
||||
s << 'love'
|
||||
assert_equal 'tenderlove', s.string
|
||||
end
|
||||
|
||||
def test_pos
|
||||
s = StringScanner.new('test string')
|
||||
assert_equal 0, s.pos
|
||||
|
|
Loading…
Reference in a new issue