diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2021-08-04 09:27:04 -0700 |
---|---|---|
committer | Aaron Patterson <tenderlove@ruby-lang.org> | 2021-08-04 09:27:04 -0700 |
commit | 6a1c30634e61967f3d8133b3181b9f301ff7f550 (patch) | |
tree | ecf1ca8343e71e2c804c06222c3d68ce993257a5 /test | |
parent | 0be49786edf40b9956da0693d112f770588424e4 (diff) | |
download | psych-6a1c30634e61967f3d8133b3181b9f301ff7f550.tar.gz |
Add quotes to the strings "y" and "n"
'y' and 'n' are kind of ambiguous. Syck treated y and n literals in
YAML documents as strings. But this is not what the YAML 1.1 spec says.
YAML 1.1 says they should be treated as booleans. When we're dumping
documents, we know it's a string, so adding quotes will eliminate the
"ambiguity" in the emitted document
Fixes #443
Diffstat (limited to 'test')
-rw-r--r-- | test/psych/test_string.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index 20ab79c..0dc34b3 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -17,6 +17,19 @@ module Psych end end + # 'y' and 'n' are kind of ambiguous. Syck treated y and n literals in + # YAML documents as strings. But this is not what the YAML 1.1 spec says. + # YAML 1.1 says they should be treated as booleans. When we're dumping + # documents, we know it's a string, so adding quotes will eliminate the + # "ambiguity" in the emitted document + def test_y_is_quoted + assert_match(/"y"/, Psych.dump("y")) + end + + def test_n_is_quoted + assert_match(/"n"/, Psych.dump("n")) + end + def test_string_with_newline assert_equal "1\n2", Psych.load("--- ! '1\n\n 2'\n") end |