-
Notifications
You must be signed in to change notification settings - Fork 2k
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 stripIgnoredCharacters utility function #1802
Add stripIgnoredCharacters utility function #1802
Conversation
} | ||
} | ||
|
||
expectStripped(ignoredTokens.join('')).toEqual(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote tests as a combination of handwritten test that covers algorithm and all branches and fuzzing tests that test all possible combinations of tokens.
Fuzzing tests helped to uncover a few edge cases that I fixed and include in handwritten tests but I think fuzzing tests are still useful in case if we change the code or extend GraphQL language grammar.
// Testing with length >5 is taking exponentially more time however it | ||
// highly recommended to test with increased limit if you make any change | ||
const maxCombinationLenght = 5; | ||
const possibleChars = ['\n', ' ', '"', 'a', '\\']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test helped me to uncovered that
"""
a
a
"""
can't be converted into:
"""a
a"""
Since you will change string value from a\n a
into a\na
.
That's why I think it's important to keep it even if can't run it with length >5
by default.
@rybon Sorry for the delay, it took me significantly more time than I expected. @Cito @martijnwalraven @mjmahone If you have time, can you please review this PR? |
@IvanGoncharov yes, I will review it now. Thanks again! |
7c07691
to
a9862a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
18c66cc
to
15441c9
Compare
Heavily based on work done by @rybon in graphql#1628. Solves graphql#1523.
15441c9
to
328b065
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like an elegant solution to me: use the lexer to condense the tokens, and then just print the tokens, rather than going through the lex => parse => print indirection.
Merge? |
@rybon Merged 🎉 |
@IvanGoncharov could you do a release to NPM? |
@rybon Just returned from GraphQL Asia. |
@rybon Sorry for the delay. |
Heavily based on work done by @rybon in #1628.
Fixes #1523.