summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-05 20:39:54 +0000
committerseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-05 20:39:54 +0000
commit319531524b0be46b216e40eaa43086b86d30eae3 (patch)
treea342ac9039fb111055a62da219c062866857605a
parent4117048c4097301007ba48563c27ec13fa3a828c (diff)
* test/rinda/test_rinda.rb (test_core_03_notify): Fixed test failures
[ruby-dev:44430] [Ruby 1.9 - Bug #372] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/rinda/test_rinda.rb75
2 files changed, 25 insertions, 55 deletions
diff --git a/ChangeLog b/ChangeLog
index a16e823c0d..a84421ec64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Sep 6 05:37:11 2011 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * test/rinda/test_rinda.rb (test_core_03_notify): Fixed test failures
+ [ruby-dev:44430] [Ruby 1.9 - Bug #372]
+
Mon Sep 5 20:59:30 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
* insns.def: change encoding pragma for emacs (shift_jis to utf-8).
diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb
index 8154b46da3..52a276e73b 100644
--- a/test/rinda/test_rinda.rb
+++ b/test/rinda/test_rinda.rb
@@ -308,70 +308,35 @@ module TupleSpaceTestModule
def test_core_03_notify
notify1 = @ts.notify(nil, [:req, Integer])
- notify2 = @ts.notify(nil, {"message"=>String, "name"=>String}, 8)
+ notify2 = @ts.notify(nil, {"message"=>String, "name"=>String})
- @ts.write({"message"=>"first", "name"=>"3"}, 3)
- @ts.write({"message"=>"second", "name"=>"1"}, 1)
- @ts.write({"message"=>"third", "name"=>"0"})
- @ts.take({"message"=>"third", "name"=>"0"})
-
- listener = Thread.new do
- lv = 0
- n = 0
- notify1.each do |ev, tuple|
- n += 1
- if ev == 'write'
- lv = lv + 1
- elsif ev == 'take'
- lv = lv - 1
- else
- break
- end
- assert(lv >= 0)
- assert_equal([:req, 2], tuple)
- end
- [lv, n]
+ 5.times do |n|
+ @ts.write([:req, 2])
end
- taker = Thread.new(5) do |count|
- s = 0
- count.times do
- tuple = @ts.take([:req, Integer])
- assert_equal(2, tuple[1])
- s += tuple[1]
- end
- @ts.write([:ans, s])
- s
+ 5.times do
+ tuple = @ts.take([:req, Integer])
+ assert_equal(2, tuple[1])
end
- 5.times do |n|
- @ts.write([:req, 2])
+ 5.times do
+ assert_equal(['write', [:req, 2]], notify1.pop)
+ end
+ 5.times do
+ assert_equal(['take', [:req, 2]], notify1.pop)
end
+ @ts.write({"message"=>"first", "name"=>"3"})
+ @ts.write({"message"=>"second", "name"=>"1"})
+ @ts.write({"message"=>"third", "name"=>"0"})
+ @ts.take({"message"=>"third", "name"=>"0"})
@ts.take({"message"=>"first", "name"=>"3"})
- assert_equal(10, thread_join(taker))
- assert_equal([:ans, 10], @ts.take([:ans, 10]))
- assert_equal([], @ts.read_all([nil, nil]))
-
- notify1.cancel
- sleep(8)
-
- assert_equal([0, 11], thread_join(listener))
-
- ary = []
- ary.push(["write", {"message"=>"first", "name"=>"3"}])
- ary.push(["write", {"message"=>"second", "name"=>"1"}])
- ary.push(["write", {"message"=>"third", "name"=>"0"}])
- ary.push(["take", {"message"=>"third", "name"=>"0"}])
- ary.push(["take", {"message"=>"first", "name"=>"3"}])
- ary.push(["delete", {"message"=>"second", "name"=>"1"}])
- ary.push(["close"])
-
- notify2.each do |ev|
- assert_equal(ary.shift, ev)
- end
- assert_equal([], ary)
+ assert_equal(["write", {"message"=>"first", "name"=>"3"}], notify2.pop)
+ assert_equal(["write", {"message"=>"second", "name"=>"1"}], notify2.pop)
+ assert_equal(["write", {"message"=>"third", "name"=>"0"}], notify2.pop)
+ assert_equal(["take", {"message"=>"third", "name"=>"0"}], notify2.pop)
+ assert_equal(["take", {"message"=>"first", "name"=>"3"}], notify2.pop)
end
def test_cancel_01