File: test_array.rb

package info (click to toggle)
ruby-thread-safe 0.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 700 kB
  • ctags: 1,072
  • sloc: java: 5,458; ruby: 2,750; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 401 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'test/unit'
require 'thread_safe'

class TestArray < Test::Unit::TestCase
  def test_concurrency
    ary = ThreadSafe::Array.new
    assert_nothing_raised do
      (1..100).map do |i|
        Thread.new do
          1000.times do
            ary << i
            ary.each {|x| x * 2}
            ary.shift
            ary.last
          end
        end
      end.map(&:join)
    end
  end
end