Skip to content

Commit

Permalink
Use Enumerable specs entirely from rubyspec
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Sep 20, 2013
1 parent 047b8ef commit d15a61a
Show file tree
Hide file tree
Showing 34 changed files with 70 additions and 1,125 deletions.
6 changes: 5 additions & 1 deletion corelib/enumerable.rb
Expand Up @@ -268,6 +268,8 @@ def each_slice(n, &block)
end

def each_with_index(&block)
return enum_for :each_with_index unless block_given?

%x{
var index = 0;
Expand All @@ -288,7 +290,9 @@ def each_with_index(&block)
}
end

def each_with_object(object, &block)
def each_with_object(object = undefined, &block)
return enum_for :each_with_object unless block_given?

%x{
#{self}.$each._p = function() {
var value;
Expand Down
5 changes: 5 additions & 0 deletions spec/filters/bugs/enumerable/drop.rb
@@ -0,0 +1,5 @@
opal_filter "Enumerable#drop" do
fails "Enumerable#drop passed a number n as an argument raise ArgumentError if n < 0"
fails "Enumerable#drop passed a number n as an argument tries to convert n to an Integer using #to_int"
fails "Enumerable#drop passed a number n as an argument raises a TypeError when the passed n can be coerced to Integer"
end
6 changes: 6 additions & 0 deletions spec/filters/bugs/enumerable/drop_while.rb
@@ -0,0 +1,6 @@
opal_filter "Enumerable#drop_while" do
fails "Enumerable#drop_while returns an Enumerator if no block given"
fails "Enumerable#drop_while passes elements to the block until the first false"
fails "Enumerable#drop_while will only go through what's needed"
fails "Enumerable#drop_while gathers whole arrays as elements when each yields multiple"
end
7 changes: 7 additions & 0 deletions spec/filters/bugs/enumerable/each_slice.rb
@@ -0,0 +1,7 @@
opal_filter "Enumerable#each_slice" do
fails "Enumerable#each_slice tries to convert n to an Integer using #to_int"
fails "Enumerable#each_slice raises an Argument Error if there is not a single parameter > 0"
fails "Enumerable#each_slice yields only as much as needed"
fails "Enumerable#each_slice gathers whole arrays as elements when each yields multiple"
fails "Enumerable#each_slice returns an enumerator if no block"
end
6 changes: 6 additions & 0 deletions spec/filters/bugs/enumerable/each_with_index.rb
@@ -0,0 +1,6 @@
opal_filter "Enumerable#each_with_index" do
fails "Enumerable#each_with_index provides each element to the block"
fails "Enumerable#each_with_index provides each element to the block and its index"
fails "Enumerable#each_with_index binds splat arguments properly"
fails "Enumerable#each_with_index passes extra parameters to each"
end
3 changes: 3 additions & 0 deletions spec/filters/bugs/enumerable/each_with_object.rb
@@ -0,0 +1,3 @@
opal_filter "Enumerable#each_with_object" do
fails "Enumerable#each_with_object returns an enumerator if no block"
end
4 changes: 4 additions & 0 deletions spec/filters/bugs/enumerable/find_index.rb
@@ -0,0 +1,4 @@
opal_filter "Enumerable#find_index" do
fails "Enumerable#find_index returns an Enumerator if no block given"
fails "Enumerable#find_index gathers initial args as elements when each yields multiple"
end
3 changes: 3 additions & 0 deletions spec/filters/bugs/enumerable/grep.rb
@@ -0,0 +1,3 @@
opal_filter "Enumerable#grep" do
fails "Enumerable#grep can use $~ in the block when used with a Regexp"
end
5 changes: 5 additions & 0 deletions spec/filters/bugs/enumerable/group_by.rb
@@ -0,0 +1,5 @@
opal_filter "Enumerable#group_by" do
fails "Enumerable#group_by returns a hash without default_proc"
fails "Enumerable#group_by returns an Enumerator if called without a block"
fails "Enumerable#group_by gathers whole arrays as elements when each yields multiple"
end
3 changes: 3 additions & 0 deletions spec/filters/bugs/enumerable/take.rb
@@ -0,0 +1,3 @@
opal_filter "Enumerable#take" do
fails "Enumerable#take requires an argument"
end
130 changes: 0 additions & 130 deletions spec/rubyspec/core/enumerable/all_spec.rb

This file was deleted.

150 changes: 0 additions & 150 deletions spec/rubyspec/core/enumerable/any_spec.rb

This file was deleted.

39 changes: 0 additions & 39 deletions spec/rubyspec/core/enumerable/collect_spec.rb

This file was deleted.

0 comments on commit d15a61a

Please sign in to comment.