Skip to content

Testing #15

Open
Open
@kripken

Description

@kripken

Still early here, but might be nice to add testing at some point.

One option is to check output .wast files for identity.

Another is to also execute them, for example, testing that fibonacci(5) has the right output. This is actually not that hard, we need to

  1. Add imports for testing prints, (import $print_i32 "spectest" "print" (param i32)) for printing an i32, for example. The spectest module is a special module that is supported in wasm test runners (it won't be supported on the web, but could be polyfilled).
  2. Call the import using call_import to print values.
  3. Add a start method (BinaryenSetStart), a void(void) function that is called when the module is loaded.
  4. Execute that webassembly using the binaryen shell, which should already be present since we build binaryen. Something like binaryen-shell test.wast will load the module and run the start method.
  5. Verify the output is as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions