summaryrefslogtreecommitdiff
path: root/spec/ruby/library/yaml
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-01 15:41:50 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-01 15:41:50 +0000
commit4d7b0b9112f2adf9e87ef75056f930bf7c1f3dc4 (patch)
tree8d712e18a619a9720d181d0d44e8cc2474ff31ee /spec/ruby/library/yaml
parent821d9a2d30f2e0d3f9009dc001b4b49aaa63c66e (diff)
Update to ruby/spec@bacedc5
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/library/yaml')
-rw-r--r--spec/ruby/library/yaml/load_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/ruby/library/yaml/load_spec.rb b/spec/ruby/library/yaml/load_spec.rb
index 7c5a33d..6a2ab65 100644
--- a/spec/ruby/library/yaml/load_spec.rb
+++ b/spec/ruby/library/yaml/load_spec.rb
@@ -34,6 +34,27 @@ describe "YAML.load" do
end
end
+ it "loads strings with chars from non-base Unicode plane" do
+ # We add these strings as bytes and force the encoding for safety
+ # as bugs in parsing unicode characters can obscure bugs in this
+ # area.
+
+ yaml_and_strings = {
+ # "--- 🌵" => "🌵"
+ [45, 45, 45, 32, 240, 159, 140, 181] =>
+ [240, 159, 140, 181],
+ # "--- 🌵 and some text" => "🌵 and some text"
+ [45, 45, 45, 32, 240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116] =>
+ [240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116],
+ # "--- Some text 🌵 and some text" => "Some text 🌵 and some text"
+ [45, 45, 45, 32, 83, 111, 109, 101, 32, 116, 101, 120, 116, 32, 240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116] =>
+ [83, 111, 109, 101, 32, 116, 101, 120, 116, 32, 240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116]
+ }
+ yaml_and_strings.each do |yaml, str|
+ YAML.load(yaml.pack("C*").force_encoding("UTF-8")).should == str.pack("C*").force_encoding("UTF-8")
+ end
+ end
+
it "fails on invalid keys" do
if YAML.to_s == "Psych"
error = Psych::SyntaxError