~ubuntu-branches/ubuntu/intrepid/ruby1.9/intrepid-updates

« back to all changes in this revision

Viewing changes to test/ruby/test_thread.rb

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-09-04 16:01:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070904160117-i15zckg2nhxe9fyw
Tags: 1.9.0+20070830-2ubuntu1
* Sync from Debian; remaining changes:
  - Add -g to CFLAGS.
* Fixes build failure on ia64.
* Fixes build failure with gcc-4.2 on lpia.
* Robustify check for target_os, fixing build failure on lpia.
* Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'test/unit'
 
2
 
 
3
class TestThread < Test::Unit::TestCase
 
4
  def test_mutex_synchronize
 
5
    m = Mutex.new
 
6
    r = 0
 
7
    max = 100
 
8
    (1..max).map{
 
9
      Thread.new{
 
10
        i=0
 
11
        while i<max*max
 
12
          i+=1
 
13
          m.synchronize{
 
14
            r += 1
 
15
          }
 
16
        end
 
17
      }
 
18
    }.each{|e|
 
19
      e.join
 
20
    }
 
21
    assert_equal(max * max * max, r)
 
22
  end
 
23
end
 
24