-
Notifications
You must be signed in to change notification settings - Fork 493
Add tests for if/then/else with indices + unknown label; #284
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
Conversation
|
The current behaviour is correct: the body of each if-branch is (implicitly) a block, and the labels name these respective blocks. Not sure why you expect a label to be in scope in a sibling block? It's no different from which likewise is an error. The other test look good. |
|
@rossberg-chromium I think it's not meant to be in scope, it should be an error - it's an assert_invalid test. |
|
Oh, sorry, totally missed that. Yeah, that's definitely a bug, I'll look into it. |
|
Okay, I now see what's going on. The problem is that labels (and identifiers in general) are resolved in the parser, because the AST doesn't have them. An unbound name hence is a syntax error, rejecting the script before you ever get to run it. So it's not really a bug but a limitation of scripts -- a script can't check for this kind of error, just like it can't check other syntax errors. You'll need to check externally against expected-output instead. |
|
@rossberg-chromium I actually ran an issue in sexpr-wasm because of this; prior to having binary modules, I could assume that |
Thank you for the explanation, I can do this, however I wonder how https://github.com/WebAssembly/spec/blob/master/ml-proto/test/switch.wast#L155 doesn't trigger the exact same issue? |
|
@bnjbvr, that test uses a raw numeric index. What's resolved in the parser is the use of symbolic labels, and their translation into numeric ones (because they are purely syntactic sugar, not a part of the Wasm AST). I certainly won't argue that this difference is nice. :) |
|
I've updated the PR. The code wasn't accepting non-zero exit codes, so I had to refactor this, by adding a way to specify that a test is expected to fail. Also, there were issues with redirecting stderr to stdout with a |
a0c3403 to
080aa4e
Compare
ml-proto/runtests.py
Outdated
|
|
||
| if headers[0] == ';;;': | ||
| for h in headers[1:]: | ||
| if h.strip() == 'expected-fail': |
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.
Instead of instrumenting comments in the file, what do you think about simply using a file name convention? Say, <test>.fail.wast for tests that ought to fail? That's easier and cheaper to process (including for other test harnesses).
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.
Yeah, good idea.
|
Thanks! Looks good modulo a few comments. |
080aa4e to
e5e2123
Compare
|
Updated the latest patch, thank you for the review! |
ml-proto/runtests.py
Outdated
|
|
||
| def _runTestFile(self, shortName, fileName, interpreterPath): | ||
|
|
||
| expectedExitCode = 1 if "fail" in fileName else 0 |
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.
Can we make this a bit narrower? ".fail." should be good.
e5e2123 to
561169f
Compare
|
Hm, Travis still barfs at the .fail test, although I can't immediately say why. |
ml-proto/runtests.py
Outdated
| self.assertEqual(expectedExitCode, exitCode, "test runner failed with exit code %i, expected %i" % (exitCode, expectedExitCode)) | ||
|
|
||
| if logPath is not None: | ||
| out.close() |
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.
One further style nit I just noted: inconsistent indentation, rest of the file uses 2
…ects output to the right places in all cases;
561169f to
9223278
Compare
|
Right, the test was failing because we are now very tied to line numbers, which is unfortunate. Addressed the two styles nits and updated the expected output to match line numbers. |
|
Cool, thanks! LGTM and landing. |
* Reintroduce exnref * Fix type_of * Simplify parser * Implement 1b * Change opcodes for catch/catch_all to avoid conflict * Put catch clauses first * Remove obsolete Delegating cases * Change exn type opcode to -0x17 * Switch to B' variant * [interpreter] Add boilerplate for ref.exn result patterns * [ci] Deactivate node run, since it can't handle try_table yet * Try -> TryTable in AST * [spec] Update spec for option B' (#283) * Deactivate Bikeshed * [spec/tests] Specification of legacy exceptions + tests (#284) * [legacy] Create specification doc for legacy exception handling * [test] Create infra for legacy tests
Hi! I'd like to add test cases we ran into in our implementation and which could be useful for others:
brin theelseis the label of thethenblock.Unfortunately, the second test (at the end of the file) doesn't work: the parser complains that the label
$lis unknown, which is exactly what we are testing here. The correct behavior would be to silently swallow the error and consider the test as passed. Am I missing something here?