Sha256: 87a095858560df50231f59a05e5d53cd0c5cf4dc55cc81d4da34df4cf31118df

Contents?: true

Size: 679 Bytes

Versions: 23

Compression:

Stored size: 679 Bytes

Contents

describe "Array#each_index" do
  before :each do
    ScratchPad.record []
  end

  it "passes the index of each element to the block" do
    a = ['a', 'b', 'c', 'd']
    a.each_index { |i| ScratchPad << i }
    ScratchPad.recorded.should == [0, 1, 2, 3]
  end

  it "returns self" do
    a = [:a, :b, :c]
    a.each_index { |i| }.should equal(a)
  end

  it "is not confused by removing elements from the front" do
    a = [1, 2, 3]

    a.shift
    ScratchPad.record []
    a.each_index { |i| ScratchPad << i }
    ScratchPad.recorded.should == [0, 1]

    a.shift
    ScratchPad.record []
    a.each_index { |i| ScratchPad << i }
    ScratchPad.recorded.should == [0]
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
opal-0.3.41 spec/core/array/each_index_spec.rb
opal-0.3.40 spec/core/array/each_index_spec.rb
opal-0.3.39 spec/core/array/each_index_spec.rb
opal-0.3.38 spec/core/array/each_index_spec.rb
opal-0.3.37 spec/core/array/each_index_spec.rb
opal-0.3.36 spec/core/array/each_index_spec.rb
opal-0.3.35 spec/core/array/each_index_spec.rb
opal-0.3.34 spec/core/array/each_index_spec.rb
opal-0.3.33 spec/core/array/each_index_spec.rb
opal-0.3.32 spec/core/array/each_index_spec.rb
opal-0.3.31 spec/core/array/each_index_spec.rb
opal-0.3.30 spec/core/array/each_index_spec.rb
opal-0.3.29 spec/core/array/each_index_spec.rb
opal-0.3.28 spec/core/array/each_index_spec.rb
opal-0.3.27 spec/core/array/each_index_spec.rb
opal-0.3.26 spec/core/array/each_index_spec.rb
opal-0.3.25 spec/core/array/each_index_spec.rb
opal-0.3.22 spec/core/array/each_index_spec.rb
opal-0.3.21 test/core/array/each_index_spec.rb
opal-0.3.20 test/core/array/each_index_spec.rb