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: 71d4d1b0ccc6
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 578f02be6be3
Choose a head ref

Commits on Jun 11, 2015

  1. Copy the full SHA
    b9e80ac View commit details
  2. Copy the full SHA
    3368fee View commit details
  3. Pass "String#gsub with pattern and without replacement and block retu…

    …rned Enumerator size should return nil"
    vais committed Jun 11, 2015
    Copy the full SHA
    192d3b0 View commit details
  4. Pass "String#each_char when no block is given returned enumerator siz…

    …e should return the size of the string"
    vais committed Jun 11, 2015
    Copy the full SHA
    b041641 View commit details
  5. Copy the full SHA
    bc13227 View commit details
  6. Update spec/rubyspec submodule

    vais committed Jun 11, 2015
    Copy the full SHA
    9533833 View commit details

Commits on Jun 13, 2015

  1. Copy the full SHA
    b591df4 View commit details
  2. Copy the full SHA
    44e44a5 View commit details
  3. Copy the full SHA
    9b91a2a View commit details
  4. Copy the full SHA
    3871f1d View commit details
  5. Copy the full SHA
    e021c89 View commit details
  6. Copy the full SHA
    fb3747a View commit details
  7. Copy the full SHA
    b83eaff View commit details
  8. Copy the full SHA
    1933038 View commit details
  9. Copy the full SHA
    b3f0d85 View commit details
  10. Copy the full SHA
    6d032ce View commit details
  11. Copy the full SHA
    ee156ba View commit details
  12. Copy the full SHA
    d13bbe1 View commit details
  13. Add fail filters for Math.cbrt

    vais committed Jun 13, 2015
    Copy the full SHA
    9f54784 View commit details
  14. Copy the full SHA
    954b724 View commit details
  15. Copy the full SHA
    dfa4b8c View commit details
  16. Fix "returned Enumerator size" failures for Array

    Fixing #combination and #permutation is left as an exercise for PhD candidates.
    vais committed Jun 13, 2015
    Copy the full SHA
    24f756f View commit details
  17. Fix Enumerator#with_index

    vais committed Jun 13, 2015
    Copy the full SHA
    ba22ab8 View commit details
  18. Copy the full SHA
    b197851 View commit details
  19. Merge pull request #933 from vais/rubyspec

    Fix a few of the new Rubyspec failures
    elia committed Jun 13, 2015
    Copy the full SHA
    578f02b View commit details
37 changes: 22 additions & 15 deletions opal/corelib/array.rb
Original file line number Diff line number Diff line change
@@ -517,9 +517,16 @@ def bsearch(&block)
end

def cycle(n = nil, &block)
return if empty? || n == 0
return enum_for(:cycle, n) {
if n == nil
Float::INFINITY
else
n = Opal.coerce_to!(n, Integer, :to_int)
n > 0 ? self.enumerator_size * n : 0
end
} unless block_given?

return enum_for :cycle, n unless block
return if empty? || n == 0

