-
Notifications
You must be signed in to change notification settings - Fork 475
[interpreter] Support nested invoke/get in test scripts #1590
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
87d3a37
cbab7f7
97a9473
4a7b1a1
0014906
23637b7
72944ae
fe26ca1
04095ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
) | ||
|
||
(module $m2 | ||
(global (export "g") i32 (i32.const 42)) | ||
(global (export "g") (mut i32) (i32.const 42)) | ||
(func (export "f") (result i32) (i32.const 42)) | ||
(func (export "add3") (param i32 i32 i32) (result i32) | ||
(i32.add (i32.add (local.get 0) (local.get 1)) (local.get 2)) | ||
|
@@ -21,17 +21,25 @@ | |
(assert_return (get $m1 "g") (i32.const 41)) | ||
(assert_return (get $m2 "g") (i32.const 42)) | ||
|
||
(set "g" (i32.const 43)) | ||
(assert_return (set "g" (i32.const 43))) | ||
(assert_return (get "g") (i32.const 43)) | ||
(set $m2 "g" (i32.const 44)) | ||
(assert_return (get "g") (i32.const 44)) | ||
(set "g" (invoke $m1 "inc" (get "g"))) | ||
(assert_return (get "g") (i32.const 45)) | ||
|
||
(assert_return (invoke "f") (i32.const 42)) | ||
(assert_return (invoke $m1 "f") (i32.const 41)) | ||
(assert_return (invoke $m2 "f") (i32.const 42)) | ||
|
||
(assert_return (invoke $m1 "inc" (i32.const 2)) (i32.const 3)) | ||
(assert_return (invoke $m1 "inc" (get $m1 "g")) (i32.const 42)) | ||
(assert_return (invoke $m1 "inc" (get $m2 "g")) (i32.const 43)) | ||
(assert_return (invoke $m1 "inc" (invoke $m1 "inc" (get "g"))) (i32.const 44)) | ||
(assert_return (invoke $m1 "inc" (get $m2 "g")) (i32.const 46)) | ||
(assert_return (invoke $m1 "inc" (invoke $m1 "inc" (get "g"))) (i32.const 47)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if intentionally limiting the grammar to not allow nested invokes (or even There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I have often missed the ability to simply plug two function calls together for an assertion. Not being able to do that on script level requires contortions exactly like those from not being able to access a global. So it would be a pity to exclude it. It's just a trivial recursive expression evaluator after all, the changes to runners ought to be minimal (see run.ml). The real complexity with this extension is in translating tests to JS. But that all has to do with the fact that synthesised Wasm modules for assertions now require an arbitrary number of imports, which isn't changed by limiting expression depth. (Also, I ran into a couple of V8/node bugs, such as #1597, and worse, deterministic bus errors on my new Arm MacBook. :( ) |
||
|
||
(assert_return (invoke "add3" (get $m1 "g") (invoke $m1 "inc" (get "g")) (get "g")) (i32.const 126)) | ||
(assert_return (invoke "add3" (invoke "swap" (get $m1 "g") (invoke $m1 "inc" (get "g"))) (i32.const -20)) (i32.const 64)) | ||
(assert_return (invoke "add3" (get $m1 "g") (invoke $m1 "inc" (get "g")) (get "g")) (i32.const 132)) | ||
(assert_return (invoke "add3" (invoke "swap" (get $m1 "g") (invoke $m1 "inc" (get "g"))) (i32.const -20)) (i32.const 67)) | ||
|
||
|
||
(module | ||
|
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.
So
set
is not like atee
, it returns empty?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.
Right, it's like global.set.