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: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3306b56971f7
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 19f3bd4530d5
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Mar 21, 2015

  1. Copy the full SHA
    5c62fba View commit details

Commits on Mar 22, 2015

  1. Merge pull request #770 from vais/casecmp

    RFC: String#casecmp fully compliant with rubyspec
    meh committed Mar 22, 2015
    Copy the full SHA
    19f3bd4 View commit details
Showing with 8 additions and 5 deletions.
  1. +8 −2 opal/corelib/string.rb
  2. +0 −3 spec/filters/bugs/string.rb
10 changes: 8 additions & 2 deletions opal/corelib/string.rb
Original file line number Diff line number Diff line change
@@ -227,8 +227,14 @@ def capitalize

def casecmp(other)
other = Opal.coerce_to(other, String, :to_str).to_s

`self.toLowerCase()` <=> `other.toLowerCase()`
%x{
var ascii_only = /^[\x00-\x7F]*$/;
if (ascii_only.test(self) && ascii_only.test(other)) {
self = self.toLowerCase();
other = other.toLowerCase();
}
}
self <=> other
end

def center(width, padstr = ' ')
3 changes: 0 additions & 3 deletions spec/filters/bugs/string.rb
Original file line number Diff line number Diff line change
@@ -93,9 +93,6 @@
fails "String#sub with pattern and Hash taints the result if the original string is tainted"
fails "String#sub with pattern and Hash taints the result if a hash value is tainted"

fails "String#casecmp independent of case for non-ASCII characters returns -1 when numerically less than other"
fails "String#casecmp independent of case for non-ASCII characters returns 1 when numerically greater than other"

fails "String#byteslice returns the character code of the character at the given index"
fails "String#byteslice returns nil if index is outside of self"
fails "String#byteslice calls to_int on the given index"