Sha256: ec50c617b9dcef7f8e60d4da5266dee27bf345fc5ed448362b8b82478bbf8eef

Contents?: true

Size: 750 Bytes

Versions: 3

Compression:

Stored size: 750 Bytes

Contents

describe "Array#map" do
  it "returns a copy of array with each element replaced by the value returned by block" do
    a = ['a', 'b', 'c', 'd']
    b = a.map { |i| i + '!' }
    b.should == ['a!', 'b!', 'c!', 'd!']
    
    # ignore
    # b.object_id.should_not == a.object_id
  end
  
  it "does not return subclass instance"
  
  it "does not change self" do
    a = ['a', 'b', 'c', 'd']
    b = a.map { |i| i + '!' }
    a.should == ['a', 'b', 'c', 'd']
  end
  
  it "returns the evaluated value of the block if it broke in the block" do
    a = ['a', 'b', 'c', 'd']
    b = a.map { |i| 
      if i == 'c'
        break 0
      else
        i + '!'
      end
    }
    b.should == 0
  end
  
  it "returns an enumerator when no block given"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opal-0.3.2 gems/core/spec/core/array/map_spec.rb
opal-0.3.1 gems/core/spec/core/array/map_spec.rb
opal-0.3.0 gems/core/spec/core/array/map_spec.rb