Sha256: e461f226762e887cad25bc700a411ef70aec049b4ddd86bd50ed47c11962e494

Contents?: true

Size: 607 Bytes

Versions: 10

Compression:

Stored size: 607 Bytes

Contents

describe "Array#sort and Array#sort!" do
  it "return new sorted Array if #sort" do
    a = [2, 7, 5, 9]
    b = a.sort

    b.should == [2, 5, 7, 9]
    b.object_id.should_not == a.object_id
  end

  it "return same sorted Array if #sort!" do
    a = [2, 7, 5, 9]
    b = a.sort!

    b.should == [2, 5, 7, 9]
    b.object_id.should == a.object_id
  end

  it "#sort and #sort! should support sorting functions" do
    ["one", "two", "three", "four"].sort {|a , b| a.length  <=> b.length }.should == ["one", "two", "four", "three"]
    [2, 7, 5, 9].sort! {|a , b| b <=> a }.should == [9, 7, 5, 2]
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
opal-0.3.41 spec/core/array/sort_spec.rb
opal-0.3.40 spec/core/array/sort_spec.rb
opal-0.3.39 spec/core/array/sort_spec.rb
opal-0.3.38 spec/core/array/sort_spec.rb
opal-0.3.37 spec/core/array/sort_spec.rb
opal-0.3.36 spec/core/array/sort_spec.rb
opal-0.3.35 spec/core/array/sort_spec.rb
opal-0.3.34 spec/core/array/sort_spec.rb
opal-0.3.33 spec/core/array/sort_spec.rb
opal-0.3.32 spec/core/array/sort_spec.rb