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 | 027d0af0d0e1b636acc747ec1719981d626836a2 (patch) | |
tree | 4dd32a4eabd9f71c5de8fc8450061fe34fee6d14 /test/rinda | |
parent | efa746c6bd61d6f327c6c1f0742284d768704d47 (diff) |
fix hash tuple bug
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@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 d537eb0ac1..a87c66258c 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])) |