test/scheduler_test.rb in openwferu-0.9.4 vs test/scheduler_test.rb in openwferu-0.9.5
- old
+ new
@@ -26,11 +26,11 @@
def test_scheduler_0
$var = nil
scheduler = OpenWFE::Scheduler.new()
- scheduler.start
+ scheduler.sstart
sid = scheduler.schedule_in('2s', TestSchedulable.new, nil)
assert \
sid,
@@ -39,11 +39,11 @@
assert \
(not $var),
"scheduler_0 is blocking but should not"
sleep(2.5)
- scheduler.do_stop
+ scheduler.sstop
#puts ">#{$var}<"
assert \
($var == "ok"),
@@ -53,11 +53,11 @@
def test_scheduler_1
$var = nil
scheduler = OpenWFE::Scheduler.new()
- scheduler.start
+ scheduler.sstart
sid = scheduler.schedule_in('1s') do
$var = "ok..1"
end
@@ -68,16 +68,43 @@
assert \
(not $var),
"scheduler_1 is blocking but should not"
sleep(2)
- scheduler.do_stop
+ scheduler.sstop
#puts ">#{$var}<"
assert \
($var == "ok..1"),
"scheduler_1 didn't work"
+ end
+
+ #
+ # test idea by ara.t.howard on the ruby-talk ml
+ #
+ def test_scheduler_2
+
+ text = ""
+
+ scheduler = OpenWFE::Scheduler.new()
+ scheduler.sstart
+
+ scheduler.schedule_in("1s") do
+ text << "one"
+ sleep(2)
+ end
+ scheduler.schedule_in("1s") do
+ text << "two"
+ end
+
+ sleep(2)
+
+ scheduler.sstop
+
+ #puts text
+
+ assert text == "onetwo"
end
protected
class TestSchedulable