-
-
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
Ambiguity in numeric literal formatting in test cases #252
Comments
I believe these instructions are for how to run things against the test suite, because of the specific output the test suite expects. You can represent things and even present them in your own API however you want. But your test-specific printer has to represent things in this way for the test suite to work. Does that make sense? Likewise, there's a ton of flexibility in how your parser handles numbers. You can keep hex numbers as hex numbers (for example, if you're writing a parser that's meant to edit kdl files programmatically), etc. |
Thanks for the quick response! That does make sense, but I am not sure if it answers my question... for
and the expected output is
However, for
and the expected output is
Now, my parser can parse both inputs fine, but they effectively result in identical internal values. So when they print, they both come out as |
Yes, we could use a little more detail in precisely how the test suite expects numeric output to work; I had to do some slightly non-trivial stuff to hold onto enough information to output in the test's expected output, and put that output form behind a flag so the default is a little simpler. It looks like I'm passing those two tests in particular by accident, just because I'm relying on Python's native number parsing and printing, and it distinguishes ints from floats and prints them differently. I'm wondering if we should canonicalize those in the test suite to one form or the other? |
In particular, right now the test suite expects:
Aside from the fact that |
Thanks @tabatkins those expectations and your explanation of your approach are very helpful! I would like to avoid tightly coupling the behavior of my pretty-printer to the specific formatting observed by my parser, and would rather control the output of my pretty-printer explicitly by configuration. It sounds like there isn't any specific reason not to do so, as long as the parser can parse the input files and is capable of representing them in the way shown in the expected output. |
FWIW, in ckdl I don't keep track of significant digits, or of whether scientific notation was used, but, for the purposes of running the test suite, configured float output to:
This covers all tests except |
Howdy!
I am working on a Perl implementation of a KDL parser (which I would love to submit for the official 1.0 compliant list once it is closer to completion). One issue I am running into right now is, I am not clear on how to correctly and consistently handle numeric literals such that they comply with the expected output of the test cases. The only note provided regarding numeric formatting in
tests/README.md
is:So for example, why does:
Result in:
instead of:
? What is the definition of simplest decimal representation? If a parser is under no obligation to represent a number in any particular way, what is intrinsic to the value derived from
1e10
that means it should be represented with E notation instead of as a simple decimal integer?Thanks!
The text was updated successfully, but these errors were encountered: