root/trunk/tests/test_defer.rb

Revision 802, 1.2 kB (checked in by raggi, 8 months ago)

ruby 1.9 compatibility enhancements

  • Property svn:keywords set to Id
Line 
1 # $Id$
2 #
3 # Author:: Francis Cianfrocca (gmail: blackhedd)
4 # Homepage::  http://rubyeventmachine.com
5 # Date:: 8 April 2006
6 #
7 # See EventMachine and EventMachine::Connection for documentation and
8 # usage examples.
9 #
10 #----------------------------------------------------------------------------
11 #
12 # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13 # Gmail: blackhedd
14 #
15 # This program is free software; you can redistribute it and/or modify
16 # it under the terms of either: 1) the GNU General Public License
17 # as published by the Free Software Foundation; either version 2 of the
18 # License, or (at your option) any later version; or 2) Ruby's License.
19 #
20 # See the file COPYING for complete licensing information.
21 #
22 #---------------------------------------------------------------------------
23 #
24 #
25 #
26
27 $:.unshift "../lib"
28 require 'eventmachine'
29 require 'test/unit'
30
31 class TestDeferUsage < Test::Unit::TestCase
32
33   def test_defers
34     n = 0
35     n_times = 20
36     EM.run {
37       n_times.times {
38         work_proc = proc { n += 1 }
39         callback = proc { EM.stop if n == n_times }
40         EM.defer work_proc, callback
41       }
42     }
43     assert_equal( n, n_times )
44   end unless RUBY_VERSION >= '1.9.0'
45
46 end
47
Note: See TracBrowser for help on using the browser.