Sha256: bbea1437016761c7f7d2d5f024eefc902c4f533ff14ae28a9d48700e1c72d913

Contents?: true

Size: 399 Bytes

Versions: 22

Compression:

Stored size: 399 Bytes

Contents

require 'rspec'
require 'enumerable_ext'

describe Enumerable do
  describe '#stable_sort' do
    it 'sorts stably' do
      xs = [-2, 2, 1, -1]
      result = xs.stable_sort{|a, b| a.abs <=> b.abs}
      expected_result = [1, -1, -2, 2]
      expect(result).to eql expected_result
    end

    it 'does not require a block' do
      expect([3, 2, 1].stable_sort).to eql [1, 2, 3]
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
abstractivator-0.20.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.19.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.18.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.17.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.16.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.15.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.14.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.13.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.12.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.11.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.10.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.8.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.7.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.6.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.5.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.4.1 spec/lib/enumerable_ext_spec.rb
abstractivator-0.4.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.3.1 spec/lib/enumerable_ext_spec.rb
abstractivator-0.3.0 spec/lib/enumerable_ext_spec.rb
abstractivator-0.2.0 spec/lib/enumerable_ext_spec.rb