diff options
author | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-04-06 15:26:25 +0000 |
---|---|---|
committer | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-04-06 15:26:25 +0000 |
commit | 86a34bd0f3b11183e1f8d0f7b6b2589a7a7d9710 (patch) | |
tree | d184a84cc7c33fcdbc8c1c84ac868570da068605 /test/rinda | |
parent | 384413139860fab487582faa3f32ecea87edf0e8 (diff) | |
download | ruby-86a34bd0f3b11183e1f8d0f7b6b2589a7a7d9710.tar.gz ruby-86a34bd0f3b11183e1f8d0f7b6b2589a7a7d9710.tar.xz ruby-86a34bd0f3b11183e1f8d0f7b6b2589a7a7d9710.zip |
fix hash tuple bug
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@6111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rinda')
-rw-r--r-- | test/rinda/test_rinda.rb | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb index d537eb0ac..a87c66258 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])) |