~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to test/io/nonblock/test_flush.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'test/unit'
 
2
begin
 
3
  require 'io/nonblock'
 
4
rescue LoadError
 
5
end
 
6
 
 
7
class TestIONonblock < Test::Unit::TestCase
 
8
  def test_flush                # [ruby-dev:24985]
 
9
    r,w = IO.pipe
 
10
    w.nonblock = true
 
11
    w.sync = false
 
12
    w << "b"
 
13
    w.flush
 
14
    w << "a" * 4096
 
15
    Thread.new {
 
16
      Thread.pass
 
17
      w.close
 
18
    }
 
19
    result = ""
 
20
    t = Thread.new {
 
21
      while (Thread.pass; s = r.read(4096))
 
22
        result << s
 
23
      end
 
24
    }
 
25
    assert_raise(IOError) {w.flush}
 
26
    assert_nothing_raised {t.join}
 
27
  end
 
28
end if IO.method_defined?(:nonblock)