ruby-changes:6792
From: mame <ko1@a...>
Date: Fri, 1 Aug 2008 21:50:31 +0900 (JST)
Subject: [ruby-changes:6792] Ruby:r18308 (trunk): * test/sdbm/test_sdbm.rb: add some tests.
mame 2008-08-01 21:50:17 +0900 (Fri, 01 Aug 2008) New Revision: 18308 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18308 Log: * test/sdbm/test_sdbm.rb: add some tests. Modified files: trunk/ChangeLog trunk/test/sdbm/test_sdbm.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 18307) +++ ChangeLog (revision 18308) @@ -1,3 +1,7 @@ +Fri Aug 1 21:49:41 2008 Yusuke Endoh <mame@t...> + + * test/sdbm/test_sdbm.rb: add some tests. + Fri Aug 1 21:36:00 2008 Yusuke Endoh <mame@t...> * gc.c (allocate_heaps, assign_heap_slot, rb_newobj_from_heap): Index: test/sdbm/test_sdbm.rb =================================================================== --- test/sdbm/test_sdbm.rb (revision 18307) +++ test/sdbm/test_sdbm.rb (revision 18308) @@ -525,5 +525,39 @@ assert_equal(key.to_i, val.to_i) } end + + def test_closed + assert_equal(false, @sdbm.closed?) + @sdbm.close + assert_equal(true, @sdbm.closed?) + @sdbm = SDBM.new(@path) + end + + def test_index + assert_equal(nil, @sdbm.index("foo")) + @sdbm["bar"] = "foo" + assert_equal("bar", @sdbm.index("foo")) + end + + def test_readonly + @sdbm["bar"] = "baz" + @sdbm.close + File.chmod(0444, @path + ".dir") + File.chmod(0444, @path + ".pag") + @sdbm = SDBM.new(@path) + assert_raise(SDBMError) { @sdbm["bar"] = "foo" } + assert_raise(SDBMError) { @sdbm.delete("bar") } + assert_raise(SDBMError) { @sdbm.delete_if { true } } + assert_raise(SDBMError) { @sdbm.clear } + assert_nil(@sdbm.store("bar", nil)) + end + + def test_update2 + obj = Object.new + def obj.each_pair + yield [] + end + assert_raise(ArgumentError) { @sdbm.update(obj) } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/