Changeset 191
- Timestamp:
- 06/03/06 15:18:03 (2 years ago)
- Files:
-
- experiments/NewMachine/test/event1_test.rb (modified) (3 diffs)
- experiments/NewMachine/test/event_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
experiments/NewMachine/test/event1_test.rb
r183 r191 14 14 15 15 def setup 16 #Reactor.instance.clear_dispatchers 16 17 end 17 18 … … 30 31 ed.add_handler(TestEvent) {|evt| 31 32 fired += evt.value 32 Reactor.stop if fired >= 1000 33 Reactor.stop if fired >= 10000 33 34 } 34 35 … … 53 54 end 54 55 56 class MyDispatcher < EventDispatcher 57 @@previous = [] 58 59 def initialize 60 super 61 @@previous << self 62 add_handler String, self, :string_event 63 end 64 65 def string_event evt 66 p @@previous.length 67 if @@previous.length > 1 68 @@previous[-2].send_event "a" 69 end 70 if @@previous.length < 1000 71 md = MyDispatcher.new 72 else 73 Machine::Reactor.stop 74 end 75 end 76 end 77 78 def test_separated_events 79 Reactor.run { 80 a,b = Socket::socketpair( Socket::AF_UNIX, Socket::SOCK_STREAM, 0) 81 EventableStream.new a 82 83 md = MyDispatcher.new 84 md.send_event "A" 85 md = MyDispatcher.new 86 md.send_event "A" 87 } 88 end 89 55 90 end 56 91 experiments/NewMachine/test/event_test.rb
r183 r191 21 21 22 22 def teardown 23 @reactor.clear_dispatchers23 #@reactor.clear_dispatchers 24 24 end 25 25