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: 1ab7395dbd92
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: def345100ef0
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 6, 2015

  1. Copy the full SHA
    16b8457 View commit details
  2. Copy the full SHA
    def3451 View commit details
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/string/codepoints_tags.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
fails:String#codepoints raises an ArgumentError when self has an invalid encoding and a method is called on the returned Enumerator
fails:String#codepoints yields each codepoint to the block if one is given
fails:String#codepoints raises an ArgumentError if self's encoding is invalid and a block is given
fails:String#codepoints returns codepoints as Fixnums
fails:String#codepoints returns one codepoint for each character
fails:String#codepoints works for multibyte characters
fails:String#codepoints returns the codepoint corresponding to the character's position in the String's encoding
fails:String#codepoints round-trips to the original String using Integer#chr
fails:String#codepoints is synonomous with #bytes for Strings which are single-byte optimisable
fails:String#codepoints returns an Array when no block is given
fails:String#codepoints raises an ArgumentError when no block is given if self has an invalid encoding
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/string/each_codepoint_tags.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
fails:String#each_codepoint raises an ArgumentError when self has an invalid encoding and a method is called on the returned Enumerator
fails:String#each_codepoint yields each codepoint to the block if one is given
fails:String#each_codepoint raises an ArgumentError if self's encoding is invalid and a block is given
fails:String#each_codepoint returns codepoints as Fixnums
fails:String#each_codepoint returns one codepoint for each character
fails:String#each_codepoint works for multibyte characters
fails:String#each_codepoint returns the codepoint corresponding to the character's position in the String's encoding
fails:String#each_codepoint round-trips to the original String using Integer#chr
fails:String#each_codepoint is synonomous with #bytes for Strings which are single-byte optimisable
fails:String#each_codepoint returns an Enumerator when no block is given
fails:String#each_codepoint returns an Enumerator when no block is given even when self has an invalid encoding
16 changes: 16 additions & 0 deletions truffle/src/main/ruby/core/rubinius/common/string.rb
Original file line number Diff line number Diff line change
@@ -381,6 +381,22 @@ def gsub!(pattern, replacement=undefined)
self
end

def each_codepoint
return to_enum :each_codepoint unless block_given?

each_char { |c| yield c.ord }
self
end

def codepoints
if block_given?
each_codepoint do |codepoint|
yield codepoint
end
else
each_codepoint.to_a
end
end

def to_sub_replacement(result, match)
index = 0