Comments (6)
Yes, that's really an edge-case.
We came to the conclusion that a mapping starting on the ---
line is actually allowed, that's why CXX2 is valid:
--- &anchor a: b
The question, though, is, what's the correct indendation for the following lines?
As far as I know that's hard (or impossible?) to tell from the spec.
There are three possibilities:
--- a: 1
b: 2
--- a: 1
b: 2
--- a: 1
b: 2
One could argue that the document-start has a "logical" indendation of -1, so the mapping would have an indendation of 0, so the first example seems valid.
While the third example looks nicer, because the indendation matches.
Our opinion is that, because of this, a parser doesn't have to allow (or even should not allow) these kind of mappings (or sequences), but we still included the test case with one line because that's clearly valid from the spec. We also would like to forbid it completely for YAML 1.3.
Some existing parsers don't allow it (like libyaml), some allow the first example (libsyck), some allow the third (js-yaml).
I agree that these kind of test cases should have explanations.
@flyx, @ingydotnet any more thoughts?
from yaml-test-suite.
Definitely disallowed in YAML 1.3. The 1.2 Spec is a bloody mess when it comes to directive end markers. For example, this is a valid document according to the productions:
---- a
- b
And it is equivalent to
- a
- b
However, I don't think any implementation supports that and I don't think this was intended. I would advice to agree that these edge cases are not properly covered by the spec and therefore we should drop both test cases, assuming that what is supported and what isn't is implementation-defined. This conforms to the current situation.
from yaml-test-suite.
Actually, the spec does imply that the indentation should be
--- a: 1
b: 2
That's based on Example 9.5, which contains this bit:
--- |
%!PS-Adobe-2.0
which is considered equivalent to:
---
!!str "%!PS-Adobe-2.0\n"
That would only be valid if ---[ \t]*
would not be considered when determining the indentation, and if it's true for block scalars, it ought to be true for block collections.
Regarding dropping the tests, I agree that at least 9KBC could be dropped due to being considered implementation-specific behaviour, but I think CXX2 is actually fine as it is; by keeping the contents to a single line, the uncertainty about the indentation can be ignored.
from yaml-test-suite.
@eemeli yeah:
"Document nodes are indented as if they have a parent indented at -1 spaces. Since a node must be more indented than its parent node, this allows the document’s node to be indented at zero or more spaces."
http://yaml.org/spec/1.2/spec.html#id2800967 9.1.3. Bare Documents
from yaml-test-suite.
Here's the meta take on this:
- The 1.2 spec has many flaws, inconsistencies and unintended consequences
- It is too late to change the 1.2 spec.
- We are working on the yaml-test-suite to be the source of truth (SoT) for all YAML and YAML spec versions.
- This means the spec for 1.2 is not the ultimate SoT. It is a guide to make hard decisions which will become represented clearly in the test suite.
- The same test can be tagged in different ways.
- The test suite is a work in progress and still quite young.
- We are simultaneously in the process of creating YAML 1.3 (which is mostly removing the inconsistencies in 1.2).
Regardless of how, the spec is interpreted, 9KBC and CXX2 were not meant to be valid in 1.2. They are failures in the spec. The correct thing to do here is to tag them as being such.
We have been thinking about tags for these situations. Ideas are: 1.2-unknown
, 1.2-bad-spec
, 1.2-pedantic
.
from yaml-test-suite.
This was fixed by a2f4449.
from yaml-test-suite.
Related Issues (20)
- Individual tags per subtest don't work
- 8G76: an empty file is not a valid JSON document HOT 7
- Should L24T/01/in.yaml and JEF9/02/in.yaml end with \n? HOT 2
- is there some logic to the naming of tests? HOT 2
- Explain Token stream notation, Event stream notation HOT 1
- Create a use case for trailing TAB
- norway problem HOT 1
- Is there an error in 4H7K HOT 1
- Why is `a: :a` valid while `a: a:` is not?
- Fix generated test in Y79Y
- Scala-yaml uses this test suite HOT 1
- json for 4ABK HOT 1
- Symmetry in spec urls HOT 1
- Broken TestML link in the Usage section
- Convert all numeric mapping keys to strings HOT 3
- test/tags/directive/NTY5.tml is broken HOT 2
- Test to cover "Value after document-start" (on first line)
- Licensing HOT 1
- Add test for e.g. `[[], :@]` HOT 1
- Address #40 and #54
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yaml-test-suite.