summaryrefslogtreecommitdiff
path: root/test/dbm/test_dbm.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-01 18:43:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-01 18:43:13 +0000
commite4518c5bde0f72723d784ba142df46df6407915b (patch)
treefb114dd39c18de64db2fc8c90faedace1db52f50 /test/dbm/test_dbm.rb
parentb66d7182b7030b1a69d6d72e0bc2e7b7cf7f8bb1 (diff)
dbm.c: yield dup of keystr
* ext/dbm/dbm.c (fdbm_fetch): yield dup of keystr, to make it shared and get rid of use of uninitialized variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/dbm/test_dbm.rb')
-rw-r--r--test/dbm/test_dbm.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/dbm/test_dbm.rb b/test/dbm/test_dbm.rb
index 9f7604be15..083a5c25ba 100644
--- a/test/dbm/test_dbm.rb
+++ b/test/dbm/test_dbm.rb
@@ -58,6 +58,14 @@ if defined? DBM
assert_nil(@dbm_rdonly.delete("bar"))
end
end
+
+ def test_fetch_not_found
+ notfound = nil
+ result = Object.new
+ assert_same(result, @dbm_rdonly.fetch("bar") {|k| notfound = k; result})
+ assert_equal("bar", notfound)
+ assert_predicate(notfound, :tainted?)
+ end
end
class TestDBM < Test::Unit::TestCase