root/trunk/tests/test_eventables.rb

Revision 668, 1.7 kB (checked in by blackhedd, 1 year ago)

migrated version_0 to trunk

  • 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
30 require 'test/unit/testsuite'
31 require 'test/unit/ui/console/testrunner'
32
33
34 class TestEventables < Test::Unit::TestCase
35
36   class EvTest
37     include EventMachine::Eventable
38   end
39
40   def setup
41   end
42
43   def teardown
44   end
45
46   def test_a; end # shut up rake until we define a test.
47
48   # TODO, this idea is still half-baked.
49   def xxx_test_a
50     n = 0
51     tester = EvTest.new
52     tester.listen_event( :fire1 ) {|arg|
53       n = 1 if arg == "$"
54       EventMachine.stop
55     }
56     tester.post_event( :fire1, "$" )
57    
58     EventMachine.run {
59       EventMachine::add_timer(1) {EventMachine.stop}
60     }
61
62     assert_equal( 1, n )
63   end
64
65 end
66
67
68 #--------------------------------------
69
70 if __FILE__ == $0
71   runner = Test::Unit::UI::Console::TestRunner
72   suite = Test::Unit::TestSuite.new("name")
73   ObjectSpace.each_object(Class) do |testcase|
74     suite << testcase.suite if testcase < Test::Unit::TestCase
75   end
76   runner.run(suite)
77 end
78
Note: See TracBrowser for help on using the browser.