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

Commits on Apr 11, 2014

  1. Enumerator fixes: Kernel#to_enum and Enumerator#each

      * Implement Kernel#to_enum as an alias for #enum_for
      * Enumerator#each now accepts arguments
    mieko committed Apr 11, 2014

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    marsam Mario Rodas
    Copy the full SHA
    ddbd523 View commit details
  2. Copy the full SHA
    d2e43f7 View commit details
  3. Merge pull request #531 from mieko/categorize_specs

    Triage uncategorized specs
    elia committed Apr 11, 2014
    Copy the full SHA
    cdb2b92 View commit details
Showing with 224 additions and 231 deletions.
  1. +7 −3 opal/corelib/enumerator.rb
  2. +2 −0 opal/corelib/kernel.rb
  3. +29 −9 spec/filters/bugs/array.rb
  4. +2 −0 spec/filters/bugs/basic_object.rb
  5. +1 −0 spec/filters/bugs/class.rb
  6. +6 −2 spec/filters/bugs/enumerable.rb
  7. +3 −0 spec/filters/bugs/enumerator.rb
  8. +6 −3 spec/filters/bugs/hash.rb
  9. +14 −0 spec/filters/bugs/language.rb
  10. +3 −1 spec/filters/bugs/math.rb
  11. +1 −1 spec/filters/bugs/numeric.rb
  12. +2 −0 spec/filters/bugs/regexp.rb
  13. +40 −4 spec/filters/bugs/string.rb
  14. +1 −0 spec/filters/bugs/stringscanner.rb
  15. +7 −2 spec/filters/bugs/struct.rb
  16. +23 −0 spec/filters/bugs/time.rb
  17. +0 −33 spec/filters/uncategorized/array.rb
  18. +0 −4 spec/filters/uncategorized/basic_object.rb
  19. +0 −3 spec/filters/uncategorized/class.rb
  20. +0 −13 spec/filters/uncategorized/enumerable.rb
  21. +0 −16 spec/filters/uncategorized/enumerator.rb
  22. +0 −14 spec/filters/uncategorized/hash.rb
  23. +0 −14 spec/filters/uncategorized/language.rb
  24. +0 −4 spec/filters/uncategorized/math.rb
  25. +0 −3 spec/filters/uncategorized/numeric.rb
  26. +0 −4 spec/filters/uncategorized/regexp.rb
  27. +0 −67 spec/filters/uncategorized/string.rb
  28. +0 −3 spec/filters/uncategorized/string_scanner.rb
  29. +0 −7 spec/filters/uncategorized/struct.rb
  30. +0 −17 spec/filters/uncategorized/time.rb
  31. +34 −2 spec/filters/unsupported/encoding.rb
  32. +1 −0 spec/filters/unsupported/enumerator.rb
  33. +3 −2 spec/filters/unsupported/frozen.rb
  34. +14 −0 spec/filters/unsupported/mutable_strings.rb
  35. +11 −0 spec/filters/unsupported/tainted.rb
  36. +14 −0 spec/filters/unsupported/trusted.rb
10 changes: 7 additions & 3 deletions opal/corelib/enumerator.rb
Original file line number Diff line number Diff line change
@@ -35,10 +35,14 @@ def initialize(*, &block)
end
end

def each(&block)
return self unless block
def each(*args, &block)
return self if block.nil? && args.empty?

@object.__send__(@method, *@args, &block)
args = @args + args

return self.class.new(@object, @method, *args) if block.nil?

@object.__send__(@method, *args, &block)
end

def size
2 changes: 2 additions & 0 deletions opal/corelib/kernel.rb
Original file line number Diff line number Diff line change
@@ -140,6 +140,8 @@ def enum_for(method = :each, *args, &block)
Enumerator.for(self, method, *args, &block)
end

alias to_enum enum_for

def equal?(other)
`self === other`
end
38 changes: 29 additions & 9 deletions spec/filters/bugs/array.rb
Original file line number Diff line number Diff line change
@@ -130,17 +130,29 @@
fails "Array#rotate does not mutate the receiver"
fails "Array#rotate returns a copy of the array when its length is one or zero"

fails "Array#sample raises a RangeError if the value is equal to the Array size"
fails "Array#sample raises a RangeError if the value is less than zero"
fails "Array#sample calls #to_int on the Object returned by #rand"
fails "Array#sample ignores an Object passed for the RNG if it does not define #rand"
fails "Array#sample calls #rand on the Object passed by the :random key in the arguments Hash"
fails "Array#sample calls #to_int on the first argument and #to_hash on the second when passed Objects"
fails "Array#sample calls #to_hash to convert the passed Object"
fails "Array#sample raises ArgumentError when passed a negative count"
fails "Array#sample calls #to_int on the Object returned by #rand"
fails "Array#sample calls #to_int on the first argument and #to_hash on the second when passed Objects"
fails "Array#sample calls #to_int to convert the count when passed an Object"
fails "Array#sample does not return the same value if the Array has unique values"
fails "Array#sample ignores an Object passed for the RNG if it does not define #rand"
fails "Array#sample raises ArgumentError when passed a negative count"
fails "Array#sample raises a RangeError if the value is equal to the Array size"
fails "Array#sample raises a RangeError if the value is less than zero"
fails "Array#sample returns at most the number of elements in the Array"
fails "Array#sample when the object returned by #rand is not a Fixnum but responds to #to_int calls #to_int on the Object"
fails "Array#sample when the object returned by #rand is not a Fixnum but responds to #to_int raises a RangeError if the value is equal to the Array size"
fails "Array#sample when the object returned by #rand is not a Fixnum but responds to #to_int raises a RangeError if the value is less than zero"
fails "Array#sample with options calls #rand on the Object passed by the :random key in the arguments Hash"
fails "Array#sample with options calls #to_hash to convert the passed Object"
fails "Array#sample with options calls #to_int on the first argument and #to_hash on the second when passed Objects"
fails "Array#sample with options ignores an Object passed for the RNG if it does not define #rand"
fails "Array#sample with options when the object returned by #rand is a Fixnum raises a RangeError if the value is equal to the Array size"
fails "Array#sample with options when the object returned by #rand is a Fixnum raises a RangeError if the value is less than zero"
fails "Array#sample with options when the object returned by #rand is a Fixnum uses the fixnum as index"

fails "Array#select returns a new array of elements for which block is true"

fails "Array#shuffle attempts coercion via #to_hash"
fails "Array#shuffle is not destructive"
@@ -154,11 +166,12 @@

fails "Array#shuffle! returns the same values, in a usually different order"

fails "Array#slice! does not expand array with negative indices out of bounds"
fails "Array#slice! does not expand array with indices out of bounds"
fails "Array#slice! calls to_int on range arguments"
fails "Array#slice! removes and return elements in range"
fails "Array#slice! calls to_int on start and length arguments"
fails "Array#slice! does not expand array with indices out of bounds"
fails "Array#slice! does not expand array with negative indices out of bounds"
fails "Array#slice! removes and return elements in range"
fails "Array#slice! removes and returns elements in end-exclusive ranges"

fails "Array#sort_by! makes some modification even if finished sorting when it would break in the given block"
fails "Array#sort_by! returns the specified value when it would break in the given block"
@@ -170,7 +183,9 @@

fails "Array#uniq compares elements based on the value returned from the block"
fails "Array#uniq compares elements with matching hash codes with #eql?"
fails "Array#uniq handles nil and false like any other values"
fails "Array#uniq uses eql? semantics"
fails "Array#uniq yields items in order"

fails "Array#uniq! compares elements based on the value returned from the block"

@@ -179,6 +194,11 @@
fails "Array#values_at returns an array of elements in the ranges when passes ranges"
fails "Array#values_at calls to_int on arguments of ranges when passes ranges"
fails "Array#values_at does not return subclass instance on Array subclasses"
fails "Array#values_at when passed ranges returns an array of elements in the ranges"
fails "Array#values_at when passed ranges calls to_int on arguments of ranges"
fails "Array#values_at when passed a range fills with nil if the index is out of the range"
fails "Array#values_at when passed a range on an empty array fills with nils if the index is out of the range"


fails "Array#zip calls #to_ary to convert the argument to an Array"
fails "Array#zip uses #each to extract arguments' elements when #to_ary fails"
2 changes: 2 additions & 0 deletions spec/filters/bugs/basic_object.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
opal_filter "BasicObject" do
fails "BasicObject#instance_eval evaluates strings"
fails "BasicObject#singleton_method_added is called when a method is defined with alias_method in the singleton class"
fails "BasicObject#singleton_method_added is called when a method is defined with syntax alias in the singleton class"
fails "BasicObject instance metaclass contains methods defined for the BasicObject instance"
fails "BasicObject instance metaclass has BasicObject as superclass"
fails "BasicObject instance metaclass is an instance of Class"
1 change: 1 addition & 0 deletions spec/filters/bugs/class.rb
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
fails "Class#initialize_copy raises a TypeError when called on BasicObject"
fails "Class#initialize raises a TypeError when called on already initialized classes"
fails "Class#initialize raises a TypeError when called on BasicObject"
fails "Class#initialize when given the Class raises a TypeError"

