summaryrefslogtreecommitdiff
path: root/test/test_pstore.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_pstore.rb')
-rw-r--r--test/test_pstore.rb36
1 files changed, 34 insertions, 2 deletions
diff --git a/test/test_pstore.rb b/test/test_pstore.rb
index 52b74f3775..7dfbdca367 100644
--- a/test/test_pstore.rb
+++ b/test/test_pstore.rb
@@ -75,7 +75,7 @@ class PStoreTest < Test::Unit::TestCase
end
def test_thread_safe
- q1 = Queue.new
+ q1 = Thread::Queue.new
assert_raise(PStore::Error) do
th = Thread.new do
@pstore.transaction do
@@ -92,7 +92,7 @@ class PStoreTest < Test::Unit::TestCase
th.join
end
end
- q2 = Queue.new
+ q2 = Thread::Queue.new
begin
pstore = PStore.new(second_file, true)
cur = Thread.current
@@ -144,6 +144,38 @@ class PStoreTest < Test::Unit::TestCase
assert_equal(bug5311, @pstore.transaction {@pstore["Bug5311"]}, bug5311)
end
+ def test_key_p
+ [:key?, :root?].each do |method|
+ clear_store
+ @pstore.transaction do
+ @pstore[:foo] = 0
+ assert_equal(true, @pstore.send(method, :foo))
+ assert_equal(false, @pstore.send(method, :bar))
+ end
+ end
+ end
+
+ def test_keys
+ [:keys, :roots].each do |method|
+ clear_store
+ @pstore.transaction do
+ assert_equal([], @pstore.send(method))
+ end
+ @pstore.transaction do
+ @pstore[:foo] = 0
+ assert_equal([:foo], @pstore.send(method))
+ end
+ end
+ end
+
+ def clear_store
+ @pstore.transaction do
+ @pstore.keys.each do |key|
+ @pstore.delete(key)
+ end
+ end
+ end
+
def second_file
File.join(Dir.tmpdir, "pstore.tmp2.#{Process.pid}")
end