diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-13 06:02:59 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-13 06:02:59 +0000 |
commit | f7081431f2c645b198db8ca00ab195c6b8c3d189 (patch) | |
tree | e874d7f4bbfb8dc3716e80a2a95f6440cf17152f /test/test_pstore.rb | |
parent | faa2bef46da2dd219e8eaecbd9e21821e3aa0ea9 (diff) | |
download | ruby-f7081431f2c645b198db8ca00ab195c6b8c3d189.tar.gz |
* lib/pstore.rb (PStore): always open in binary mode even if
default encodings are set. [Bug #5311] [ruby-core:39503]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_pstore.rb')
-rw-r--r-- | test/test_pstore.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test_pstore.rb b/test/test_pstore.rb index b5deb9f359..21831903cf 100644 --- a/test/test_pstore.rb +++ b/test/test_pstore.rb @@ -1,5 +1,6 @@ require 'test/unit' require 'pstore' +require_relative 'ruby/envutil' class PStoreTest < Test::Unit::TestCase def setup @@ -110,4 +111,21 @@ class PStoreTest < Test::Unit::TestCase pstore.transaction { pstore.transaction { } } end end + + # Test that PStore's file operations do not blow up when default encodings are set + def test_pstore_files_are_accessed_as_binary_files + bug5311 = '[ruby-core:39503]' + n = 128 + assert_in_out_err(["-rpstore", "-", @pstore_file], <<-SRC, [bug5311], [], bug5311) + @pstore = PStore.new(ARGV[0]) + Encoding.default_internal = 'utf-8' + Encoding.default_external = 'utf-8' + (1..#{n}).each do |i| + @pstore.transaction {@pstore["Key\#{i}"] = "value \#{i}"} + end + @pstore.transaction {@pstore["Bug5311"] = '#{bug5311}'} + puts @pstore.transaction {@pstore["Bug5311"]} + SRC + assert_equal(bug5311, @pstore.transaction {@pstore["Bug5311"]}, bug5311) + end end |