Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d1bbea8bf030
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e7147f0285f3
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 2, 2015

  1. Copy the full SHA
    8caa62c View commit details
  2. Copy the full SHA
    e7147f0 View commit details
11 changes: 8 additions & 3 deletions spec/ruby/core/matchdata/element_reference_spec.rb
Original file line number Diff line number Diff line change
@@ -2,9 +2,14 @@

describe "MatchData#[]" do
it "acts as normal array indexing [index]" do
/(.)(.)(\d+)(\d)/.match("THX1138.")[0].should == 'HX1138'
/(.)(.)(\d+)(\d)/.match("THX1138.")[1].should == 'H'
/(.)(.)(\d+)(\d)/.match("THX1138.")[2].should == 'X'
md = /(.)(.)(\d+)(\d)/.match("THX1138.")

md[0].should == 'HX1138'
md[1].should == 'H'
md[2].should == 'X'
md[-3].should == 'X'
md[10000].should == nil
md[-10000].should == nil
end

it "supports accessors [start, length]" do
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/slice_tags.txt
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ fails:String#slice with Range works with Range subclasses
fails:String#slice with Regexp always taints resulting strings when self or regexp is tainted
fails:String#slice with Regexp returns an untrusted string if the regexp is untrusted
fails:String#slice with Regexp returns subclass instances
fails:String#slice with Regexp, index returns the capture for the given index
fails:String#slice with Regexp, index always taints resulting strings when self or regexp is tainted
fails:String#slice with Regexp, index returns an untrusted string if the regexp is untrusted
fails:String#slice with Regexp, index returns nil if there is no capture for the given index
@@ -44,12 +43,10 @@ fails:String#slice! with Regexp, index doesn't taint self when regexp is tainted
fails:String#slice! with Regexp, index returns nil if there is no capture for idx
fails:String#slice! with Regexp, index calls to_int on idx
fails:String#slice! with Regexp, index returns subclass instances
fails:String#slice! with Regexp, index returns the encoding aware capture for the given index
fails:String#slice! with String removes and returns the first occurrence of other_str from self
fails:String#slice! with String taints resulting strings when other is tainted
fails:String#slice! with String doesn't set $~
fails:String#slice! with String returns nil if self does not contain other
fails:String#slice! with String returns a subclass instance when given a subclass instance
fails:String#slice! with Regexp, index accepts a Float for capture index
fails:String#slice! with Regexp, index calls #to_int to convert an Object to capture index

Original file line number Diff line number Diff line change
@@ -44,10 +44,13 @@ public GetIndexNode(GetIndexNode prev) {
public Object getIndex(RubyMatchData matchData, int index) {
notDesignedForCompilation();

if (index >= matchData.getValues().length || index < 0) {
final Object[] values = matchData.getValues();
final int normalizedIndex = RubyArray.normalizeIndex(values.length, index);

if ((normalizedIndex < 0) || (normalizedIndex >= values.length)) {
return getContext().getCoreLibrary().getNilObject();
} else {
return matchData.getValues()[index];
return values[normalizedIndex];
}
}