yaml / yaml-test-suite

Comprehensive, language independent Test Suite for YAML
MIT License
172 stars 58 forks source link

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

Open perlpunk opened 4 years ago

perlpunk commented 4 years ago

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

ingydotnet commented 4 years ago

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

am11 commented 4 years ago

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 commented 4 years ago

(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?

perlpunk commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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.