-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Tests: Let runTestCase() pretty-print expected TokenStream too #2056
Tests: Let runTestCase() pretty-print expected TokenStream too #2056
Conversation
Could you please explain why you did this? I don't see the benefit. You can see the (usually) formatted token stream in the test file itself. And the calculated difference between two formatted token streams and two non-formatted token streams should be the same (apart from some whitespaces). Also, a potential problem I see is that the mocha output will be longer which is a bit of a problem because consoles usually only store a fixed number of lines. The output of some more complex test cases can easily exceed 1000 lines because of the (current) diff. (For reference: The number of stored lines in VS Code's terminal is 1000 by default.) |
Well, it already formatted the actual token stream. Having it display the actual data pretty-printed but not the expected data seems inconsistent. If you want the terse representation then you can just leave out the Based on your argument that you can see the formatted token stream in the test file itself, it shouldn't display the expected data at all, but just the actual data. Not sure about the usefulness of the diff, it's really just the actual data from the first difference on - if there's an extra character in the very first line of a test then you get the full actual data twice. And mocha actually does a better job at showing a mismatch: |
True, but do need to have the expected token stream formatted?
Well, yes kinda. I don't think we gain anything from displaying the expected token stream. After all, you can see it in the test file, so you know exactly what's expected.
(I never gave any thought to our diff...) You're exactly right. Mocha does a way better job. We should just remove our diff. I spent If I had to guess, @Golmote didn't notice this change before merging (@Golmote wouldn't have accepted code indented this badly) and it just stuck around. Knowing this: What more than the actual token stream and a small diff from mocha do we really need? |
To be honest, I would scratch the diff and the expected output and just print the actual token stream. This could even be behind another flag, as mocha tells you pretty much everything you need to know. But I guess it doesn't hurt as long as it is printed above what mocha outputs. Not sure if there is anything else needed. The position of the first difference / error? But that's tricky, because the raw as well as the reformatted token streams differ from the test file, so there's no straightforward way to compute that for the file. What could be helpful though is the location of the test in question, which mocha doesn't tell you. I committed these changes, let me know what you think: (without --pretty) |
I really like the simplified format. I added a bit code to also have the line and column number of the first difference at the end of the file path. Most IDEs understand this format, so you can jump directly into the test case at the position of the difference. Please tell me what you think! |
I tried it with different white-space in the test file and it seems to point reliably at or behind the position of the deviation. Looks very good to me! |
I dig it. |
Only the actual token stream was pretty-printed. This makes the helper function pretty-print the expected token stream as well (and the diff too). Also added some
\n
to separate it from the mocha output.