fails "Class.new raises a TypeError if passed a metaclass"
fails "Class#new passes the block to #initialize"
8 changes: 6 additions & 2 deletions spec/filters/bugs/enumerable.rb
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@
fails "Enumerable#chunk yields the current element and the current chunk to the block"
fails "Enumerable#chunk returns an Enumerator if given a block"
fails "Enumerable#chunk raises an ArgumentError if called without a block"
fails "Enumerable#chunk with [initial_state] yields an element and an object value-equal but not identical to the object passed to #chunk"
fails "Enumerable#chunk with [initial_state] does not yield the object passed to #chunk if it is nil"

fails "Enumerable#each_cons gathers whole arrays as elements when each yields multiple"
fails "Enumerable#each_cons returns an enumerator if no block"
@@ -42,7 +44,7 @@
fails "Enumerable#minmax_by returns an enumerator if no block"

fails "Enumerable#minmax gathers whole arrays as elements when each yields multiple"
fails "Enumerable#minmax return the minimun when using a block rule"
fails "Enumerable#minmax returns the minimum when using a block rule"
fails "Enumerable#minmax raises a NoMethodError for elements without #<=>"
fails "Enumerable#minmax raises an ArgumentError when elements are incomparable"
fails "Enumerable#minmax returns [nil, nil] for an empty Enumerable"
@@ -56,7 +58,9 @@
fails "Enumerable#sort sorts enumerables that contain nils"
fails "Enumerable#sort raises a NoMethodError if elements do not define <=>"
fails "Enumerable#sort yields elements to the provided block"
fails "Enumerable#sort sorts by the natural order as defined by <=> "
fails "Enumerable#sort sorts by the natural order as defined by <=>"

fails "Enumerable#take_while calls the block with initial args when yielded with multiple arguments"

fails "Enumerable#zip passes each element of the result array to a block and return nil if a block is given"
fails "Enumerable#zip converts arguments to arrays using #to_ary"
3 changes: 3 additions & 0 deletions spec/filters/bugs/enumerator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
opal_filter "Enumerator" do
fails "Enumerator#each requires multiple arguments" # arity issue
end
9 changes: 6 additions & 3 deletions spec/filters/bugs/hash.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
opal_filter "Hash" do
fails "Hash#assoc only returns the first matching key-value pair for identity hashes"

fails "Hash.[] coerces a single argument which responds to #to_ary"
fails "Hash.[] ignores elements that are not arrays"
fails "Hash.[] calls to_hash"
@@ -10,6 +8,9 @@
fails "Hash.[] does not call #initialize on the subclass instance"
fails "Hash.[] passed an array treats elements that are 1 element arrays as keys with value nil"
fails "Hash.[] passed a single argument which responds to #to_hash coerces it and returns a copy"
fails "Hash.[] removes the default_proc"

fails "Hash#assoc only returns the first matching key-value pair for identity hashes"

fails "Hash#default_proc= uses :to_proc on its argument"

@@ -52,7 +53,7 @@
fails "Hash#fetch raises an ArgumentError when not passed one or two arguments"

fails "Hash#flatten recursively flattens Array values to the given depth"
fails "Hash#flatten raises an TypeError if given a non-Integer argument"
fails "Hash#flatten raises a TypeError if given a non-Integer argument"

fails "Hash#has_key? compares keys with the same #hash value via #eql?"
fails "Hash#has_key? returns true if argument is a key"
@@ -112,6 +113,8 @@
fails "Hash#sort works when some of the keys are themselves arrays"
fails "Hash#sort uses block to sort array if passed a block"

fails "Hash#to_h returns self for Hash instances"

fails "Hash#to_s handles hashes with recursive values"

fails "Hash.try_convert does not rescue exceptions raised by #to_hash"
14 changes: 14 additions & 0 deletions spec/filters/bugs/language.rb
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
fails "The alias keyword adds the new method to the list of methods"

