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 | c8d5f06b1c2a7627b432a58fbf08493f200815c6 (patch) | |
| tree | 4dd32a4eabd9f71c5de8fc8450061fe34fee6d14 /test | |
| parent | 4fbac4522ee279def63ceab3f8bf3710473fcee1 (diff) | |
| download | ruby-c8d5f06b1c2a7627b432a58fbf08493f200815c6.tar.gz ruby-c8d5f06b1c2a7627b432a58fbf08493f200815c6.tar.xz ruby-c8d5f06b1c2a7627b432a58fbf08493f200815c6.zip | |
fix hash tuple bug
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@6111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
| -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])) |
