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: a2a2d11ab082
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 19a2e5a560cd
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Nov 10, 2013

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    9b6be50 View commit details
  2. Copy the full SHA
    d894a81 View commit details
  3. Copy the full SHA
    19a2e5a View commit details
Showing with 9 additions and 11 deletions.
  1. +8 −4 opal/core/enumerable.rb
  2. +0 −7 spec/filters/bugs/enumerable.rb
  3. +1 −0 spec/rubyspecs
12 changes: 8 additions & 4 deletions opal/core/enumerable.rb
Original file line number Diff line number Diff line change
@@ -285,6 +285,10 @@ def drop_while(&block)
def each_slice(n, &block)
n = Opal.coerce_to n, Integer, :to_int

if `n <= 0`
raise ArgumentError, 'invalid slice size'
end

return enum_for :each_slice, n unless block_given?

%x{
@@ -323,8 +327,8 @@ def each_slice(n, &block)
nil
end

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

%x{
var result,
@@ -342,14 +346,14 @@ def each_with_index(&block)
index++;
};
self.$each();
self.$each.apply(self, args);
if (result !== undefined) {
return result;
}
}

nil
self
end

def each_with_object(object, &block)
7 changes: 0 additions & 7 deletions spec/filters/bugs/enumerable.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
opal_filter "Enumerable" do
fails "Enumerable#cycle passed a number n as an argument raises an ArgumentError if more arguments are passed"

fails "Enumerable#each_slice raises an Argument Error if there is not a single parameter > 0"

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"

fails "Enumerable#entries passes arguments to each"

fails "Enumerable#first when passed an argument consumes only what is needed"
1 change: 1 addition & 0 deletions spec/rubyspecs
Original file line number Diff line number Diff line change
@@ -116,6 +116,7 @@ core/nil/xor_spec

core/enumerable/all_spec
core/enumerable/any_spec
core/enumerable/cycle_spec
core/enumerable/collect_spec
core/enumerable/count_spec
core/enumerable/detect_spec