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: 4f5cfb12cf89
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 153b32427a56
Choose a head ref
  • 5 commits
  • 3 files changed
  • 2 contributors

Commits on Mar 2, 2015

  1. Copy the full SHA
    9519fd4 View commit details
  2. Pass "String#=== returns obj == self if obj responds to to_str"

    Also passes "String#=== returns false if obj does not respond to
    to_str" now EXCEPT for one line that tests symbol argument:
    “'hello'.send(@method, :hello).should be_false”. There is no way to
    pass this assertion since strings and symbols are identical in Opal.
    vais committed Mar 2, 2015
    Copy the full SHA
    e0383eb View commit details
  3. Pass "String#== returns obj == self if obj responds to to_str"

    Also passes "String#== returns false if obj does not respond to to_str"
    now EXCEPT for one line that tests symbol argument:
    “'hello'.send(@method, :hello).should be_false”.
    
    Also passes "String#eql? when given a non-String returns false"  now
    EXCEPT for one line that tests symbol argument: "'hello'.should_not
    eql(:hello)"
    
    There is no way to pass these assertions since strings and symbols are
    identical in Opal.
    vais committed Mar 2, 2015
    Copy the full SHA
    e55671e View commit details
  4. Copy the full SHA
    605ca3c View commit details

Commits on Mar 3, 2015

  1. Merge pull request #717 from vais/string

    String#===, String#==, and String#eql? implementation fully compliant with rubyspec
    meh committed Mar 3, 2015
    Copy the full SHA
    153b324 View commit details
Showing with 14 additions and 10 deletions.
  1. +2 −0 CHANGELOG.md
  2. +9 −3 opal/corelib/string.rb
  3. +3 −7 spec/filters/bugs/string.rb
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@

* `String#succ` and `String#next` implementation fully compliant with rubyspec

* `String#===`, `String#==`, and `String#eql?` implementation fully compliant with rubyspec

## 0.7.1 2015-02-14

* CLI options `-d` and `-v` now set respectively `$DEBUG` and `$VERBOSE`
12 changes: 9 additions & 3 deletions opal/corelib/string.rb
Original file line number Diff line number Diff line change
@@ -75,9 +75,15 @@ def <<(other)
end

def ==(other)
return false unless String === other

`#{to_s} == #{other.to_s}`
%x{
if (other.$$is_string) {
return self.toString() === other.toString();
}
if (#{Opal.respond_to? `other`, :to_str}) {
return #{other == self};
}
return false;
}
end

alias eql? ==
10 changes: 3 additions & 7 deletions spec/filters/bugs/string.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
opal_filter "String" do
fails "String#=== ignores subclass differences"
fails "String#=== returns false if obj does not respond to to_str"
fails "String#=== returns obj == self if obj responds to to_str"
fails "String#=== returns obj == self if obj responds to to_str"
fails "String#=== returns false if obj does not respond to to_str" #passes except for the line with symbol: fails "'hello'.send(@method, :hello).should be_false"

fails "String#=~ raises a TypeError if a obj is a string"

@@ -222,9 +219,8 @@
fails "String#each_byte keeps iterating from the old position (to new string end) when self changes"
fails "String#each_byte passes each byte in self to the given block"

fails "String#== returns obj == self if obj responds to to_str"
fails "String#== returns false if obj does not respond to to_str"
fails "String#eql? when given a non-String returns false"
fails "String#== returns false if obj does not respond to to_str" #passes except for the line with symbol: fails "'hello'.send(@method, :hello).should be_false"
fails "String#eql? when given a non-String returns false" #passes except for the line with symbol: fails "'hello'.should_not eql(:hello)"

fails "String#hex treats leading characters of self as a string of hex digits"