fails "The unpacking splat operator (*) when applied to a non-Array value attempts to coerce it to Array if the object respond_to?(:to_a)"
fails "The unpacking splat operator (*) when applied to a non-Array value attempts to coerce it to Array if the object respond_to?(:to_ary)"
fails "The unpacking splat operator (*) returns a new array containing the same values when applied to an array inside an empty array"
fails "The unpacking splat operator (*) unpacks the start and count arguments in an array slice assignment"
fails "The unpacking splat operator (*) unpacks arguments as if they were listed statically"
@@ -155,6 +156,10 @@
fails "The defined? keyword for an expression with logical connectives returns nil for an expression with '!' and an unset global variable"
fails "The defined? keyword for an expression with logical connectives returns nil for an expression with 'not' and an unset class variable"
fails "The defined? keyword for an expression with logical connectives returns nil for an expression with '!' and an unset class variable"
fails "The defined? keyword for loop expressions returns 'expression' for a 'for' expression"
fails "The defined? keyword for loop expressions returns 'expression' for a 'retry' expression"
fails "The defined? keyword for literals for a literal Array returns nil if one element is not defined"
fails "The defined? keyword for literals for a literal Array returns nil if all elements are not defined"
fails "The defined? keyword for variables returns nil for a global variable that has been read but not assigned to"

fails "An ensure block inside a begin block is executed even when a symbol is thrown in it's corresponding begin block"
@@ -220,6 +225,10 @@
fails "A method call evaluates block pass after arguments"
fails "A method call evaluates arguments after receiver"

fails "not() returns false if the argument is true"
fails "not() returns true if the argument is false"
fails "not() returns true if the argument is nil"

fails "Operators or/and have higher precedence than if unless while until modifiers"
fails "Operators = %= /= -= += |= &= >>= <<= *= &&= ||= **= have higher precedence than defined? operator"
fails "Operators = %= /= -= += |= &= >>= <<= *= &&= ||= **= are right-associative"
@@ -251,15 +260,20 @@
fails "A Proc taking || arguments raises an ArgumentError if a value is passed"
fails "A Proc taking zero arguments raises an ArgumentErro if a value is passed"

fails "The redo statement raises a LocalJumpError if used not within block or while/for loop"

fails "The rescue keyword parses 'a += b rescue c' as 'a += (b rescue c)'"
fails "The rescue keyword will not rescue errors raised in an else block in the rescue block above it"
fails "The rescue keyword will not execute an else block if an exception was raised"
fails "The rescue keyword will execute an else block only if no exceptions were raised"

fails "The retry statement re-executes the closest block"
fails "The retry statement re-executes the entire enumeration"
fails "The retry statement raises a SyntaxError when used outside of a begin statement"
fails "The retry statement raises a LocalJumpError if used outside of a block"
fails "The retry keyword inside a begin block's rescue block causes the begin block to be executed again"


fails "The return keyword within a begin returns last value returned in nested ensures"
fails "The return keyword within a begin executes nested ensures before returning"
fails "The return keyword when passed a splat calls 'to_a' on the splatted value first"
4 changes: 3 additions & 1 deletion spec/filters/bugs/math.rb
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@
fails "Math.erf accepts any argument that can be coerced with Float()"
fails "Math#erf is accessible as a private instance method"

fails "Math.erfc returns the complementary error function of the argument"

fails "Math.frexp returns the normalized fraction and exponent"
fails "Math.frexp raises a TypeError if the argument cannot be coerced with Float()"
fails "Math.frexp returns NaN given NaN"
@@ -27,7 +29,7 @@
fails "Math.ldexp raises a TypeError if the first argument cannot be coerced with Float()"
fails "Math.ldexp returns NaN given NaN"
fails "Math.ldexp raises RangeError if NaN is given as the second arg"
fails "Math.ldexp raises an TypeError if the second argument cannot be coerced with Integer()"
fails "Math.ldexp raises a TypeError if the second argument cannot be coerced with Integer()"
fails "Math.ldexp raises a TypeError if the first argument is nil"
fails "Math.ldexp raises a TypeError if the second argument is nil"
fails "Math.ldexp accepts any first argument that can be coerced with Float()"
2 changes: 1 addition & 1 deletion spec/filters/bugs/numeric.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
opal_filter "Fixnum bugs" do
fails "Integer#downto [stop] when self and stop are Fixnums raises a ArgumentError for invalid endpoints"
fails "Integer#downto [stop] when self and stop are Fixnums raises an ArgumentError for invalid endpoints"

fails "Fixnum#to_s when no base given returns self converted to a String using base 10"

2 changes: 2 additions & 0 deletions spec/filters/bugs/regexp.rb
Original file line number Diff line number Diff line change
@@ -2,4 +2,6 @@
fails "Regexp#~ matches against the contents of $_"
fails "Regexp#match uses the start as a character offset"
fails "Regexp#match matches the input at a given position"
fails "Regexp#match with [string, position] when given a positive position matches the input at a given position"
fails "Regexp#match with [string, position] when given a negative position matches the input at a given position"
end
Loading