mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-24 06:01:33 +00:00
Fixed formatting
This commit is contained in:
@ -9,8 +9,7 @@ mod tests {
|
|||||||
fn should_detect_emscripten_files() {
|
fn should_detect_emscripten_files() {
|
||||||
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_true.wast");
|
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_true.wast");
|
||||||
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
|
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
|
||||||
let module =
|
let module = compile(&wasm_binary[..]).expect("WASM can't be compiled");
|
||||||
compile(&wasm_binary[..]).expect("WASM can't be compiled");
|
|
||||||
let module = Arc::new(module);
|
let module = Arc::new(module);
|
||||||
assert!(is_emscripten_module(&module));
|
assert!(is_emscripten_module(&module));
|
||||||
}
|
}
|
||||||
@ -19,8 +18,7 @@ mod tests {
|
|||||||
fn should_detect_non_emscripten_files() {
|
fn should_detect_non_emscripten_files() {
|
||||||
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_false.wast");
|
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_false.wast");
|
||||||
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
|
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
|
||||||
let module =
|
let module = compile(&wasm_binary[..]).expect("WASM can't be compiled");
|
||||||
compile(&wasm_binary[..]).expect("WASM can't be compiled");
|
|
||||||
let module = Arc::new(module);
|
let module = Arc::new(module);
|
||||||
assert!(!is_emscripten_module(&module));
|
assert!(!is_emscripten_module(&module));
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
use wabt::wat2wasm;
|
use wabt::wat2wasm;
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime::{
|
||||||
error,
|
compile, error, func, imports,
|
||||||
func,
|
|
||||||
Global,
|
|
||||||
Memory,
|
|
||||||
imports,
|
|
||||||
compile,
|
|
||||||
Table,
|
|
||||||
Ctx,
|
|
||||||
types::{ElementType, MemoryDescriptor, TableDescriptor, Value},
|
types::{ElementType, MemoryDescriptor, TableDescriptor, Value},
|
||||||
units::Pages,
|
units::Pages,
|
||||||
|
Ctx, Global, Memory, Table,
|
||||||
};
|
};
|
||||||
|
|
||||||
static EXAMPLE_WASM: &'static [u8] = include_bytes!("simple.wasm");
|
static EXAMPLE_WASM: &'static [u8] = include_bytes!("simple.wasm");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use wabt::wat2wasm;
|
use wabt::wat2wasm;
|
||||||
use wasmer_runtime::{ImportObject, Instance, compile};
|
use wasmer_runtime::{compile, ImportObject, Instance};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let instance = create_module_1();
|
let instance = create_module_1();
|
||||||
@ -23,8 +23,7 @@ fn create_module_1() -> Instance {
|
|||||||
(elem (;1;) (i32.const 9) 1))
|
(elem (;1;) (i32.const 9) 1))
|
||||||
"#;
|
"#;
|
||||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||||
let module = compile(&wasm_binary[..])
|
let module = compile(&wasm_binary[..]).expect("WASM can't be compiled");
|
||||||
.expect("WASM can't be compiled");
|
|
||||||
module
|
module
|
||||||
.instantiate(&generate_imports())
|
.instantiate(&generate_imports())
|
||||||
.expect("WASM can't be instantiated")
|
.expect("WASM can't be instantiated")
|
||||||
@ -43,8 +42,7 @@ static IMPORT_MODULE: &str = r#"
|
|||||||
|
|
||||||
pub fn generate_imports() -> ImportObject {
|
pub fn generate_imports() -> ImportObject {
|
||||||
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
|
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
|
||||||
let module = compile(&wasm_binary[..])
|
let module = compile(&wasm_binary[..]).expect("WASM can't be compiled");
|
||||||
.expect("WASM can't be compiled");
|
|
||||||
let instance = module
|
let instance = module
|
||||||
.instantiate(&ImportObject::new())
|
.instantiate(&ImportObject::new())
|
||||||
.expect("WASM can't be instantiated");
|
.expect("WASM can't be instantiated");
|
||||||
|
@ -21,8 +21,7 @@ mod tests {
|
|||||||
(elem (;0;) (i32.const 0) 0))
|
(elem (;0;) (i32.const 0) 0))
|
||||||
"#;
|
"#;
|
||||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||||
let module = wasmer_runtime::compile(&wasm_binary[..])
|
let module = wasmer_runtime::compile(&wasm_binary[..]).expect("WASM can't be compiled");
|
||||||
.expect("WASM can't be compiled");
|
|
||||||
let instance = module
|
let instance = module
|
||||||
.instantiate(&ImportObject::new())
|
.instantiate(&ImportObject::new())
|
||||||
.expect("WASM can't be instantiated");
|
.expect("WASM can't be instantiated");
|
||||||
|
@ -217,21 +217,13 @@ mod tests {
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use wabt::script::{Action, Command, CommandKind, ScriptParser, Value};
|
use wabt::script::{Action, Command, CommandKind, ScriptParser, Value};
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime::{
|
||||||
CompilerConfig,
|
compile_with_config,
|
||||||
ImportObject,
|
error::CompileError,
|
||||||
LikeNamespace,
|
func, imports,
|
||||||
Instance,
|
|
||||||
error::{CompileError},
|
|
||||||
Export,
|
|
||||||
Global,
|
|
||||||
Memory,
|
|
||||||
Table,
|
|
||||||
types::{ElementType, MemoryDescriptor, TableDescriptor},
|
types::{ElementType, MemoryDescriptor, TableDescriptor},
|
||||||
units::Pages,
|
units::Pages,
|
||||||
|
CompilerConfig, Ctx, Export, Features, Global, ImportObject, Instance, LikeNamespace,
|
||||||
Features,
|
Memory, Table,
|
||||||
func, imports, Ctx,
|
|
||||||
compile_with_config,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn parse_and_run(
|
fn parse_and_run(
|
||||||
@ -306,10 +298,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let module = compile_with_config(
|
let module = compile_with_config(&module.into_vec(), config)
|
||||||
&module.into_vec(),
|
|
||||||
config,
|
|
||||||
)
|
|
||||||
.expect("WASM can't be compiled");
|
.expect("WASM can't be compiled");
|
||||||
let i = module
|
let i = module
|
||||||
.instantiate(&spectest_import_object)
|
.instantiate(&spectest_import_object)
|
||||||
@ -715,10 +704,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
compile_with_config(
|
compile_with_config(&module.into_vec(), config)
|
||||||
&module.into_vec(),
|
|
||||||
config,
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
match result {
|
match result {
|
||||||
Ok(module) => {
|
Ok(module) => {
|
||||||
@ -770,10 +756,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
compile_with_config(
|
compile_with_config(&module.into_vec(), config)
|
||||||
&module.into_vec(),
|
|
||||||
config,
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@ -824,10 +807,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let module = compile_with_config(
|
let module = compile_with_config(&module.into_vec(), config)
|
||||||
&module.into_vec(),
|
|
||||||
config,
|
|
||||||
)
|
|
||||||
.expect("WASM can't be compiled");
|
.expect("WASM can't be compiled");
|
||||||
let result = panic::catch_unwind(AssertUnwindSafe(|| {
|
let result = panic::catch_unwind(AssertUnwindSafe(|| {
|
||||||
module
|
module
|
||||||
@ -922,10 +902,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let module = compile_with_config(
|
let module = compile_with_config(&module.into_vec(), config)
|
||||||
&module.into_vec(),
|
|
||||||
config,
|
|
||||||
)
|
|
||||||
.expect("WASM can't be compiled");
|
.expect("WASM can't be compiled");
|
||||||
module.instantiate(&spectest_import_object)
|
module.instantiate(&spectest_import_object)
|
||||||
}));
|
}));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#![cfg(test)]
|
#![cfg(test)]
|
||||||
use wasmer_runtime::{compile, Func, Ctx};
|
use wasmer_runtime::{compile, Ctx, Func};
|
||||||
use wasmer_wasi::{state::*, *};
|
use wasmer_wasi::{state::*, *};
|
||||||
|
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
|
@ -5,8 +5,7 @@ macro_rules! assert_wasi_output {
|
|||||||
use wasmer_wasi::generate_import_object;
|
use wasmer_wasi::generate_import_object;
|
||||||
let wasm_bytes = include_bytes!($file);
|
let wasm_bytes = include_bytes!($file);
|
||||||
|
|
||||||
let module = wasmer_runtime::compile(&wasm_bytes[..])
|
let module = wasmer_runtime::compile(&wasm_bytes[..]).expect("WASM can't be compiled");
|
||||||
.expect("WASM can't be compiled");
|
|
||||||
|
|
||||||
let import_object = generate_import_object(vec![], vec![], $po_dir_args, $mapdir_args);
|
let import_object = generate_import_object(vec![], vec![], $po_dir_args, $mapdir_args);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user