WebAssembly / WebAssembly/spec
Feature request: test-local variables in .wast
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 3.5k
- Forks
- 539
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 13
Description
In a CG call a few weeks back, I mentioned that having the ability to have test-local variables in .wast files would be useful.
In particular, many tests that use reference types, mostly in proposals right now (such as function-references and gc use tables internal to a module and an initializer. These tests would be shorter, easier to write, and easier to debug (a key productivity boost for engine implementers) if the test itself could bind variables.
Exact details of syntax and semantics TBD.
Sketch:
(module
(func "create_ref1" (result anyref))
...
(func "take_ref" (param anyref) (result i32))
)
(test-local $ref1 anyref (invoke "create_ref1"))
(assert_return (invoke "take_ref" (test-local.get $ref1)) (i32.const 11))
That would remove the need for tables, but the issue of needing to create objects/functions inside a module (because types and decls live in modules) remains.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing .wast test syntax in the reference interpreter and test suite, then compare how reference types, tables, and module initializers are represented. Define the test-local variable syntax and semantics, including how values are created and retrieved; done means the design is specified and covered by representative tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100