yaml-test-suite icon indicating copy to clipboard operation
yaml-test-suite copied to clipboard

Add a test for `{a: b?}`

Open perlpunk opened this issue 5 years ago • 6 comments

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

perlpunk avatar Feb 21 '20 18:02 perlpunk

Related is {?a: b}. libyaml likes it and ref parser does not

ingydotnet avatar Feb 21 '20 20:02 ingydotnet

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

am11 avatar Feb 22 '20 14:02 am11

(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 avatar Mar 14 '20 02:03 am11

@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

perlpunk avatar Mar 20 '20 13:03 perlpunk

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.

perlpunk avatar May 24 '20 12:05 perlpunk

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.

perlpunk avatar May 24 '20 12:05 perlpunk