Sha256: 124ab061aaa6c5a6edf77e9ff313c316e16d95ff76f0905c4dd3032765f783b7

Contents?: true

Size: 1.63 KB

Versions: 47

Compression:

Stored size: 1.63 KB

Contents

require "spec_helper"
require "bunny/concurrent/synchronized_sorted_set"

unless ENV["CI"]
  describe Bunny::Concurrent::SynchronizedSortedSet do
    50.times do |i|
      it "provides the same API as SortedSet for key operations (take #{i})" do
        s = described_class.new
        expect(s.length).to eq 0

        s << 1
        expect(s.length).to eq 1
        s << 1
        expect(s.length).to eq 1
        s << 2
        expect(s.length).to eq 2
        s << 3
        expect(s.length).to eq 3
        s << 4
        expect(s.length).to eq 4
        s << 4
        s << 4
        s << 4
        expect(s.length).to eq 4
        s << 5
        expect(s.length).to eq 5
        s << 5
        s << 5
        s << 5
        expect(s.length).to eq 5
        s << 6
        expect(s.length).to eq 6
        s << 7
        expect(s.length).to eq 7
        s << 8
        expect(s.length).to eq 8
        s.delete 8
        expect(s.length).to eq 7
        s.delete_if { |i| i == 1 }
        expect(s.length).to eq 6
      end
      it "synchronizes common operations needed by Bunny (take #{i})" do
        s = described_class.new
        expect(s.length).to eq 0

        10.times do
          Thread.new do
            s << 1
            s << 1
            s << 2
            s << 3
            s << 4
            s << 4
            s << 4
            s << 4
            s << 5
            s << 5
            s << 5
            s << 5
            s << 6
            s << 7
            s << 8
            s.delete 8
            s.delete_if { |i| i == 1 }
          end
        end
        sleep 0.5

        expect(s.length).to eq 6
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
bunny-2.19.0 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.18.0 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.17.0 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.16.1 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.15.0 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.14.4 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.14.3 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.14.2 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.14.1 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.13.0 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.12.1 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.12.0 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.12.0.rc1 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.11.0 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.11.0.pre1 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.10.0 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.9.2 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.9.1 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.6.7 spec/unit/concurrent/synchronized_sorted_set_spec.rb
bunny-2.7.4 spec/unit/concurrent/synchronized_sorted_set_spec.rb