-
Notifications
You must be signed in to change notification settings - Fork 440
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
stdlib should have a parseInt function #212
Comments
This is useful, please submit a PR! |
In fact if you do it today it'll get in the release I'm planning to do tomorrow. |
Would the following be simpler?
|
Igor has a good point |
Thanks for the suggestion. I'll make this change in the PR. As a quick aside is there an easy way to regenerate the golden validation without looking through ./run_tests.sh |
The easiest way I know is, from test_suite:
which can take a list of files |
Well, don't do it on a test that does not have a golden file, like stdlib.jsonnet :) It might be worth writing a script to refresh all of them at once (even if only some of them need it). However I suppose this would make people sloppy and not actually checking that the changes are valid. |
Note that neither your variant nor mine handles negative numbers or numbers with leading whitespace... |
I have negative numbers in the pr. I didn't consider leading whitespace though. Is the whitespace fix necessary though? For example it looks like in Java any extra whitespace throws NumberFormatException. |
I think it's fine as it is the PR. We can always add a trim() or whatever. In future, we might want to parse floating point, or even arbitrary JSON as well. |
* Refactor handling of --{ext,tla}-* flags * better helper function names for --{ext,tla}-* flags
It'd be nice to have something where I can do
stdlib.parseInt("16") == 16
I wrote this function myself here but would like to contribute it upstream.
The text was updated successfully, but these errors were encountered: