diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-08 00:46:28 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-08 00:46:28 +0000 |
commit | 4e3c92899712bf10bf12947caffb14d2dc86cba0 (patch) | |
tree | a89f9744e33fea1c3a261a5adbe4f8eab131dc9d /test/dbm | |
parent | 79634569e483d82874c9eaadf0d3a61c1b529fa8 (diff) |
merge revision(s) 33673:
* test/dbm/test_dbm.rb: split tests for read only database.
* test/gdbm/test_gdbm.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/dbm')
-rw-r--r-- | test/dbm/test_dbm.rb | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/test/dbm/test_dbm.rb b/test/dbm/test_dbm.rb index bc1b5ee27e..e61ddbbe60 100644 --- a/test/dbm/test_dbm.rb +++ b/test/dbm/test_dbm.rb @@ -10,8 +10,8 @@ if defined? DBM require 'tmpdir' require 'fileutils' - class TestDBM < Test::Unit::TestCase - def TestDBM.uname_s + class TestDBM_RDONLY < Test::Unit::TestCase + def TestDBM_RDONLY.uname_s require 'rbconfig' case RbConfig::CONFIG['target_os'] when 'cygwin' @@ -31,7 +31,6 @@ if defined? DBM @tmpdir = Dir.mktmpdir("tmptest_dbm") @prefix = "tmptest_dbm_#{$$}" @path = "#{@tmpdir}/#{@prefix}_" - assert_instance_of(DBM, @dbm = DBM.new(@path)) # prepare to make readonly DBM file DBM.open("#{@tmpdir}/#{@prefix}_rdonly") {|dbm| @@ -43,7 +42,6 @@ if defined? DBM assert_instance_of(DBM, @dbm_rdonly = DBM.new("#{@tmpdir}/#{@prefix}_rdonly", nil)) end def teardown - assert_nil(@dbm.close) assert_nil(@dbm_rdonly.close) ObjectSpace.each_object(DBM) do |obj| obj.close unless obj.closed? @@ -51,6 +49,32 @@ if defined? DBM FileUtils.remove_entry_secure @tmpdir end + def test_delete_rdonly + if /^CYGWIN_9/ !~ SYSTEM + assert_raise(DBMError) { + @dbm_rdonly.delete("foo") + } + + assert_nil(@dbm_rdonly.delete("bar")) + end + end + end + + class TestDBM < Test::Unit::TestCase + def setup + @tmpdir = Dir.mktmpdir("tmptest_dbm") + @prefix = "tmptest_dbm_#{$$}" + @path = "#{@tmpdir}/#{@prefix}_" + assert_instance_of(DBM, @dbm = DBM.new(@path)) + end + def teardown + assert_nil(@dbm.close) + ObjectSpace.each_object(DBM) do |obj| + obj.close unless obj.closed? + end + FileUtils.remove_entry_secure @tmpdir + end + def check_size(expect, dbm=@dbm) assert_equal(expect, dbm.size) n = 0 @@ -325,15 +349,8 @@ if defined? DBM assert_equal(2, @dbm.size) assert_nil(@dbm.delete(key)) - - if /^CYGWIN_9/ !~ SYSTEM - assert_raise(DBMError) { - @dbm_rdonly.delete("foo") - } - - assert_nil(@dbm_rdonly.delete("bar")) - end end + def test_delete_with_block key = 'no called block' @dbm[key] = 'foo' |