summaryrefslogtreecommitdiff
path: root/test/rinda
diff options
context:
space:
mode:
authorseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-06 15:26:25 +0000
committerseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-06 15:26:25 +0000
commit3d359cecd815f6d6cd9eeb55e14f38de75ab03ee (patch)
treed184a84cc7c33fcdbc8c1c84ac868570da068605 /test/rinda
parent383964bc30a9e0b9f8f8a17dbf0ecd9450bfb90e (diff)
fix hash tuple bug
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rinda')
-rw-r--r--test/rinda/test_rinda.rb44
1 files changed, 36 insertions, 8 deletions
diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb
index d537eb0..a87c662 100644
--- a/test/rinda/test_rinda.rb
+++ b/test/rinda/test_rinda.rb
@@ -36,23 +36,51 @@ module TupleSpaceTestModule
tmpl = Rinda::Template.new({"message"=>String, "name"=>String})
assert_equal(2, tmpl.size)
assert(tmpl.match({"message"=>"Hello", "name"=>"Foo"}))
- assert(tmpl.match({"message"=>"Hello", "name"=>"Foo", 1=>2}))
- assert(tmpl.match({"message"=>"Hi", "name"=>"Foo", :name=>1}))
+ assert(tmpl.match({"message"=>"Hello", "name"=>"Foo", "1"=>2}))
+ assert(tmpl.match({"message"=>"Hi", "name"=>"Foo", "age"=>1}))
assert(!tmpl.match({"message"=>"Hello", "no_name"=>"Foo"}))
- tmpl = Rinda::Template.new({:message=>String, "name"=>String})
+ assert_raises(Rinda::InvalidHashTupleKey) do
+ tmpl = Rinda::Template.new({:message=>String, "name"=>String})
+ end
+ tmpl = Rinda::Template.new({"name"=>String})
assert_equal(1, tmpl.size)
assert(tmpl.match({"message"=>"Hello", "name"=>"Foo"}))
- assert(tmpl.match({"message"=>:symbol, "name"=>"Foo", 1=>2}))
- assert(tmpl.match({"message"=>"Hi", "name"=>"Foo", :name=>1}))
+ assert(tmpl.match({"message"=>:symbol, "name"=>"Foo", "1"=>2}))
+ assert(tmpl.match({"message"=>"Hi", "name"=>"Foo", "age"=>1}))
assert(!tmpl.match({"message"=>"Hello", "no_name"=>"Foo"}))
tmpl = Rinda::Template.new({"message"=>String, "name"=>String, :size=>2})
assert_equal(2, tmpl.size)
assert(tmpl.match({"message"=>"Hello", "name"=>"Foo"}))
- assert(!tmpl.match({"message"=>"Hello", "name"=>"Foo", 1=>2}))
- assert(!tmpl.match({"message"=>"Hi", "name"=>"Foo", :name=>1}))
+ assert(!tmpl.match({"message"=>"Hello", "name"=>"Foo", "1"=>2}))
+ assert(!tmpl.match({"message"=>"Hi", "name"=>"Foo", "age"=>1}))
+ assert(!tmpl.match({"message"=>"Hello", "no_name"=>"Foo"}))
+
+ tmpl = Rinda::Template.new({"message"=>String, :size=>2})
+ assert_equal(1, tmpl.size)
+ assert(tmpl.match({"message"=>"Hello", "name"=>"Foo"}))
+ assert(!tmpl.match({"message"=>"Hello", "name"=>"Foo", "1"=>2}))
+ assert(!tmpl.match({"message"=>"Hi", "name"=>"Foo", "age"=>1}))
+ assert(tmpl.match({"message"=>"Hello", "no_name"=>"Foo"}))
+
+ tmpl = Rinda::Template.new({"message"=>String, "name"=>nil})
+ assert_equal(2, tmpl.size)
+ assert(tmpl.match({"message"=>"Hello", "name"=>"Foo"}))
+ assert(tmpl.match({"message"=>"Hello", "name"=>"Foo", "1"=>2}))
+ assert(tmpl.match({"message"=>"Hi", "name"=>"Foo", "age"=>1}))
assert(!tmpl.match({"message"=>"Hello", "no_name"=>"Foo"}))
+
+ tmpl = Rinda::Template.new({:size=>2})
+ assert_equal(0, tmpl.size)
+ assert(tmpl.match({"message"=>"Hello", "name"=>"Foo"}))
+ assert(!tmpl.match({"message"=>"Hello", "name"=>"Foo", "1"=>2}))
+ assert(!tmpl.match({"message"=>"Hi", "name"=>"Foo", "age"=>1}))
+ assert(tmpl.match({"message"=>"Hello", "no_name"=>"Foo"}))
+
+ assert_raises(Rinda::InvalidHashTupleKey) do
+ @ts.write({:message=>String, "name"=>String})
+ end
end
def test_00_DRbObject
@@ -246,7 +274,7 @@ module TupleSpaceTestModule
end
assert_equal([], ary)
end
-
+
def test_cancel_01
entry = @ts.write([:removeme, 1])
assert_equal([[:removeme, 1]], @ts.read_all([nil, nil]))