String#slice! and String#[]= with negative ranges behave differently than Ruby
------------------------------------------------------------------------------

                 Key: JRUBY-1730
                 URL: http://jira.codehaus.org/browse/JRUBY-1730
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.x
         Environment: Latest JRuby 1.1b1 from trunk.
            Reporter: Vladimir Sizikov
         Attachments: string-slice-behavior-differs-from-ruby.patch, 
string_slice_range.rb

Conseder the example:

p "hello".slice!(-3..-9)
p "hello"[-3..-9]=""

It fails with JRuby:
string_slice_range.rb:1: -3..-9 out of range. (RangeError)

But works fine with MRI 1.8.6 and 1.9:
#>ruby string_slice_range.rb
""
""

This also leads to one rubinius spec failure:
49)
String#slice! Range deletes and return the substring given by the offsets of 
the range FAILED
-3..-9 out of range.
/opt/work/rubinius/./spec/core/string/slice_spec.rb:146
/opt/work/rubinius/./spec/core/string/slice_spec.rb:146:in `it'
/opt/work/rubinius/spec/mini_rspec.rb:414:in `it'
/opt/work/rubinius/./spec/core/string/slice_spec.rb:146:in `it'
/opt/work/rubinius/./spec/core/string/slice_spec.rb:146:in `describe'
/opt/work/rubinius/spec/mini_rspec.rb:410:in `describe'
/opt/work/rubinius/./spec/core/string/slice_spec.rb:145:in `describe'
/opt/work/rubinius/./spec/core/string/slice_spec.rb:145:in `load'
tmp/last_mspec.rb:13:in `load'
tmp/last_mspec.rb:1:in `each'
tmp/last_mspec.rb:7:in `each'


The proposed patch fixes the problem and the spec failure.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to