File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -272,7 +272,7 @@ def visit_String o
272272 tag = 'tag:yaml.org,2002:str'
273273 plain = false
274274 quote = false
275- elsif o == 'y' || o == 'n '
275+ elsif o == 'y' || o == 'Y' || o == 'n' || o == 'N '
276276 style = Nodes ::Scalar ::DOUBLE_QUOTED
277277 elsif @line_width && o . length > @line_width
278278 style = Nodes ::Scalar ::FOLDED
Original file line number Diff line number Diff line change @@ -24,10 +24,19 @@ def initialize
2424 # "ambiguity" in the emitted document
2525 def test_y_is_quoted
2626 assert_match ( /"y"/ , Psych . dump ( "y" ) )
27+ assert_match ( /"Y"/ , Psych . dump ( "Y" ) )
2728 end
2829
2930 def test_n_is_quoted
3031 assert_match ( /"n"/ , Psych . dump ( "n" ) )
32+ assert_match ( /"N"/ , Psych . dump ( "N" ) )
33+ end
34+
35+ def test_all_yaml_1_1_booleans_are_quoted
36+ yaml_1_1_booleans = %w[ y Y yes Yes YES n N no No NO true True TRUE false False FALSE on On ON off Off OFF ] # from https://yaml.org/type/bool.html
37+ yaml_1_1_booleans . each do |boolean |
38+ assert_match ( /"#{ boolean } "|'#{ boolean } '/ , Psych . dump ( boolean ) )
39+ end
3140 end
3241
3342 def test_string_with_newline
You can’t perform that action at this time.
0 commit comments