Crate greenwasm_spectest[][src]

A library shim around a mirror of the official webassembly MVP testsuite.

It can be used as a independent testsuite launcher for other webassembly implementations by implementing ScriptHandler.

Example:

use greenwasm_spectest::*;

struct DummyHandler;
impl ScriptHandler for DummyHandler {
   fn reset(&mut self) {}
   fn action_invoke(&mut self,
                    module: Option<String>,
                    field: String,
                    args: Vec<Value>) -> InvokationResult
   {
       unimplemented!()
   }
   fn action_get(&mut self,
                 module: Option<String>,
                 field: String) -> Value
   {
       unimplemented!()
   }
   fn module(&mut self, bytes: Vec<u8>, name: Option<String>) {
       unimplemented!()
   }
   fn assert_malformed(&mut self, bytes: Vec<u8>) {
       unimplemented!()
   }
   fn assert_invalid(&mut self, bytes: Vec<u8>) {
       unimplemented!()
   }
   fn assert_uninstantiable(&mut self, bytes: Vec<u8>) {
       unimplemented!()
   }
   fn assert_exhaustion(&mut self, action: Action) {
       unimplemented!()
   }
   fn register(&mut self, name: Option<String>, as_name: String) {
       unimplemented!()
   }
}

run_mvp_spectest(&mut DummyHandler).present();

This would result in a output like this:

Executing address.wast ...
Executing align.wast ...
Executing binary.wast ...
Executing block.wast ...
Executing br.wast ...
[...]

wast failures:
   address.wast:3, not yet implemented
   address.wast:104, <not attempted>
   address.wast:105, <not attempted>
   ...
wast total: 0 passed; 17955 failed

Re-exports

pub extern crate wabt;

Structs

NanCompare

Wrapper type that compares a list of wabt Values according to their bit-pattern if they contain floating point values, and according to regular PartialEq semantics otherwise.

SpectestResult

Result of running a series of script commands.

Enums

Action

Description of action that should be performed on a wasm module.

CommandKind

Script's command.

InvokationResult

Result of invoking a function.

Value

Wasm value

Constants

SPECTEST_MODULE

Module that is expected under the name "spectest" by all spectest testcases.

Traits

NanPayload

Extension trait for floating point values.

ScriptHandler

Handles the different script commands of the *.wast format.

Functions

run_all_in_directory

Run all scripts in a given directory on handler.

run_mvp_spectest

Run all scripts of the bundled webassembly testsuite on handler.

run_single_command

Run handler on a single wabt script command, catching any panic that might happen in the process.

run_single_command_no_catch

Run handler on a single wabt script command.

run_single_file

Run handler on the single .wast script file at path.