Module: Thread::Etest
- Defined in:
- lib/vex/base/thread/sleep.rb,
lib/vex/base/thread/deferred.rb
Instance Method Summary collapse
Instance Method Details
#test_deferred ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/vex/base/thread/deferred.rb', line 20 def test_deferred i = 0 Thread.deferred do i = 1 end Thread.sleep 0.05 assert_equal(1, i) end |
#test_deferred_exception ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vex/base/thread/deferred.rb', line 30 def test_deferred_exception i = 0 Thread.deferred do i = 1 raise i = 2 end Thread.sleep 0.05 assert_equal(1, i) end |
#test_pids ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vex/base/thread/deferred.rb', line 42 def test_pids pids = [ Thread.uid ] Thread.deferred { pids[1] = Thread.uid } Thread.deferred { pids[2] = Thread.uid } Thread.sleep 0.05 assert_equal(pids, pids.compact) assert_equal(pids, pids.uniq) end |