-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix empty keys in tests 2JQS and PW8X #40
Conversation
I can see why the yaml2json tests require specifying a schema, but I'm unhappy to require this at the yaml2event level as well, as that's a level that is supposed to be schema agnostic (as the schema application occurs at a higher layer). PS: Also, I'd like to see the testsuite be extended to test all 3 specified yaml schemas as that's one area where I currently have to write my own tests, as I implement all 3 schemas in HsYAML. |
I believe that the fixes proposed here are (or at least should be) equivalent for all schemas, as the comparison that we're talking about is whether a node with no explicit tag and an empty string value is equivalent to itself, i.e. |
Thanks. |
@eemeli I think the question is, where this check should be implemented. I currently think the parser should not care at all about this, even if two empty keys look perfectly equal. In the end, the mapping you are loading might not end up at all as a mapping/dictionary. A processor on top of the parser can do a lot of things with the parsing events additionally to just create a mapping data structure. Changing PW8X might still be a good idea, though. |
Just to verify what we're talking about, are we agreed that the Now, presuming that the
Regarding the first question, I don't really have an opinion. My JS Regarding the second question, I would have a hard time accepting that the test suite should include test input that is in error, but not have that test be marked as an error. Maybe it'd be better to just remove |
@eemeli Regarding question 1, that what I was trying to say, I believe that the parser should not be checking key equivalence, so the event stream can still stay in the test. Currently, the
The default would be valid. Hopefully that makes sense now =) |
I think I understand where you're coming from, but I'm not sure that separating parser/constructor/loader errors from each other is necessarily a good idea. The one-line description of the yaml-test-suite is that it's a "Comprehensive, language independent Test Suite for YAML", and to me that implies rather strongly that it should not concern itself with the implementation details of each parser or library. Quoting from section 3.1 of the 1.2 spec:
As I've understood it, the intent moving forward is to make this test suite rather than the written spec be the final authority. In that context, classifying errors as belonging to some specific stage seems... surprising. Of the current tests, So to keep the good bits, I'm going to update this PR by leaving out the second pair, which will evade the key-equality question, keep the empty-key behaviour that's nominally being tested, and allow the test to not be an error. Would that be acceptable? |
I also added |
I think we agree on most things, so currently I just fail to see the problem =) If a processor just does everything in one step, then it can't use the test-event file for testing. Look at it from the perspective of libyaml, for example. libyaml is just a parser and emitter. It can give you parsing events or a tree of nodes, where each node represents the parsed mapping, sequence or scalar, with its style and other attributes. It does not implement a schema. For libyaml, everything is just a string. It also doesn't know anything about the meaning of tags. A processor can always just skip certain tests, anyway. There will always be implementation specific things. Edit: libyaml is actually a bad example in this case, as it cannot parse empty keys anyway |
I agree that 2JQS should not be a general error case; I'd gotten stuck earlier on looking at its |
This fixes #25 by marking
2JQS
as an error due to the repeated null key, and adjustsPW8X
to avoid repeating null keys, allowing that test to test what it's supposed to test without error.Tests
E76Z
andX38W
are also mentioned in #25, but their alias node keys are not necessarily equal to their anchor nodes, and hence can be considered correct as is.