%x{
var i, length, value;
@@ -581,7 +588,7 @@ def initialize_copy(other)
end

def collect(&block)
return enum_for :collect unless block_given?
return enum_for(:collect){self.size} unless block_given?

%x{
var result = [];
@@ -601,7 +608,7 @@ def collect(&block)
end

def collect!(&block)
return enum_for :collect! unless block_given?
return enum_for(:collect!){self.size} unless block_given?

%x{
for (var i = 0, length = self.length; i < length; i++) {
@@ -620,7 +627,7 @@ def collect!(&block)

def combination(n)
num = Opal.coerce_to! n, Integer, :to_int
return enum_for :combination, num unless block_given?
return enum_for(:combination, num){self.size} unless block_given?

%x{
var i, length, stack, chosen, lev, done, next;
@@ -757,7 +764,7 @@ def delete_at(index)
end

def delete_if(&block)
return enum_for :delete_if unless block_given?
return enum_for(:delete_if){self.size} unless block_given?

%x{
for (var i = 0, length = self.length, value; i < length; i++) {
@@ -790,7 +797,7 @@ def drop(number)
alias dup clone

def each(&block)
return enum_for :each unless block_given?
return enum_for(:each){self.size} unless block_given?

%x{
for (var i = 0, length = self.length; i < length; i++) {
@@ -806,7 +813,7 @@ def each(&block)
end

def each_index(&block)
return enum_for :each_index unless block_given?
return enum_for(:each_index){self.size} unless block_given?

%x{
for (var i = 0, length = self.length; i < length; i++) {
@@ -1246,7 +1253,7 @@ def join(sep = nil)
end

def keep_if(&block)
return enum_for :keep_if unless block_given?
return enum_for(:keep_if){self.size} unless block_given?

%x{
for (var i = 0, length = self.length, value; i < length; i++) {
@@ -1295,7 +1302,7 @@ def length
alias map! collect!

def permutation(num = undefined, &block)
return enum_for(:permutation, num) unless block_given?
return enum_for(:permutation, num){self.size} unless block_given?

%x{
var permute, offensive, output;
@@ -1458,7 +1465,7 @@ def rassoc(object)
end

def reject(&block)
return enum_for :reject unless block_given?
return enum_for(:reject){self.size} unless block_given?

%x{
var result = [];
@@ -1477,7 +1484,7 @@ def reject(&block)
end

def reject!(&block)
return enum_for :reject! unless block_given?
return enum_for(:reject!){self.size} unless block_given?

original = length
delete_if(&block)
@@ -1511,7 +1518,7 @@ def reverse!
end

def reverse_each(&block)
return enum_for :reverse_each unless block_given?
return enum_for(:reverse_each){self.size} unless block_given?

reverse.each &block
self
@@ -1707,7 +1714,7 @@ def sample(count = undefined, options = undefined)
end

def select(&block)
return enum_for :select unless block_given?
return enum_for(:select){self.size} unless block_given?

%x{
var result = [];
@@ -1729,7 +1736,7 @@ def select(&block)
end

def select!(&block)
return enum_for :select! unless block_given?
return enum_for(:select!){self.size} unless block_given?

%x{
var original = self.length;
35 changes: 21 additions & 14 deletions opal/corelib/enumerable.rb
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ def chunk(state = undefined, &block)
end

def collect(&block)
return enum_for :collect unless block_given?
return enum_for(:collect){self.enumerator_size} unless block_given?

%x{
var result = [];
@@ -95,7 +95,7 @@ def collect(&block)
end

def collect_concat(&block)
return enum_for :collect_concat unless block_given?
return enum_for(:collect_concat){self.enumerator_size} unless block_given?
map { |item| yield item }.flatten(1)
end

@@ -132,7 +132,14 @@ def count(object = undefined, &block)
end

def cycle(n = nil, &block)
return enum_for :cycle, n unless block
return enum_for(:cycle, n) {
if n == nil
respond_to?(:size) ? Float::INFINITY : nil
else
n = Opal.coerce_to!(n, Integer, :to_int)
n > 0 ? self.enumerator_size * n : 0
end
} unless block_given?

unless n.nil?
n = Opal.coerce_to! n, Integer, :to_int
@@ -303,7 +310,7 @@ def each_slice(n, &block)
raise ArgumentError, 'invalid slice size'
end

return enum_for :each_slice, n unless block_given?
return enum_for(:each_slice, n){respond_to?(:size) ? (size / n).ceil : nil} unless block_given?

%x{
var result,
@@ -342,7 +349,7 @@ def each_slice(n, &block)
end

def each_with_index(*args, &block)
return enum_for :each_with_index, *args unless block_given?
return enum_for(:each_with_index, *args){self.enumerator_size} unless block_given?

%x{
var result,
@@ -371,7 +378,7 @@ def each_with_index(*args, &block)
end

def each_with_object(object, &block)
return enum_for :each_with_object, object unless block_given?
return enum_for(:each_with_object, object){self.enumerator_size} unless block_given?

%x{
var result;
@@ -413,7 +420,7 @@ def entries(*args)
alias find detect

def find_all(&block)
return enum_for :find_all unless block_given?
return enum_for(:find_all){self.enumerator_size} unless block_given?

%x{
var result = [];
@@ -566,7 +573,7 @@ def grep(pattern, &block)
end

def group_by(&block)
return enum_for :group_by unless block_given?
return enum_for(:group_by){self.enumerator_size} unless block_given?

hash = Hash.new

@@ -729,7 +736,7 @@ def max(&block)
end

def max_by(&block)
return enum_for :max_by unless block
return enum_for(:max_by){self.enumerator_size} unless block

%x{
var result,
@@ -815,7 +822,7 @@ def min(&block)
end

def min_by(&block)
return enum_for :min_by unless block
return enum_for(:min_by){self.enumerator_size} unless block

%x{
var result,
@@ -937,7 +944,7 @@ def one?(&block)
end

def partition(&block)
return enum_for :partition unless block_given?
return enum_for(:partition){self.enumerator_size} unless block_given?

%x{
var truthy = [], falsy = [], result;
@@ -968,7 +975,7 @@ def partition(&block)
alias reduce inject

def reject(&block)
return enum_for :reject unless block_given?
return enum_for(:reject){self.enumerator_size} unless block_given?

%x{
var result = [];
@@ -994,7 +1001,7 @@ def reject(&block)
end

def reverse_each(&block)
return enum_for :reverse_each unless block_given?
return enum_for(:reverse_each){self.enumerator_size} unless block_given?

%x{
var result = [];
@@ -1082,7 +1089,7 @@ def sort(&block)
end

def sort_by(&block)
return enum_for :sort_by unless block_given?
return enum_for(:sort_by){self.enumerator_size} unless block_given?

map {
arg = Opal.destructure(`arguments`)
2 changes: 1 addition & 1 deletion opal/corelib/enumerator.rb
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ def with_index(offset = 0, &block)
offset = 0
end

return enum_for :with_index, offset unless block
return enum_for(:with_index, offset){self.size} unless block

%x{
var result, index = offset;
18 changes: 9 additions & 9 deletions opal/corelib/hash.rb
Original file line number Diff line number Diff line change
@@ -311,7 +311,7 @@ def delete(key, &block)
end

def delete_if(&block)
return enum_for :delete_if unless block
return enum_for(:delete_if){self.size} unless block

%x{
var _map = self.map,
@@ -352,7 +352,7 @@ def delete_if(&block)
alias dup clone

def each(&block)
return enum_for :each unless block
return enum_for(:each){self.size} unless block

%x{
var _map = self.map,
@@ -383,8 +383,8 @@ def each(&block)
end

def each_key(&block)
return enum_for :each_key unless block
# @keys.each(&block)
return enum_for(:each_key){self.size} unless block

%x{
var keys = self.keys, key;
@@ -403,7 +403,7 @@ def each_key(&block)
alias each_pair each

def each_value(&block)
return enum_for :each_value unless block
return enum_for(:each_value){self.size} unless block

%x{
var _map = self.map,
@@ -729,7 +729,7 @@ def invert
end

def keep_if(&block)
return enum_for :keep_if unless block
return enum_for(:keep_if){self.size} unless block

%x{
var _map = self.map,
@@ -888,7 +888,7 @@ def rassoc(object)
end

def reject(&block)
return enum_for :reject unless block
return enum_for(:reject){self.size} unless block

%x{
var keys = self.keys,
@@ -960,7 +960,7 @@ def replace(other)
end

def select(&block)
return enum_for :select unless block
return enum_for(:select){self.size} unless block

%x{
var keys = self.keys,
@@ -1003,7 +1003,7 @@ def select(&block)
end

def select!(&block)
return enum_for :select! unless block
return enum_for(:select!){self.size} unless block

%x{
var _map = self.map,
26 changes: 16 additions & 10 deletions opal/corelib/numeric.rb
Original file line number Diff line number Diff line change
@@ -269,14 +269,17 @@ def conj

alias conjugate conj

def downto(finish, &block)
return enum_for :downto, finish unless block
def downto(stop, &block)
return enum_for(:downto, stop){
raise ArgumentError, "comparison of #{self.class} with #{stop.class} failed" unless Numeric === stop
stop > self ? 0 : self - stop + 1
} unless block_given?

%x{
if (!finish.$$is_number) {
#{raise ArgumentError, "comparison of #{self.class} with #{finish.class} failed"}
if (!stop.$$is_number) {
#{raise ArgumentError, "comparison of #{self.class} with #{stop.class} failed"}
}
for (var i = self; i >= finish; i--) {
for (var i = self; i >= stop; i--) {
if (block(i) === $breaker) {
return $breaker.$v;
}
@@ -464,14 +467,17 @@ def divmod(rhs)
[q, r]
end

def upto(finish, &block)
return enum_for :upto, finish unless block
def upto(stop, &block)
return enum_for(:upto, stop){
raise ArgumentError, "comparison of #{self.class} with #{stop.class} failed" unless Numeric === stop
stop < self ? 0 : stop - self + 1
} unless block_given?

%x{
if (!finish.$$is_number) {
#{raise ArgumentError, "comparison of #{self.class} with #{finish.class} failed"}
if (!stop.$$is_number) {
#{raise ArgumentError, "comparison of #{self.class} with #{stop.class} failed"}
}
for (var i = self; i <= finish; i++) {
for (var i = self; i <= stop; i++) {
if (block(i) === $breaker) {
return $breaker.$v;
}
Loading