🐛 Less strict number string coercion, to match RFCs#680
Merged
Conversation
I was resisting the temptation to go all meta-programming with these tests. But they got too big, and I want to add different types of examples that would require too many changes.
Extract `#test_method_invocation`, which simplifies all tests to either `method(input) => result` or `method(input) raises Exception`.
The formal syntax in the RFCs would appear to allow any of zero-able numbers to be zero-padded: i.e, not only `"0" => 0`, but also `"000" => 0` and `"012" => 12`! [RFC9051](https://www.rfc-editor.org/rfc/rfc9051#name-formal-syntax): ```abnf number = 1*DIGIT number64 = 1*DIGIT nz-number = digit-nz *DIGIT nz-number64 = digit-nz *DIGIT ``` [RFC7162](https://www.rfc-editor.org/rfc/rfc7162.html#section-7): ```abnf mod-sequence-value = 1*DIGIT mod-sequence-valzer = "0" / mod-sequence-value ``` I dont' like this. I'd prefer that the specs for `number`, `number64`, and `mod-sequence-value` were stricter, like my original regexps: ```abnf number = "0" / nz-number number64 = "0" / nz-number64 nz-number = digit-nz *DIGIT nz-number64 = digit-nz *DIGIT mod-sequence-value = number64 mod-sequence-valzer = nz-number64 ``` ... but they're not! A future release may add an upper limit to how many prefix zeros can be added, to prohibit goofy numbers like `"0000000000000000000000000001"`.
700d43c to
1810d39
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Convert most
NumValidator#coerce_{type}methods to a simpler/\A\d+\z/regexp.The formal syntax in the RFCs would appear to allow any of zero-able numbers to be zero-padded: i.e, not only
"0" => 0, but also"000" => 0and"012" => 12!RFC9051:
RFC7162:
I dont' like this. I'd prefer that the specs for
number,number64, andmod-sequence-valuewere stricter, like my original regexps:... but they're not!
A future release may add an upper limit to how many prefix zeros can be added, to prohibit goofy numbers like
"0000000000000000000000000001". But that's a lot more important for the regexps used byResponseReaderandResponseParserthan it is for the regexps used byNumValidator.