diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-14 06:15:58 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-14 06:15:58 +0000 |
commit | 296f537bf48664461d9c80493357290ce726dbe8 (patch) | |
tree | 9164cd8f79f9e9b317dad2b399778e47b410cae1 /test/psych/test_string.rb | |
parent | 33ea7a9807a533fe9e29f4cd81a0dfd7da36c5c3 (diff) | |
download | ruby-296f537bf48664461d9c80493357290ce726dbe8.tar.gz |
Merge psych-3.0.0.beta3 from ruby/psych.
* Rely on encoding tags to determine if string should be dumped as binary.
https://github.com/ruby/psych/commit/8949a47b8cee31e03e21608406ba116adcf74054
* Specify "frozen_string_literal: true".
* Support to binary release for mingw32 platform.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych/test_string.rb')
-rw-r--r-- | test/psych/test_string.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index 4aa6016a59..973f38b9c2 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -# frozen_string_literal: false +# frozen_string_literal: true require_relative 'helper' module Psych @@ -166,7 +166,7 @@ string: &70121654388580 !ruby/string end def test_nonascii_string_as_binary - string = "hello \x80 world!" + string = "hello \x80 world!".dup string.force_encoding 'ascii-8bit' yml = Psych.dump string assert_match(/binary/, yml) @@ -174,7 +174,7 @@ string: &70121654388580 !ruby/string end def test_binary_string_null - string = "\x00" + string = "\x00\x92".b yml = Psych.dump string assert_match(/binary/, yml) assert_equal string, Psych.load(yml) @@ -187,8 +187,8 @@ string: &70121654388580 !ruby/string assert_equal string, Psych.load(yml) end - def test_non_binary_string - string = binary_string(0.29) + def test_ascii_only_binary_string + string = "non bnry string".b yml = Psych.dump string refute_match(/binary/, yml) assert_equal string, Psych.load(yml) @@ -202,7 +202,7 @@ string: &70121654388580 !ruby/string end def test_string_with_ivars - food = "is delicious" + food = "is delicious".dup ivar = "on rock and roll" food.instance_variable_set(:@we_built_this_city, ivar) @@ -220,9 +220,9 @@ string: &70121654388580 !ruby/string end def binary_string percentage = 0.31, length = 100 - string = '' + string = ''.b (percentage * length).to_i.times do |i| - string << "\b" + string << "\x92".b end string << 'a' * (length - string.length) string |