wasmer/lib/runtime/tests/spectests/memory_grow.rs

1266 lines
41 KiB
Rust
Raw Normal View History

2019-01-09 06:06:24 +00:00
// 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/memory_grow.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
(type (;0;) (func (result i32)))
(type (;1;) (func))
(type (;2;) (func (param i32) (result i32)))
(func (;0;) (type 0) (result i32)
i32.const 0
i32.load)
(func (;1;) (type 1)
i32.const 0
i32.const 2
i32.store)
(func (;2;) (type 0) (result i32)
i32.const 65536
i32.load)
(func (;3;) (type 1)
i32.const 65536
i32.const 3
i32.store)
(func (;4;) (type 2) (param i32) (result i32)
get_local 0
memory.grow)
(func (;5;) (type 0) (result i32)
memory.size)
(memory (;0;) 0)
(export \"load_at_zero\" (func 0))
(export \"store_at_zero\" (func 1))
(export \"load_at_page_size\" (func 2))
(export \"store_at_page_size\" (func 3))
(export \"grow\" (func 4))
(export \"size\" (func 5)))
";
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
fn c1_l14_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c1_l14_action_invoke");
let result = instance.call("size", &[]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 15
fn c2_l15_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c2_l15_action_invoke");
let result = instance.call("store_at_zero", &[]);
result.map(|_| ())
}
#[test]
fn c2_l15_assert_trap() {
let mut instance = create_module_1();
let result = c2_l15_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 16
fn c3_l16_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c3_l16_action_invoke");
let result = instance.call("load_at_zero", &[]);
result.map(|_| ())
}
#[test]
fn c3_l16_assert_trap() {
let mut instance = create_module_1();
let result = c3_l16_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 17
fn c4_l17_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c4_l17_action_invoke");
let result = instance.call("store_at_page_size", &[]);
result.map(|_| ())
}
#[test]
fn c4_l17_assert_trap() {
let mut instance = create_module_1();
let result = c4_l17_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 18
fn c5_l18_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c5_l18_action_invoke");
let result = instance.call("load_at_page_size", &[]);
result.map(|_| ())
}
#[test]
fn c5_l18_assert_trap() {
let mut instance = create_module_1();
let result = c5_l18_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 19
fn c6_l19_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c6_l19_action_invoke");
let result = instance.call("grow", &[Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 20
fn c7_l20_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c7_l20_action_invoke");
let result = instance.call("size", &[]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 21
fn c8_l21_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c8_l21_action_invoke");
let result = instance.call("load_at_zero", &[]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 22
fn c9_l22_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c9_l22_action_invoke");
let result = instance.call("store_at_zero", &[]);
assert_eq!(result, Ok(None));
result.map(|_| ())
}
// Line 23
fn c10_l23_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c10_l23_action_invoke");
let result = instance.call("load_at_zero", &[]);
assert_eq!(result, Ok(Some(Value::I32(2 as i32))));
result.map(|_| ())
}
// Line 24
fn c11_l24_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c11_l24_action_invoke");
let result = instance.call("store_at_page_size", &[]);
result.map(|_| ())
}
#[test]
fn c11_l24_assert_trap() {
let mut instance = create_module_1();
let result = c11_l24_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 25
fn c12_l25_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c12_l25_action_invoke");
let result = instance.call("load_at_page_size", &[]);
result.map(|_| ())
}
#[test]
fn c12_l25_assert_trap() {
let mut instance = create_module_1();
let result = c12_l25_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 26
fn c13_l26_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c13_l26_action_invoke");
let result = instance.call("grow", &[Value::I32(4 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 27
fn c14_l27_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c14_l27_action_invoke");
let result = instance.call("size", &[]);
assert_eq!(result, Ok(Some(Value::I32(5 as i32))));
result.map(|_| ())
}
// Line 28
fn c15_l28_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c15_l28_action_invoke");
let result = instance.call("load_at_zero", &[]);
assert_eq!(result, Ok(Some(Value::I32(2 as i32))));
result.map(|_| ())
}
// Line 29
fn c16_l29_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c16_l29_action_invoke");
let result = instance.call("store_at_zero", &[]);
assert_eq!(result, Ok(None));
result.map(|_| ())
}
// Line 30
fn c17_l30_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c17_l30_action_invoke");
let result = instance.call("load_at_zero", &[]);
assert_eq!(result, Ok(Some(Value::I32(2 as i32))));
result.map(|_| ())
}
// Line 31
fn c18_l31_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c18_l31_action_invoke");
let result = instance.call("load_at_page_size", &[]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 32
fn c19_l32_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c19_l32_action_invoke");
let result = instance.call("store_at_page_size", &[]);
assert_eq!(result, Ok(None));
result.map(|_| ())
}
// Line 33
fn c20_l33_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c20_l33_action_invoke");
let result = instance.call("load_at_page_size", &[]);
assert_eq!(result, Ok(Some(Value::I32(3 as i32))));
result.map(|_| ())
}
// Line 36
#[test]
fn test_module_1() {
let mut instance = create_module_1();
// We group the calls together
start_module_1(&mut instance);
c1_l14_action_invoke(&mut instance);
c6_l19_action_invoke(&mut instance);
c7_l20_action_invoke(&mut instance);
c8_l21_action_invoke(&mut instance);
c9_l22_action_invoke(&mut instance);
c10_l23_action_invoke(&mut instance);
c13_l26_action_invoke(&mut instance);
c14_l27_action_invoke(&mut instance);
c15_l28_action_invoke(&mut instance);
c16_l29_action_invoke(&mut instance);
c17_l30_action_invoke(&mut instance);
c18_l31_action_invoke(&mut instance);
c19_l32_action_invoke(&mut instance);
c20_l33_action_invoke(&mut instance);
}
fn create_module_2() -> Box<Instance> {
let module_str = "(module
(type (;0;) (func (param i32) (result i32)))
(func (;0;) (type 0) (param i32) (result i32)
get_local 0
memory.grow)
(memory (;0;) 0)
(export \"grow\" (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_2(instance: &mut Instance) {
// TODO Review is explicit start needed? Start now called in runtime::Instance::new()
//instance.start();
}
// Line 41
fn c22_l41_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c22_l41_action_invoke");
let result = instance.call("grow", &[Value::I32(0 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 42
fn c23_l42_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c23_l42_action_invoke");
let result = instance.call("grow", &[Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 43
fn c24_l43_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c24_l43_action_invoke");
let result = instance.call("grow", &[Value::I32(0 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 44
fn c25_l44_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c25_l44_action_invoke");
let result = instance.call("grow", &[Value::I32(2 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 45
fn c26_l45_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c26_l45_action_invoke");
let result = instance.call("grow", &[Value::I32(800 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(3 as i32))));
result.map(|_| ())
}
// Line 46
fn c27_l46_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c27_l46_action_invoke");
let result = instance.call("grow", &[Value::I32(65536 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(-1 as i32))));
result.map(|_| ())
}
// Line 47
fn c28_l47_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c28_l47_action_invoke");
let result = instance.call("grow", &[Value::I32(64736 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(-1 as i32))));
result.map(|_| ())
}
// Line 48
fn c29_l48_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c29_l48_action_invoke");
let result = instance.call("grow", &[Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(803 as i32))));
result.map(|_| ())
}
// Line 50
#[test]
fn test_module_2() {
let mut instance = create_module_2();
// We group the calls together
start_module_2(&mut instance);
c22_l41_action_invoke(&mut instance);
c23_l42_action_invoke(&mut instance);
c24_l43_action_invoke(&mut instance);
c25_l44_action_invoke(&mut instance);
c26_l45_action_invoke(&mut instance);
c27_l46_action_invoke(&mut instance);
c28_l47_action_invoke(&mut instance);
c29_l48_action_invoke(&mut instance);
}
fn create_module_3() -> Box<Instance> {
let module_str = "(module
(type (;0;) (func (param i32) (result i32)))
(func (;0;) (type 0) (param i32) (result i32)
get_local 0
memory.grow)
(memory (;0;) 0 10)
(export \"grow\" (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 55
fn c31_l55_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c31_l55_action_invoke");
let result = instance.call("grow", &[Value::I32(0 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 56
fn c32_l56_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c32_l56_action_invoke");
let result = instance.call("grow", &[Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 57
fn c33_l57_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c33_l57_action_invoke");
let result = instance.call("grow", &[Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 58
fn c34_l58_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c34_l58_action_invoke");
let result = instance.call("grow", &[Value::I32(2 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(2 as i32))));
result.map(|_| ())
}
// Line 59
fn c35_l59_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c35_l59_action_invoke");
let result = instance.call("grow", &[Value::I32(6 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(4 as i32))));
result.map(|_| ())
}
// Line 60
fn c36_l60_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c36_l60_action_invoke");
let result = instance.call("grow", &[Value::I32(0 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(10 as i32))));
result.map(|_| ())
}
// Line 61
fn c37_l61_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c37_l61_action_invoke");
let result = instance.call("grow", &[Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(-1 as i32))));
result.map(|_| ())
}
// Line 62
fn c38_l62_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c38_l62_action_invoke");
let result = instance.call("grow", &[Value::I32(65536 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(-1 as i32))));
result.map(|_| ())
}
// Line 66
#[test]
fn test_module_3() {
let mut instance = create_module_3();
// We group the calls together
start_module_3(&mut instance);
c31_l55_action_invoke(&mut instance);
c32_l56_action_invoke(&mut instance);
c33_l57_action_invoke(&mut instance);
c34_l58_action_invoke(&mut instance);
c35_l59_action_invoke(&mut instance);
c36_l60_action_invoke(&mut instance);
c37_l61_action_invoke(&mut instance);
c38_l62_action_invoke(&mut instance);
}
fn create_module_4() -> Box<Instance> {
let module_str = "(module
(type (;0;) (func (param i32) (result i32)))
(type (;1;) (func (param i32 i32) (result i32)))
(func (;0;) (type 0) (param i32) (result i32)
get_local 0
memory.grow)
(func (;1;) (type 1) (param i32 i32) (result i32)
(local i32)
i32.const 1
set_local 2
block ;; label = @1
loop ;; label = @2
get_local 0
i32.load8_u
set_local 2
get_local 2
i32.const 0
i32.ne
br_if 1 (;@1;)
get_local 0
get_local 1
i32.ge_u
br_if 1 (;@1;)
get_local 0
i32.const 1
i32.add
set_local 0
get_local 0
get_local 1
i32.le_u
br_if 0 (;@2;)
end
end
get_local 2)
(memory (;0;) 1)
(export \"grow\" (func 0))
(export \"check-memory-zero\" (func 1)))
";
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_4(instance: &mut Instance) {
// TODO Review is explicit start needed? Start now called in runtime::Instance::new()
//instance.start();
}
// Line 87
fn c40_l87_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c40_l87_action_invoke");
let result = instance.call("check-memory-zero", &[Value::I32(0 as i32), Value::I32(65535 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 88
fn c41_l88_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c41_l88_action_invoke");
let result = instance.call("grow", &[Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 89
fn c42_l89_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c42_l89_action_invoke");
let result = instance.call("check-memory-zero", &[Value::I32(65536 as i32), Value::I32(131071 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 90
fn c43_l90_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c43_l90_action_invoke");
let result = instance.call("grow", &[Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(2 as i32))));
result.map(|_| ())
}
// Line 91
fn c44_l91_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c44_l91_action_invoke");
let result = instance.call("check-memory-zero", &[Value::I32(131072 as i32), Value::I32(196607 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 92
fn c45_l92_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c45_l92_action_invoke");
let result = instance.call("grow", &[Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(3 as i32))));
result.map(|_| ())
}
// Line 93
fn c46_l93_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c46_l93_action_invoke");
let result = instance.call("check-memory-zero", &[Value::I32(196608 as i32), Value::I32(262143 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 94
fn c47_l94_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c47_l94_action_invoke");
let result = instance.call("grow", &[Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(4 as i32))));
result.map(|_| ())
}
// Line 95
fn c48_l95_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c48_l95_action_invoke");
let result = instance.call("check-memory-zero", &[Value::I32(262144 as i32), Value::I32(327679 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 96
fn c49_l96_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c49_l96_action_invoke");
let result = instance.call("grow", &[Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(5 as i32))));
result.map(|_| ())
}
// Line 97
fn c50_l97_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c50_l97_action_invoke");
let result = instance.call("check-memory-zero", &[Value::I32(327680 as i32), Value::I32(393215 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 101
#[test]
fn test_module_4() {
let mut instance = create_module_4();
// We group the calls together
start_module_4(&mut instance);
c40_l87_action_invoke(&mut instance);
c41_l88_action_invoke(&mut instance);
c42_l89_action_invoke(&mut instance);
c43_l90_action_invoke(&mut instance);
c44_l91_action_invoke(&mut instance);
c45_l92_action_invoke(&mut instance);
c46_l93_action_invoke(&mut instance);
c47_l94_action_invoke(&mut instance);
c48_l95_action_invoke(&mut instance);
c49_l96_action_invoke(&mut instance);
c50_l97_action_invoke(&mut instance);
}
fn create_module_5() -> Box<Instance> {
let module_str = "(module
(type (;0;) (func (param i32 i32 i32) (result i32)))
(type (;1;) (func (result i32)))
(type (;2;) (func))
(type (;3;) (func (param i32 i32) (result i32)))
(func (;0;) (type 1) (result i32)
block (result i32) ;; label = @1
i32.const 0
memory.grow
br 0 (;@1;)
end)
(func (;1;) (type 2)
block ;; label = @1
i32.const 0
memory.grow
br_if 0 (;@1;)
end)
(func (;2;) (type 1) (result i32)
block (result i32) ;; label = @1
i32.const 0
memory.grow
i32.const 1
br_if 0 (;@1;)
drop
i32.const 7
end)
(func (;3;) (type 1) (result i32)
block (result i32) ;; label = @1
i32.const 6
i32.const 0
memory.grow
br_if 0 (;@1;)
drop
i32.const 7
end)
(func (;4;) (type 2)
block ;; label = @1
i32.const 0
memory.grow
br_table 0 (;@1;) 0 (;@1;) 0 (;@1;)
end)
(func (;5;) (type 1) (result i32)
block (result i32) ;; label = @1
i32.const 0
memory.grow
i32.const 1
br_table 0 (;@1;) 0 (;@1;) 0 (;@1;)
i32.const 7
end)
(func (;6;) (type 1) (result i32)
block (result i32) ;; label = @1
i32.const 6
i32.const 0
memory.grow
br_table 0 (;@1;) 0 (;@1;)
i32.const 7
end)
(func (;7;) (type 1) (result i32)
i32.const 0
memory.grow
return)
(func (;8;) (type 1) (result i32)
i32.const 0
memory.grow
if (result i32) ;; label = @1
i32.const 0
else
i32.const 1
end)
(func (;9;) (type 1) (result i32)
i32.const 1
if (result i32) ;; label = @1
i32.const 0
memory.grow
else
i32.const 0
end)
(func (;10;) (type 1) (result i32)
i32.const 0
if (result i32) ;; label = @1
i32.const 0
else
i32.const 0
memory.grow
end)
(func (;11;) (type 3) (param i32 i32) (result i32)
i32.const 0
memory.grow
get_local 0
get_local 1
select)
(func (;12;) (type 3) (param i32 i32) (result i32)
get_local 0
i32.const 0
memory.grow
get_local 1
select)
(func (;13;) (type 1) (result i32)
i32.const 0
i32.const 1
i32.const 0
memory.grow
select)
(func (;14;) (type 0) (param i32 i32 i32) (result i32)
i32.const -1)
(func (;15;) (type 1) (result i32)
i32.const 0
memory.grow
i32.const 2
i32.const 3
call 14)
(func (;16;) (type 1) (result i32)
i32.const 1
i32.const 0
memory.grow
i32.const 3
call 14)
(func (;17;) (type 1) (result i32)
i32.const 1
i32.const 2
i32.const 0
memory.grow
call 14)
(func (;18;) (type 1) (result i32)
i32.const 0
memory.grow
i32.const 2
i32.const 3
i32.const 0
call_indirect (type 0))
(func (;19;) (type 1) (result i32)
i32.const 1
i32.const 0
memory.grow
i32.const 3
i32.const 0
call_indirect (type 0))
(func (;20;) (type 1) (result i32)
i32.const 1
i32.const 2
i32.const 0
memory.grow
i32.const 0
call_indirect (type 0))
(func (;21;) (type 1) (result i32)
i32.const 1
i32.const 2
i32.const 3
i32.const 0
memory.grow
call_indirect (type 0))
(func (;22;) (type 2)
(local i32)
i32.const 0
memory.grow
set_local 0)
(func (;23;) (type 1) (result i32)
(local i32)
i32.const 0
memory.grow
tee_local 0)
(func (;24;) (type 2)
(local i32)
i32.const 0
memory.grow
set_global 0)
(func (;25;) (type 1) (result i32)
i32.const 0
memory.grow
i32.load)
(func (;26;) (type 1) (result i32)
i32.const 0
memory.grow
i32.load8_s)
(func (;27;) (type 2)
i32.const 0
memory.grow
i32.const 7
i32.store)
(func (;28;) (type 2)
i32.const 2
i32.const 0
memory.grow
i32.store)
(func (;29;) (type 2)
i32.const 0
memory.grow
i32.const 7
i32.store8)
(func (;30;) (type 2)
i32.const 2
i32.const 0
memory.grow
i32.store16)
(func (;31;) (type 1) (result i32)
i32.const 0
memory.grow
i32.clz)
(func (;32;) (type 1) (result i32)
i32.const 0
memory.grow
i32.const 10
i32.add)
(func (;33;) (type 1) (result i32)
i32.const 10
i32.const 0
memory.grow
i32.sub)
(func (;34;) (type 1) (result i32)
i32.const 0
memory.grow
i32.eqz)
(func (;35;) (type 1) (result i32)
i32.const 0
memory.grow
i32.const 10
i32.le_s)
(func (;36;) (type 1) (result i32)
i32.const 10
i32.const 0
memory.grow
i32.ne)
(func (;37;) (type 1) (result i32)
i32.const 0
memory.grow
memory.grow)
(table (;0;) 1 1 anyfunc)
(memory (;0;) 1)
(global (;0;) (mut i32) (i32.const 0))
(export \"as-br-value\" (func 0))
(export \"as-br_if-cond\" (func 1))
(export \"as-br_if-value\" (func 2))
(export \"as-br_if-value-cond\" (func 3))
(export \"as-br_table-index\" (func 4))
(export \"as-br_table-value\" (func 5))
(export \"as-br_table-value-index\" (func 6))
(export \"as-return-value\" (func 7))
(export \"as-if-cond\" (func 8))
(export \"as-if-then\" (func 9))
(export \"as-if-else\" (func 10))
(export \"as-select-first\" (func 11))
(export \"as-select-second\" (func 12))
(export \"as-select-cond\" (func 13))
(export \"as-call-first\" (func 15))
(export \"as-call-mid\" (func 16))
(export \"as-call-last\" (func 17))
(export \"as-call_indirect-first\" (func 18))
(export \"as-call_indirect-mid\" (func 19))
(export \"as-call_indirect-last\" (func 20))
(export \"as-call_indirect-index\" (func 21))
(export \"as-set_local-value\" (func 22))
(export \"as-tee_local-value\" (func 23))
(export \"as-set_global-value\" (func 24))
(export \"as-load-address\" (func 25))
(export \"as-loadN-address\" (func 26))
(export \"as-store-address\" (func 27))
(export \"as-store-value\" (func 28))
(export \"as-storeN-address\" (func 29))
(export \"as-storeN-value\" (func 30))
(export \"as-unary-operand\" (func 31))
(export \"as-binary-left\" (func 32))
(export \"as-binary-right\" (func 33))
(export \"as-test-operand\" (func 34))
(export \"as-compare-left\" (func 35))
(export \"as-compare-right\" (func 36))
(export \"as-memory.grow-size\" (func 37))
(elem (;0;) (i32.const 0) 14))
";
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_5(instance: &mut Instance) {
// TODO Review is explicit start needed? Start now called in runtime::Instance::new()
//instance.start();
}
// Line 259
fn c52_l259_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c52_l259_action_invoke");
let result = instance.call("as-br-value", &[]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 261
fn c53_l261_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c53_l261_action_invoke");
let result = instance.call("as-br_if-cond", &[]);
assert_eq!(result, Ok(None));
result.map(|_| ())
}
// Line 262
fn c54_l262_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c54_l262_action_invoke");
let result = instance.call("as-br_if-value", &[]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 263
fn c55_l263_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c55_l263_action_invoke");
let result = instance.call("as-br_if-value-cond", &[]);
assert_eq!(result, Ok(Some(Value::I32(6 as i32))));
result.map(|_| ())
}
// Line 265
fn c56_l265_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c56_l265_action_invoke");
let result = instance.call("as-br_table-index", &[]);
assert_eq!(result, Ok(None));
result.map(|_| ())
}
// Line 266
fn c57_l266_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c57_l266_action_invoke");
let result = instance.call("as-br_table-value", &[]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 267
fn c58_l267_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c58_l267_action_invoke");
let result = instance.call("as-br_table-value-index", &[]);
assert_eq!(result, Ok(Some(Value::I32(6 as i32))));
result.map(|_| ())
}
// Line 269
fn c59_l269_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c59_l269_action_invoke");
let result = instance.call("as-return-value", &[]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 271
fn c60_l271_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c60_l271_action_invoke");
let result = instance.call("as-if-cond", &[]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 272
fn c61_l272_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c61_l272_action_invoke");
let result = instance.call("as-if-then", &[]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 273
fn c62_l273_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c62_l273_action_invoke");
let result = instance.call("as-if-else", &[]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 275
fn c63_l275_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c63_l275_action_invoke");
let result = instance.call("as-select-first", &[Value::I32(0 as i32), Value::I32(1 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 276
fn c64_l276_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c64_l276_action_invoke");
let result = instance.call("as-select-second", &[Value::I32(0 as i32), Value::I32(0 as i32)]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 277
fn c65_l277_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c65_l277_action_invoke");
let result = instance.call("as-select-cond", &[]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 279
fn c66_l279_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c66_l279_action_invoke");
let result = instance.call("as-call-first", &[]);
assert_eq!(result, Ok(Some(Value::I32(-1 as i32))));
result.map(|_| ())
}
// Line 280
fn c67_l280_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c67_l280_action_invoke");
let result = instance.call("as-call-mid", &[]);
assert_eq!(result, Ok(Some(Value::I32(-1 as i32))));
result.map(|_| ())
}
// Line 281
fn c68_l281_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c68_l281_action_invoke");
let result = instance.call("as-call-last", &[]);
assert_eq!(result, Ok(Some(Value::I32(-1 as i32))));
result.map(|_| ())
}
// Line 283
fn c69_l283_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c69_l283_action_invoke");
let result = instance.call("as-call_indirect-first", &[]);
assert_eq!(result, Ok(Some(Value::I32(-1 as i32))));
result.map(|_| ())
}
// Line 284
fn c70_l284_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c70_l284_action_invoke");
let result = instance.call("as-call_indirect-mid", &[]);
assert_eq!(result, Ok(Some(Value::I32(-1 as i32))));
result.map(|_| ())
}
// Line 285
fn c71_l285_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c71_l285_action_invoke");
let result = instance.call("as-call_indirect-last", &[]);
assert_eq!(result, Ok(Some(Value::I32(-1 as i32))));
result.map(|_| ())
}
// Line 286
fn c72_l286_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c72_l286_action_invoke");
let result = instance.call("as-call_indirect-index", &[]);
result.map(|_| ())
}
#[test]
fn c72_l286_assert_trap() {
let mut instance = create_module_5();
let result = c72_l286_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 288
fn c73_l288_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c73_l288_action_invoke");
let result = instance.call("as-set_local-value", &[]);
assert_eq!(result, Ok(None));
result.map(|_| ())
}
// Line 289
fn c74_l289_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c74_l289_action_invoke");
let result = instance.call("as-tee_local-value", &[]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 290
fn c75_l290_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c75_l290_action_invoke");
let result = instance.call("as-set_global-value", &[]);
assert_eq!(result, Ok(None));
result.map(|_| ())
}
// Line 292
fn c76_l292_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c76_l292_action_invoke");
let result = instance.call("as-load-address", &[]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 293
fn c77_l293_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c77_l293_action_invoke");
let result = instance.call("as-loadN-address", &[]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 294
fn c78_l294_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c78_l294_action_invoke");
let result = instance.call("as-store-address", &[]);
assert_eq!(result, Ok(None));
result.map(|_| ())
}
// Line 295
fn c79_l295_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c79_l295_action_invoke");
let result = instance.call("as-store-value", &[]);
assert_eq!(result, Ok(None));
result.map(|_| ())
}
// Line 296
fn c80_l296_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c80_l296_action_invoke");
let result = instance.call("as-storeN-address", &[]);
assert_eq!(result, Ok(None));
result.map(|_| ())
}
// Line 297
fn c81_l297_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c81_l297_action_invoke");
let result = instance.call("as-storeN-value", &[]);
assert_eq!(result, Ok(None));
result.map(|_| ())
}
// Line 299
fn c82_l299_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c82_l299_action_invoke");
let result = instance.call("as-unary-operand", &[]);
assert_eq!(result, Ok(Some(Value::I32(31 as i32))));
result.map(|_| ())
}
// Line 301
fn c83_l301_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c83_l301_action_invoke");
let result = instance.call("as-binary-left", &[]);
assert_eq!(result, Ok(Some(Value::I32(11 as i32))));
result.map(|_| ())
}
// Line 302
fn c84_l302_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c84_l302_action_invoke");
let result = instance.call("as-binary-right", &[]);
assert_eq!(result, Ok(Some(Value::I32(9 as i32))));
result.map(|_| ())
}
// Line 304
fn c85_l304_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c85_l304_action_invoke");
let result = instance.call("as-test-operand", &[]);
assert_eq!(result, Ok(Some(Value::I32(0 as i32))));
result.map(|_| ())
}
// Line 306
fn c86_l306_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c86_l306_action_invoke");
let result = instance.call("as-compare-left", &[]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 307
fn c87_l307_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c87_l307_action_invoke");
let result = instance.call("as-compare-right", &[]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
// Line 309
fn c88_l309_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c88_l309_action_invoke");
let result = instance.call("as-memory.grow-size", &[]);
assert_eq!(result, Ok(Some(Value::I32(1 as i32))));
result.map(|_| ())
}
#[test]
fn test_module_5() {
let mut instance = create_module_5();
// We group the calls together
start_module_5(&mut instance);
c52_l259_action_invoke(&mut instance);
c53_l261_action_invoke(&mut instance);
c54_l262_action_invoke(&mut instance);
c55_l263_action_invoke(&mut instance);
c56_l265_action_invoke(&mut instance);
c57_l266_action_invoke(&mut instance);
c58_l267_action_invoke(&mut instance);
c59_l269_action_invoke(&mut instance);
c60_l271_action_invoke(&mut instance);
c61_l272_action_invoke(&mut instance);
c62_l273_action_invoke(&mut instance);
c63_l275_action_invoke(&mut instance);
c64_l276_action_invoke(&mut instance);
c65_l277_action_invoke(&mut instance);
c66_l279_action_invoke(&mut instance);
c67_l280_action_invoke(&mut instance);
c68_l281_action_invoke(&mut instance);
c69_l283_action_invoke(&mut instance);
c70_l284_action_invoke(&mut instance);
c71_l285_action_invoke(&mut instance);
c73_l288_action_invoke(&mut instance);
c74_l289_action_invoke(&mut instance);
c75_l290_action_invoke(&mut instance);
c76_l292_action_invoke(&mut instance);
c77_l293_action_invoke(&mut instance);
c78_l294_action_invoke(&mut instance);
c79_l295_action_invoke(&mut instance);
c80_l296_action_invoke(&mut instance);
c81_l297_action_invoke(&mut instance);
c82_l299_action_invoke(&mut instance);
c83_l301_action_invoke(&mut instance);
c84_l302_action_invoke(&mut instance);
c85_l304_action_invoke(&mut instance);
c86_l306_action_invoke(&mut instance);
c87_l307_action_invoke(&mut instance);
c88_l309_action_invoke(&mut instance);
}