summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSHIBATA Hiroshi <hsbt@ruby-lang.org>2017-06-30 07:58:15 +0900
committerGitHub <noreply@github.com>2017-06-30 07:58:15 +0900
commit4552cfc32939c57bfaacce9aea0416e3a1be908f (patch)
tree79e9c583aa8690a03a9bef8a50dcecc0684c91d2 /test
parent56d545e278577b3cfb3f71905a54f85cd2fba16c (diff)
parent0ca2d343735444d83a0dd733b52b2893c5084546 (diff)
downloadpsych-4552cfc32939c57bfaacce9aea0416e3a1be908f.tar.gz
Merge branch 'master' into frozen
Diffstat (limited to 'test')
-rw-r--r--test/psych/test_array.rb6
-rw-r--r--test/psych/test_scalar.rb5
-rw-r--r--test/psych/test_string.rb10
-rw-r--r--test/psych/visitors/test_yaml_tree.rb2
4 files changed, 17 insertions, 6 deletions
diff --git a/test/psych/test_array.rb b/test/psych/test_array.rb
index 11f5f23..f2bbdca 100644
--- a/test/psych/test_array.rb
+++ b/test/psych/test_array.rb
@@ -15,6 +15,12 @@ module Psych
@list = [{ :a => 'b' }, 'foo']
end
+ def test_enumerator
+ x = [1, 2, 3, 4]
+ y = Psych.load Psych.dump x.to_enum
+ assert_equal x, y
+ end
+
def test_another_subclass_with_attributes
y = Y.new.tap {|o| o.val = 1}
y << "foo" << "bar"
diff --git a/test/psych/test_scalar.rb b/test/psych/test_scalar.rb
index 4e45991..e2f9ec7 100644
--- a/test/psych/test_scalar.rb
+++ b/test/psych/test_scalar.rb
@@ -8,5 +8,10 @@ module Psych
def test_utf_8
assert_equal "日本語", Psych.load("--- 日本語")
end
+
+ def test_some_bytes # Ticket #278
+ x = "\xEF\xBF\xBD\x1F"
+ assert_cycle x
+ end
end
end
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb
index 7d14d16..973f38b 100644
--- a/test/psych/test_string.rb
+++ b/test/psych/test_string.rb
@@ -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)
@@ -220,9 +220,9 @@ string: &70121654388580 !ruby/string
end
def binary_string percentage = 0.31, length = 100
- string = ''.dup
+ string = ''.b
(percentage * length).to_i.times do |i|
- string << "\b"
+ string << "\x92".b
end
string << 'a' * (length - string.length)
string
diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb
index 503a3e4..01f1aec 100644
--- a/test/psych/visitors/test_yaml_tree.rb
+++ b/test/psych/visitors/test_yaml_tree.rb
@@ -37,7 +37,7 @@ module Psych
end
def test_binary_formatting
- gif = "GIF89a\f\x00\f\x00\x84\x00\x00\xFF\xFF\xF7\xF5\xF5\xEE\xE9\xE9\xE5fff\x00\x00\x00\xE7\xE7\xE7^^^\xF3\xF3\xED\x8E\x8E\x8E\xE0\xE0\xE0\x9F\x9F\x9F\x93\x93\x93\xA7\xA7\xA7\x9E\x9E\x9Eiiiccc\xA3\xA3\xA3\x84\x84\x84\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9!\xFE\x0EMade with GIMP\x00,\x00\x00\x00\x00\f\x00\f\x00\x00\x05, \x8E\x810\x9E\xE3@\x14\xE8i\x10\xC4\xD1\x8A\b\x1C\xCF\x80M$z\xEF\xFF0\x85p\xB8\xB01f\r\e\xCE\x01\xC3\x01\x1E\x10' \x82\n\x01\x00;"
+ gif = "GIF89a\f\x00\f\x00\x84\x00\x00\xFF\xFF\xF7\xF5\xF5\xEE\xE9\xE9\xE5fff\x00\x00\x00\xE7\xE7\xE7^^^\xF3\xF3\xED\x8E\x8E\x8E\xE0\xE0\xE0\x9F\x9F\x9F\x93\x93\x93\xA7\xA7\xA7\x9E\x9E\x9Eiiiccc\xA3\xA3\xA3\x84\x84\x84\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9\xFF\xFE\xF9!\xFE\x0EMade with GIMP\x00,\x00\x00\x00\x00\f\x00\f\x00\x00\x05, \x8E\x810\x9E\xE3@\x14\xE8i\x10\xC4\xD1\x8A\b\x1C\xCF\x80M$z\xEF\xFF0\x85p\xB8\xB01f\r\e\xCE\x01\xC3\x01\x1E\x10' \x82\n\x01\x00;".b
@v << gif
scalar = @v.tree.children.first.children.first
assert_equal Psych::Nodes::Scalar::LITERAL, scalar.style