mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-15 15:15:40 +00:00
145 lines
5.5 KiB
Rust
145 lines
5.5 KiB
Rust
|
// Rust test file autogenerated with cargo build (build/spectests.rs).
|
||
|
// Please do NOT modify it by hand, as it will be reset on next build.
|
||
|
// Test based on spectests/custom.wast
|
||
|
#![allow(
|
||
|
warnings,
|
||
|
dead_code
|
||
|
)]
|
||
|
use wabt::wat2wasm;
|
||
|
use std::{f32, f64};
|
||
|
|
||
|
use wasmer_runtime::types::Value;
|
||
|
use wasmer_runtime::{Instance, Module};
|
||
|
use wasmer_clif_backend::CraneliftCompiler;
|
||
|
|
||
|
use crate::spectests::_common::{
|
||
|
spectest_importobject,
|
||
|
NaNCheck,
|
||
|
};
|
||
|
|
||
|
|
||
|
// Line 1
|
||
|
fn create_module_1() -> Box<Instance> {
|
||
|
let module_str = "(module)
|
||
|
";
|
||
|
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||
|
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new()).expect("WASM can't be compiled");
|
||
|
module.instantiate(&spectest_importobject()).expect("WASM can't be instantiated")
|
||
|
}
|
||
|
|
||
|
fn start_module_1(instance: &mut Instance) {
|
||
|
// TODO Review is explicit start needed? Start now called in runtime::Instance::new()
|
||
|
//instance.start();
|
||
|
}
|
||
|
|
||
|
// Line 14
|
||
|
|
||
|
#[test]
|
||
|
fn test_module_1() {
|
||
|
let mut instance = create_module_1();
|
||
|
// We group the calls together
|
||
|
start_module_1(&mut instance);
|
||
|
}
|
||
|
fn create_module_2() -> Box<Instance> {
|
||
|
let module_str = "(module)
|
||
|
";
|
||
|
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||
|
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new()).expect("WASM can't be compiled");
|
||
|
module.instantiate(&spectest_importobject()).expect("WASM can't be instantiated")
|
||
|
}
|
||
|
|
||
|
fn start_module_2(instance: &mut Instance) {
|
||
|
// TODO Review is explicit start needed? Start now called in runtime::Instance::new()
|
||
|
//instance.start();
|
||
|
}
|
||
|
|
||
|
// Line 50
|
||
|
|
||
|
#[test]
|
||
|
fn test_module_2() {
|
||
|
let mut instance = create_module_2();
|
||
|
// We group the calls together
|
||
|
start_module_2(&mut instance);
|
||
|
}
|
||
|
fn create_module_3() -> Box<Instance> {
|
||
|
let module_str = "(module
|
||
|
(type (;0;) (func (param i32 i32) (result i32)))
|
||
|
(func (;0;) (type 0) (param i32 i32) (result i32)
|
||
|
get_local 0
|
||
|
get_local 1
|
||
|
i32.add)
|
||
|
(export \"addTwo\" (func 0)))
|
||
|
";
|
||
|
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||
|
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new()).expect("WASM can't be compiled");
|
||
|
module.instantiate(&spectest_importobject()).expect("WASM can't be instantiated")
|
||
|
}
|
||
|
|
||
|
fn start_module_3(instance: &mut Instance) {
|
||
|
// TODO Review is explicit start needed? Start now called in runtime::Instance::new()
|
||
|
//instance.start();
|
||
|
}
|
||
|
|
||
|
// Line 61
|
||
|
#[test]
|
||
|
fn c3_l61_assert_malformed() {
|
||
|
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 0];
|
||
|
let compilation = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new());
|
||
|
assert!(compilation.is_err(), "WASM should not compile as is malformed");
|
||
|
}
|
||
|
|
||
|
// Line 69
|
||
|
#[test]
|
||
|
fn c4_l69_assert_malformed() {
|
||
|
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 0, 0];
|
||
|
let compilation = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new());
|
||
|
assert!(compilation.is_err(), "WASM should not compile as is malformed");
|
||
|
}
|
||
|
|
||
|
// Line 77
|
||
|
#[test]
|
||
|
fn c5_l77_assert_malformed() {
|
||
|
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 0, 0, 0, 5, 1, 0, 7, 0, 0];
|
||
|
let compilation = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new());
|
||
|
assert!(compilation.is_err(), "WASM should not compile as is malformed");
|
||
|
}
|
||
|
|
||
|
// Line 85
|
||
|
#[test]
|
||
|
fn c6_l85_assert_malformed() {
|
||
|
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 0, 38, 16, 97, 32, 99, 117, 115, 116, 111, 109, 32, 115, 101, 99, 116, 105, 111, 110, 116, 104, 105, 115, 32, 105, 115, 32, 116, 104, 101, 32, 112, 97, 121, 108, 111, 97, 100];
|
||
|
let compilation = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new());
|
||
|
assert!(compilation.is_err(), "WASM should not compile as is malformed");
|
||
|
}
|
||
|
|
||
|
// Line 93
|
||
|
#[test]
|
||
|
fn c7_l93_assert_malformed() {
|
||
|
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 0, 37, 16, 97, 32, 99, 117, 115, 116, 111, 109, 32, 115, 101, 99, 116, 105, 111, 110, 116, 104, 105, 115, 32, 105, 115, 32, 116, 104, 101, 32, 112, 97, 121, 108, 111, 97, 100, 0, 36, 16, 97, 32, 99, 117, 115, 116, 111, 109, 32, 115, 101, 99, 116, 105, 111, 110, 116, 104, 105, 115, 32, 105, 115, 32, 116, 104, 101, 32, 112, 97, 121, 108, 111, 97, 100];
|
||
|
let compilation = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new());
|
||
|
assert!(compilation.is_err(), "WASM should not compile as is malformed");
|
||
|
}
|
||
|
|
||
|
// Line 102
|
||
|
#[test]
|
||
|
fn c8_l102_assert_malformed() {
|
||
|
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 7, 1, 96, 2, 127, 127, 1, 127, 0, 37, 16, 97, 32, 99, 117, 115, 116, 111, 109, 32, 115, 101, 99, 116, 105, 111, 110, 116, 104, 105, 115, 32, 105, 115, 32, 116, 104, 101, 32, 112, 97, 121, 108, 111, 97, 100, 3, 2, 1, 0, 10, 9, 1, 7, 0, 32, 0, 32, 1, 106, 11, 0, 27, 7, 99, 117, 115, 116, 111, 109, 50, 116, 104, 105, 115, 32, 105, 115, 32, 116, 104, 101, 32, 112, 97, 121, 108, 111, 97, 100];
|
||
|
let compilation = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new());
|
||
|
assert!(compilation.is_err(), "WASM should not compile as is malformed");
|
||
|
}
|
||
|
|
||
|
// Line 115
|
||
|
#[test]
|
||
|
fn c9_l115_assert_malformed() {
|
||
|
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 0, 97, 115, 109, 1, 0, 0, 0];
|
||
|
let compilation = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new());
|
||
|
assert!(compilation.is_err(), "WASM should not compile as is malformed");
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_module_3() {
|
||
|
let mut instance = create_module_3();
|
||
|
// We group the calls together
|
||
|
start_module_3(&mut instance);
|
||
|
}
|