Improved tests to use available compilers

This commit is contained in:
Syrus
2020-04-16 11:52:11 -07:00
parent 5f5928dfbd
commit b301ac85be
14 changed files with 428 additions and 467 deletions

View File

@@ -351,6 +351,10 @@ pub mod error {
/// Idea for generic trait; consider rename; it will need to be moved somewhere else
pub trait CompiledModule {
fn new(bytes: impl AsRef<[u8]>) -> error::CompileResult<Module>;
fn new_with_compiler(
bytes: impl AsRef<[u8]>,
compiler: Box<dyn compiler::Compiler>,
) -> error::CompileResult<Module>;
fn from_binary(bytes: impl AsRef<[u8]>) -> error::CompileResult<Module>;
fn from_binary_unchecked(bytes: impl AsRef<[u8]>) -> error::CompileResult<Module>;
fn from_file(file: impl AsRef<std::path::Path>) -> Result<Module, error::CompileFromFileError>;
@@ -365,6 +369,14 @@ impl CompiledModule for Module {
wasmer_runtime_core::compile_with(bytes, &compiler::default_compiler())
}
fn new_with_compiler(
bytes: impl AsRef<[u8]>,
compiler: Box<dyn compiler::Compiler>,
) -> error::CompileResult<Module> {
let bytes = bytes.as_ref();
wasmer_runtime_core::compile_with(bytes, &*compiler)
}
fn from_binary(bytes: impl AsRef<[u8]>) -> error::CompileResult<Module> {
let bytes = bytes.as_ref();
wasmer_runtime_core::compile_with(bytes, &compiler::default_compiler())