Skip to content

Commit

Permalink
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/slice_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
fails:String#slice with index, length returns subclass instances
fails:String#slice with Range returns an empty string if range.begin is inside self and > real end
fails:String#slice with Range always taints resulting strings when self is tainted
fails:String#slice with Range returns subclass instances
fails:String#slice with Range calls to_int on range arguments
fails:String#slice with Range works with Range subclasses
@@ -21,7 +19,6 @@ fails:String#slice! with index, length always taints resulting strings when self
fails:String#slice! with index, length calls to_int on idx and length
fails:String#slice! with index, length returns subclass instances
fails:String#slice! with index, length returns the substring given by the character offsets
fails:String#slice! Range deletes and return the substring given by the offsets of the range
fails:String#slice! Range returns subclass instances
fails:String#slice! Range calls to_int on range arguments
fails:String#slice! Range works with Range subclasses
Original file line number Diff line number Diff line change
@@ -336,6 +336,10 @@ public Object slice(RubyString string, RubyRange.IntegerFixnumRange range, @Supp
final int end = string.normalizeIndex(range.getEnd());
final int excludingEnd = string.clampExclusiveIndex(range.doesExcludeEnd() ? end : end+1);

if (begin > excludingEnd) {
return getContext().makeString("");
}

return getContext().makeString(javaString.substring(begin, excludingEnd), string.getByteList().getEncoding());
}
}

0 comments on commit 17ae6b4

Please sign in to comment.