Skip to content
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

Add test cases for whitespace #16

Closed
wants to merge 2 commits into from
Closed

Add test cases for whitespace #16

wants to merge 2 commits into from

Conversation

SamMousa
Copy link

This test will catch implementation bugs related to whitespace.
jmespath/jmespath.js#58

This test will catch implementation bugs related to whitespace.
jmespath/jmespath.js#58
tests/basic.json Outdated
{
"expression": "foo\t.\tbar\t.\tbaz",
"result": "correct"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you talking about the code or the test case?
Do you want the test expression to have a trailing \t?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, in the actual json document. ;)

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have said: "Please can you remove the trailing space characters on this line". Sorry!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one time I don't use my own IDE, 20% of LOC contain errors =D

tests/basic.json Outdated
{
"expression": "foo\r.\rbar\r.\rbaz",
"result": "correct"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

tests/basic.json Outdated
{
"expression": "foo\r\n.\r\nbar\r\n.\r\nbaz",
"result": "correct"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Contributor

@GrahamCampbell GrahamCampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. My comments seem to have not hidden themselves, but they are no longer valid.

@jamesls
Copy link
Member

jamesls commented May 31, 2022

I know this is super, super late for feedback, but I won't be able to take this change. While most of the implementations ignore some degree of whitespace at the lexing stage, the grammar for jmespath uses ABNF which is strict about requiring whitespace to be explicitly modeled. From Section 3.1 of RFC 4234:

NOTE:

This specification for ABNF does not provide for implicit
specification of linear white space.

Any grammar that wishes to permit linear white space around
delimiters or string segments must specify it explicitly. It is
often useful to provide for such white space in "core" rules that are
then used variously among higher-level rules. The "core" rules might
be formed into a lexical analyzer or simply be part of the main
ruleset.

If we're going to support whitespace around expressions we would need to update the spec/grammar first, and I'm not sure at this point it's something we'd want to do (though I'm open to a discussion about it).

@jamesls jamesls closed this May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants