middleware/proxy: favor __send__ for method dispatch
[raindrops.git] / test / test_raindrops_gc.rb
blob209812923bc175677a0baa4e5308b6bcf494a602
1 # -*- encoding: binary -*-
2 require 'test/unit'
3 require 'raindrops'
5 class TestRaindropsGc < Test::Unit::TestCase
7   # we may need to create more garbage as GC may be less aggressive
8   # about expiring things.  This is completely unrealistic code,
9   # though...
10   def test_gc
11     assert_nothing_raised do
12       1000000.times { |i| Raindrops.new(24); [] }
13     end
14   end
16   def test_gc_postfork
17     tmp = Raindrops.new 2
18     pid = fork do
19       1000000.times do
20         tmp = Raindrops.new 2
21         tmp.to_ary
22       end
23     end
24     _, status = Process.waitpid2(pid)
25     assert status.success?
26     assert_equal [ 0, 0 ], tmp.to_ary
27     tmp.incr 1
28     assert_equal [ 0, 1 ], tmp.to_ary
29     pid = fork do
30       tmp.incr 1
31       exit([ 0, 2 ] == tmp.to_ary)
32     end
33     _, status = Process.waitpid2(pid)
34     assert status.success?
35     assert_equal [ 0, 2 ], tmp.to_ary
36   end
37 end if !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" &&
38        ENV["STRESS"].to_i != 0