Skip to content

Commit

Permalink
Fix Array.try_convert compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Nov 27, 2013
1 parent 423241a commit b05aa05
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
6 changes: 2 additions & 4 deletions opal/corelib/array.rb
Expand Up @@ -75,10 +75,8 @@ def self.new(size = nil, obj = nil, &block)
end

def self.try_convert(obj)
return obj if Array === obj
return obj.to_ary if obj.respond_to? :to_ary

nil
return nil unless obj.respond_to? :to_ary
obj = Opal.coerce_to obj, Array, :to_ary
end

def &(other)
Expand Down
4 changes: 0 additions & 4 deletions spec/opal/filters/bugs/array.rb
Expand Up @@ -132,11 +132,7 @@
fails "Array#transpose raises a TypeError if the passed Argument does not respond to #to_ary"
fails "Array#transpose tries to convert the passed argument to an Array using #to_ary"

fails "Array.try_convert does not rescue exceptions raised by #to_ary"
fails "Array.try_convert sends #to_ary to the argument and raises TypeError if it's not a kind of Array"
fails "Array.try_convert sends #to_ary to the argument and returns the result if it's a kind of Array"
fails "Array.try_convert sends #to_ary to the argument and returns the result if it's an Array"
fails "Array.try_convert sends #to_ary to the argument and returns the result if it's nil"

fails "Array#uniq compares elements based on the value returned from the block"
fails "Array#uniq compares elements with matching hash codes with #eql?"
Expand Down

0 comments on commit b05aa05

Please sign in to comment.