From 22887fa36f2de81f6577801e949c73fe08c595c7 Mon Sep 17 00:00:00 2001 From: Toshiaki Asai Date: Fri, 23 Aug 2013 13:34:06 +0900 Subject: 起動終了後はフィルタを別スレッドで実行 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/core/test_plugin.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/core') diff --git a/test/core/test_plugin.rb b/test/core/test_plugin.rb index 39082111..6cc81de1 100644 --- a/test/core/test_plugin.rb +++ b/test/core/test_plugin.rb @@ -27,6 +27,35 @@ class TC_Plugin < Test::Unit::TestCase assert_equal(2, sum) end + must "filter in another thread" do + filter_thread = nil + Plugin.create(:event) do + on_thread do + end + + filter_thread do + filter_thread = Thread.current + [] + end + end + Event[:thread].call + Delayer.run while not Delayer.empty? + assert filter_thread + assert_equal Thread.current, filter_thread + + Event.filter_another_thread = true + filter_thread = nil + r = true + Event[:thread].call.next{ r = false }.trap{ r = false } + + Delayer.run while r + # p r + # p SerialThread.instance_eval{ @queue.size } + # p Delayer.empty? + assert filter_thread + assert_not_equal Thread.current, filter_thread + end + must "uninstall" do sum = 0 Plugin.create(:event) do @@ -119,3 +148,4 @@ class TC_Plugin < Test::Unit::TestCase end end + -- cgit v1.2.3