-
Notifications
You must be signed in to change notification settings - Fork 454
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
Implement a basic macro-assembler for test cases. #155
Conversation
Awesome! Would it make sense to add a "replace"-macro, which replaces @ (or smth. else) with a list of strings? like this:
Gets translated to
|
Perhaps we could call it a "for each" macro or something. In any case, that kind of thing is certainly possible. |
Ok, I've written the basic implementation for this and will clean up the code (perhaps) tomorrow. When that's done, shall I make a PR for the branch? (I'm asking, because this would be a PR for a PR and therefore some kind of PR-ception, don't know, if this is intended use of PRs) |
I noticed a bug: If I rewrite a line in fac.mast from
to
It seems to add an "invisible" operand, which messes up the amount and position of operands, and the "while"-instruction doesn't get translated anymore. EDIT: It's because Windows uses carriage return, disabled that in my notepad++ |
Friendly ping. |
def isalnum(c): | ||
return isdigit(c) or (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z') | ||
|
||
def skip_whitespace_and_comments(s, i): |
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.
This is the only function, in which you are checking if the index exceeds the length of the string. MASM still raises an IndexError, if the index is out-of-bounds in the other functions, but it could be hard to debug mast-files.
We want to make it as easy as possible to write conformance tests, because a strong testsuite is one of the main tools we have for ensuring that implementations behave consistently. A builtin macro-assembler layer might make it significantly easier to write some kinds of tests. I'm not super attached to the actual code right now; it's pretty primitive right now. I'm mainly looking for feedback on the idea. |
I'm rather impartial to this, but I fear it might blur the boundary of what is spec'ed for people trying to learn about the details of the language by looking at the examples from tests. Also, do we actually expect to manually write large tests in the future, instead of generating them? Should we discuss at the meeting? |
Closing for now, since it's not presently a high priority. This idea, with or without the code here, can be brought back if there is need of it. |
This has already been updated in the upstream spec, but also needs to be fixed in proposals.
This PR covers tests for some float literal introduced in WebAssembly#1069, specific for following ops: Bit shifts Bitwise operations Boolean horizontal reductions Conversions Integer comparisons Store These tests are pulled from WAVM/WAVM#236
While WebAssembly's current AST has some high-level constructs like
if
, it doesn't have other obvious high-level control constructs such aswhile
andfor
, making it difficult for humans to code by hand.To address this concern, this PR introduces the start of a macro-assembler facility which allows tests to be written using high-level control constructs. So far, only
while
is implemented, but the basic idea is demonstrated: there is a fac.mast testcase which implements the common fibonacci function using awhile
loop, and the runtest.py script automatically runs the macro-assembler and generates a fac.generated.wast file, and then runs the test.The macro-assembler preserves whitespace and comments in non-transformed parts of the code, so the output is fairly readable. With a modest amount of additional effort, it could be made to format the transformed parts in a pretty way as well.