| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
$:.unshift "../lib" |
|---|
| 6 |
require 'eventmachine' |
|---|
| 7 |
require 'test/unit' |
|---|
| 8 |
|
|---|
| 9 |
a = TCPServer.new('localhost', 6000) |
|---|
| 10 |
Thread.new { a.accept } |
|---|
| 11 |
|
|---|
| 12 |
module SlowClosers |
|---|
| 13 |
@@total_closed = 0 |
|---|
| 14 |
|
|---|
| 15 |
def post_init |
|---|
| 16 |
@@total_closed += 1 |
|---|
| 17 |
raise LocalJumpError.new() if @@total_closed == 2 |
|---|
| 18 |
end |
|---|
| 19 |
|
|---|
| 20 |
def unbind |
|---|
| 21 |
@@total_closed += 1 |
|---|
| 22 |
raise LocalJumpError.new() if @@total_closed == 2 |
|---|
| 23 |
end |
|---|
| 24 |
|
|---|
| 25 |
end |
|---|
| 26 |
|
|---|
| 27 |
class DeathEnd < Test::Unit::TestCase |
|---|
| 28 |
|
|---|
| 29 |
def setup |
|---|
| 30 |
SlowClosers.class_eval("@@total_closed = 0") |
|---|
| 31 |
end |
|---|
| 32 |
|
|---|
| 33 |
def test_ends_well_multi_thread |
|---|
| 34 |
begin |
|---|
| 35 |
passed = false |
|---|
| 36 |
EM::run { |
|---|
| 37 |
print "here3\n" |
|---|
| 38 |
3.times {EM::connect '127.0.0.1', 6000, SlowClosers} |
|---|
| 39 |
print "here5\n" |
|---|
| 40 |
} |
|---|
| 41 |
rescue LocalJumpError |
|---|
| 42 |
|
|---|
| 43 |
print "here2\n" |
|---|
| 44 |
passed = true |
|---|
| 45 |
end |
|---|
| 46 |
print "here\n" |
|---|
| 47 |
flunk unless passed |
|---|
| 48 |
end |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
end |
|---|
| 54 |
|
|---|