Skip to content

Commit

Permalink
Add remaining array specs from rubyspec
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Dec 13, 2013
1 parent 5f7ec71 commit 71218a2
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 8 deletions.
86 changes: 86 additions & 0 deletions spec/opal/filters/bugs/array.rb
Expand Up @@ -96,13 +96,82 @@
fails "Array.new with (size, object=nil) calls #to_int to convert the size argument to an Integer when object is not given"
fails "Array.new with (size, object=nil) raises a TypeError if the size argument is not an Integer type"

fails "Array#permutation generates from a defensive copy, ignoring mutations"
fails "Array#permutation returns an Enumerator which works as expected even when the array was modified"
fails "Array#permutation truncates Float arguments"
fails "Array#permutation handles nested Arrays correctly"
fails "Array#permutation handles duplicate elements correctly"
fails "Array#permutation returns no permutations when the given length has no permutations"
fails "Array#permutation returns the empty permutation([]) when called on an empty Array"
fails "Array#permutation returns the empty permutation ([[]]) when the given length is 0"
fails "Array#permutation yields all permutations of given length to the block then returns self when called with block and argument"
fails "Array#permutation yields all permutations to the block then returns self when called with block but no arguments"
fails "Array#permutation returns an Enumerator of permutations of given length when called with an argument but no block"
fails "Array#permutation returns an Enumerator of all permutations when called without a block or arguments"

fails "Array#pop passed a number n as an argument raises an ArgumentError if more arguments are passed"

fails "Array#product when given an empty block returns self"
fails "Array#product when given a block will ignore unreasonable numbers of products and yield anyway"
fails "Array#product when given a block yields all combinations in turn"
fails "Array#product does not attempt to produce an unreasonable number of products"
fails "Array#product returns an empty array when the argument is an empty array"
fails "Array#product has no required argument"
fails "Array#product returns the expected result"
fails "Array#product returns converted arguments using :to_ary"

fails "Array#rassoc does not check the last element in each contained but speficically the second"
fails "Array#rassoc calls elem == obj on the second element of each contained array"

fails "Array#repeated_combination generates from a defensive copy, ignoring mutations"
fails "Array#repeated_combination accepts sizes larger than the original array"
fails "Array#repeated_combination yields a partition consisting of only singletons"
fails "Array#repeated_combination yields nothing when the array is empty and num is non zero"
fails "Array#repeated_combination yields [] when length is 0"
fails "Array#repeated_combination yields the expected repeated_combinations"
fails "Array#repeated_combination yields nothing for negative length and return self"
fails "Array#repeated_combination returns self when a block is given"
fails "Array#repeated_combination returns an enumerator when no block is provided"

fails "Array#repeated_permutation generates from a defensive copy, ignoring mutations"
fails "Array#repeated_permutation allows permutations larger than the number of elements"
fails "Array#repeated_permutation returns an Enumerator which works as expected even when the array was modified"
fails "Array#repeated_permutation truncates Float arguments"
fails "Array#repeated_permutation handles duplicate elements correctly"
fails "Array#repeated_permutation does not yield when called on an empty Array with a nonzero argument"
fails "Array#repeated_permutation yields the empty repeated_permutation ([[]]) when the given length is 0"
fails "Array#repeated_permutation yields all repeated_permutations to the block then returns self when called with block but no arguments"
fails "Array#repeated_permutation returns an Enumerator of all repeated permutations of given length when called without a block"

fails "Array#rindex rechecks the array size during iteration"

fails "Array#rotate! with an argument n raises a TypeError if not passed an integer-like argument"
fails "Array#rotate! with an argument n coerces the argument using to_int"
fails "Array#rotate! with an argument n moves the first (n % size) elements at the end and returns self"
fails "Array#rotate! when passed no argument moves the first element to the end and returns self"
fails "Array#rotate! raises a RuntimeError on a frozen array"
fails "Array#rotate! does nothing and returns self when the length is zero or one"
fails "Array#rotate with an argument n raises a TypeError if not passed an integer-like argument"
fails "Array#rotate with an argument n coerces the argument using to_int"
fails "Array#rotate with an argument n returns a copy of the array with the first (n % size) elements moved at the end"
fails "Array#rotate when passed no argument returns a copy of the array with the first element moved at the end"
fails "Array#rotate does not return subclass instance for Array subclasses"
fails "Array#rotate does not return self"
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 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 returns at most the number of elements in the Array"

fails "Array#shift passed a number n as an argument raises an ArgumentError if more arguments are passed"
fails "Array#shift passed a number n as an argument raises a TypeError when the passed n can be coerced to Integer"
fails "Array#shift passed a number n as an argument tries to convert n to an Integer using #to_int"
Expand All @@ -129,6 +198,14 @@
fails "Array#slice! removes and return elements in range"
fails "Array#slice! calls to_int on start and length arguments"

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"
fails "Array#sort_by! raises a RuntimeError on an empty frozen array"
fails "Array#sort_by! raises a RuntimeError on a frozen array"
fails "Array#sort_by! completes when supplied a block that always returns the same result"
fails "Array#sort_by! returns an Enumerator if not given a block"
fails "Array#sort_by! sorts array in place by passing each element to the given block"

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"

Expand Down Expand Up @@ -163,4 +240,13 @@
fails "Array#partition returns in the left array values for which the block evaluates to true"
fails "Array#partition returns two arrays"
fails "Array#partition does not return subclass instances on Array subclasses"

fails "Array#| does not call to_ary on array subclasses"
fails "Array#| does not return subclass instances for Array subclasses"
fails "Array#| acts as if using an intermediate hash to collect values"
fails "Array#| tries to convert the passed argument to an Array using #to_ary"
fails "Array#| properly handles recursive arrays"
fails "Array#| creates an array with elements in order they are first encountered"
fails "Array#| creates an array with no duplicates"
fails "Array#| returns an array of elements that appear in either array (union)"
end
16 changes: 8 additions & 8 deletions spec/opal/rubyspecs
Expand Up @@ -53,27 +53,27 @@ core/array/multiply_spec
core/array/new_spec
core/array/nitems_spec
core/array/partition_spec
# core/array/permutation_spec
core/array/permutation_spec
core/array/plus_spec
core/array/pop_spec
# core/array/product_spec
core/array/product_spec
core/array/push_spec
core/array/rassoc_spec
core/array/reject_spec
# core/array/repeated_combination_spec
# core/array/repeated_permutation_spec
core/array/repeated_combination_spec
core/array/repeated_permutation_spec
core/array/replace_spec
core/array/reverse_each_spec
core/array/reverse_spec
core/array/rindex_spec
# core/array/rotate_spec
# core/array/sample_spec
core/array/rotate_spec
core/array/sample_spec
core/array/select_spec
core/array/shift_spec
core/array/shuffle_spec
core/array/size_spec
core/array/slice_spec
# core/array/sort_by_spec
core/array/sort_by_spec
core/array/sort_spec
core/array/take_spec
core/array/take_while_spec
Expand All @@ -82,7 +82,7 @@ core/array/to_ary_spec
core/array/to_s_spec
core/array/transpose_spec
core/array/try_convert_spec
# core/array/union_spec
core/array/union_spec
core/array/uniq_spec
core/array/unshift_spec
core/array/values_at_spec
Expand Down

0 comments on commit 71218a2

Please sign in to comment.