Sha256: 25744cd23500d7cab73047fab09d331d8cfdb43c95ff4cdd4c3148d10b3ab420

Contents?: true

Size: 584 Bytes

Versions: 15

Compression:

Stored size: 584 Bytes

Contents

describe "Array#rindex" do
  it "returns the first index backwards from the end where element == to object" do
    [2, 1, 3, 5, 1].rindex(3).should == 2
  end

  it "returns size-1 if last element == to object" do
    [2, 1, 3, 2, 5].rindex(5).should == 4
  end

  it "returns 0 if only first element == to object" do
    [2, 1, 3, 1, 5].rindex(2).should == 0
  end

  it "returns nil if no element == to object" do
    [1, 1, 3, 2, 1, 3].rindex(4).should == nil
  end

  it "accepts a block instead of an argument" do
    [4, 2, 1, 5, 1, 3].rindex { |x| x < 2 }.should == 4
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
opal-0.3.41 spec/core/array/rindex_spec.rb
opal-0.3.40 spec/core/array/rindex_spec.rb
opal-0.3.39 spec/core/array/rindex_spec.rb
opal-0.3.38 spec/core/array/rindex_spec.rb
opal-0.3.37 spec/core/array/rindex_spec.rb
opal-0.3.36 spec/core/array/rindex_spec.rb
opal-0.3.35 spec/core/array/rindex_spec.rb
opal-0.3.34 spec/core/array/rindex_spec.rb
opal-0.3.33 spec/core/array/rindex_spec.rb
opal-0.3.32 spec/core/array/rindex_spec.rb
opal-0.3.31 spec/core/array/rindex_spec.rb
opal-0.3.30 spec/core/array/rindex_spec.rb
opal-0.3.29 spec/core/array/rindex_spec.rb
opal-0.3.28 spec/core/array/rindex_spec.rb
opal-0.3.27 spec/core/array/rindex_spec.rb