yaml-test-suite
yaml-test-suite copied to clipboard
Add a test for `{a: b?}`
According to HsYAML and the reference parser it is valid. ruamel.yaml, NiMYAML, JS js-yaml, JS yaml, and YAML::PP parse it libyaml, yaml-cpp, pyyaml, ruby psych don't
Related is {?a: b}
. libyaml likes it and ref parser does not
YamlDotNet does not like it either:
{a:b?}
+STR
+DOC
+MAP
=VAL :a
YamlDotNet.Core.SemanticErrorException: (Line: 1, Col: 6, Idx: 5) - (Line: 1, Col: 7, Idx: 6): While parsing a flow mapping, did not find expected ',' or '}'.
However, {?a:b}
is fine:
+STR
+DOC
+MAP
=VAL :a
=VAL :b
-MAP
-DOC
-STR
(sorry for an off-topic question) what is the algorithm which generates the test codes (e..g 33X3
)? Is there some encoding scheme for it or just (an unreserved) random string?
@am11 the bin/new
script can be used to create a new test.
cat /dev/urandom | LC_ALL=C tr -cd A-HJ-NP-Z2-9 | fold -w4 | grep [A-Z] | grep [0-9] | head -n1
In https://github.com/yaml/yaml-test-suite/commit/a107e87a36dc5e6b40e934ae286a6724f933aadf I added https://github.com/yaml/yaml-test-suite/blob/master/test/JR7V.tml with several question-mark related tests.
I think for {?a: b}
there should be an extra issue. I would like to know why the reference parser and HsYAML think it's invalid, but I can't find in the spec why this should be invalid.