Sha256: cdd7a43b6f407ec785aa2a8d9495d538e5f33da2cdca75de2db252c3668f1d47

Contents?: true

Size: 732 Bytes

Versions: 3

Compression:

Stored size: 732 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!']
    # 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.2.2 opals/opal/opal/spec/core/array/map_spec.rb
opal-0.2.0 opals/opal/opal/spec/core/array/map_spec.rb
opal-0.1.0 opals/opal/spec/core/array/map_spec.rb