From: Anders Bengtsson Date: 2001-01-10T05:14:18+09:00 Subject: [ruby-talk:8956] Re: String confusion Aleksi Niemel� wrote: > > Robert asks: > > On Wed, 10 Jan 2001, Yukihiro Matsumoto wrote: > > > It's a bug. Here's the patch. Thank you. > > > > > Dave&Andy: Would Rubicon have caught this? How complete is it? > > I just tested with latest 1.7.0 and Rubicon 0.1.4. I'm pretty sure this one > would have been missed. Here's the tests for String#reverse!: > > def test_reverse! > a="beta" > assert_equal("ateb",a.reverse!) > assert_equal("ateb",a) > end > > As you see, the problem was the side-effect, that reverse! didn't only > change string pointed by self, but the other (dupped) string too. I now found a way to reproduce this particular bug without really looking for side effects: s = "foo" s.freeze s.reverse! This code happily reverses the string in Ruby 1.6.2, while the CVS version gives the expected "TypeError: can't modify frozen string". But I guess that testing every method for how they work with frozen objects isn't really easier. /Anders _____________________________________________________________________ A n d e r s B e n g t s s o n ndrsbngtssn@yahoo.se Stockholm, Sweden _____________________________________________________ Do You Yahoo!? S�lj eller l�gg ett bud p� Yahoo! Auktioner http://se.auctions.yahoo.com