// 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/set_local.wast #![allow( warnings, dead_code )] use wabt::wat2wasm; use std::{f32, f64}; use wasmer_runtime::types::Value; use wasmer_runtime::{Instance, module::Module}; use wasmer_clif_backend::CraneliftCompiler; use crate::spectests::_common::{ spectest_importobject, NaNCheck, }; // Line 3 fn create_module_1() -> Box { let module_str = "(module (type (;0;) (func)) (type (;1;) (func (param i32))) (type (;2;) (func (param i64))) (type (;3;) (func (param f32))) (type (;4;) (func (param f64))) (type (;5;) (func (param i64 f32 f64 i32 i32))) (type (;6;) (func (param i64 f32 f64 i32 i32) (result i64))) (func (;0;) (type 0) (local i32) i32.const 0 set_local 0) (func (;1;) (type 0) (local i64) i64.const 0 set_local 0) (func (;2;) (type 0) (local f32) f32.const 0x0p+0 (;=0;) set_local 0) (func (;3;) (type 0) (local f64) f64.const 0x0p+0 (;=0;) set_local 0) (func (;4;) (type 1) (param i32) i32.const 10 set_local 0) (func (;5;) (type 2) (param i64) i64.const 11 set_local 0) (func (;6;) (type 3) (param f32) f32.const 0x1.633334p+3 (;=11.1;) set_local 0) (func (;7;) (type 4) (param f64) f64.const 0x1.8666666666666p+3 (;=12.2;) set_local 0) (func (;8;) (type 5) (param i64 f32 f64 i32 i32) (local f32 i64 i64 f64) i64.const 0 set_local 0 f32.const 0x0p+0 (;=0;) set_local 1 f64.const 0x0p+0 (;=0;) set_local 2 i32.const 0 set_local 3 i32.const 0 set_local 4 f32.const 0x0p+0 (;=0;) set_local 5 i64.const 0 set_local 6 i64.const 0 set_local 7 f64.const 0x0p+0 (;=0;) set_local 8) (func (;9;) (type 6) (param i64 f32 f64 i32 i32) (result i64) (local f32 i64 i64 f64) f32.const -0x1.333334p-2 (;=-0.3;) set_local 1 i32.const 40 set_local 3 i32.const -7 set_local 4 f32.const 0x1.6p+2 (;=5.5;) set_local 5 i64.const 6 set_local 6 f64.const 0x1p+3 (;=8;) set_local 8 get_local 0 f64.convert_u/i64 get_local 1 f64.promote/f32 get_local 2 get_local 3 f64.convert_u/i32 get_local 4 f64.convert_s/i32 get_local 5 f64.promote/f32 get_local 6 f64.convert_u/i64 get_local 7 f64.convert_u/i64 get_local 8 f64.add f64.add f64.add f64.add f64.add f64.add f64.add f64.add i64.trunc_s/f64) (export \"type-local-i32\" (func 0)) (export \"type-local-i64\" (func 1)) (export \"type-local-f32\" (func 2)) (export \"type-local-f64\" (func 3)) (export \"type-param-i32\" (func 4)) (export \"type-param-i64\" (func 5)) (export \"type-param-f32\" (func 6)) (export \"type-param-f64\" (func 7)) (export \"type-mixed\" (func 8)) (export \"write\" (func 9))) "; 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 68 fn c1_l68_action_invoke(instance: &mut Instance) -> Result<(), String> { println!("Executing function {}", "c1_l68_action_invoke"); let result = instance.call("type-local-i32", &[]); assert_eq!(result, Ok(None)); result.map(|_| ()) } // Line 69 fn c2_l69_action_invoke(instance: &mut Instance) -> Result<(), String> { println!("Executing function {}", "c2_l69_action_invoke"); let result = instance.call("type-local-i64", &[]); assert_eq!(result, Ok(None)); result.map(|_| ()) } // Line 70 fn c3_l70_action_invoke(instance: &mut Instance) -> Result<(), String> { println!("Executing function {}", "c3_l70_action_invoke"); let result = instance.call("type-local-f32", &[]); assert_eq!(result, Ok(None)); result.map(|_| ()) } // Line 71 fn c4_l71_action_invoke(instance: &mut Instance) -> Result<(), String> { println!("Executing function {}", "c4_l71_action_invoke"); let result = instance.call("type-local-f64", &[]); assert_eq!(result, Ok(None)); result.map(|_| ()) } // Line 73 fn c5_l73_action_invoke(instance: &mut Instance) -> Result<(), String> { println!("Executing function {}", "c5_l73_action_invoke"); let result = instance.call("type-param-i32", &[Value::I32(2 as i32)]); assert_eq!(result, Ok(None)); result.map(|_| ()) } // Line 74 fn c6_l74_action_invoke(instance: &mut Instance) -> Result<(), String> { println!("Executing function {}", "c6_l74_action_invoke"); let result = instance.call("type-param-i64", &[Value::I64(3 as i64)]); assert_eq!(result, Ok(None)); result.map(|_| ()) } // Line 75 fn c7_l75_action_invoke(instance: &mut Instance) -> Result<(), String> { println!("Executing function {}", "c7_l75_action_invoke"); let result = instance.call("type-param-f32", &[Value::F32((4.4f32).to_bits())]); assert_eq!(result, Ok(None)); result.map(|_| ()) } // Line 76 fn c8_l76_action_invoke(instance: &mut Instance) -> Result<(), String> { println!("Executing function {}", "c8_l76_action_invoke"); let result = instance.call("type-param-f64", &[Value::F64((5.5f64).to_bits())]); assert_eq!(result, Ok(None)); result.map(|_| ()) } // Line 79 fn c9_l79_action_invoke(instance: &mut Instance) -> Result<(), String> { println!("Executing function {}", "c9_l79_action_invoke"); let result = instance.call("type-mixed", &[Value::I64(1 as i64), Value::F32((2.2f32).to_bits()), Value::F64((3.3f64).to_bits()), Value::I32(4 as i32), Value::I32(5 as i32)]); assert_eq!(result, Ok(None)); result.map(|_| ()) } // Line 85 fn c10_l85_action_invoke(instance: &mut Instance) -> Result<(), String> { println!("Executing function {}", "c10_l85_action_invoke"); let result = instance.call("write", &[Value::I64(1 as i64), Value::F32((2.0f32).to_bits()), Value::F64((3.3f64).to_bits()), Value::I32(4 as i32), Value::I32(5 as i32)]); assert_eq!(result, Ok(Some(Value::I64(56 as i64)))); result.map(|_| ()) } // Line 95 #[test] fn c11_l95_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 126, 3, 2, 1, 0, 10, 10, 1, 8, 1, 1, 127, 65, 0, 33, 0, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 101 #[test] fn c12_l101_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 14, 1, 12, 1, 1, 125, 67, 0, 0, 0, 0, 33, 0, 69, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 107 #[test] fn c13_l107_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 13, 1, 11, 2, 1, 124, 1, 126, 66, 0, 33, 1, 154, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 114 #[test] fn c14_l114_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 1, 1, 127, 1, 33, 0, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 118 #[test] fn c15_l118_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 13, 1, 11, 1, 1, 127, 67, 0, 0, 0, 0, 33, 0, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 122 #[test] fn c16_l122_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 17, 1, 15, 1, 1, 125, 68, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 126 #[test] fn c17_l126_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 19, 1, 17, 2, 1, 124, 1, 126, 68, 0, 0, 0, 0, 0, 0, 0, 0, 33, 1, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 134 #[test] fn c18_l134_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 1, 127, 1, 126, 3, 2, 1, 0, 10, 6, 1, 4, 0, 32, 0, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 138 #[test] fn c19_l138_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 125, 0, 3, 2, 1, 0, 10, 7, 1, 5, 0, 32, 0, 69, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 142 #[test] fn c20_l142_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 2, 124, 126, 0, 3, 2, 1, 0, 10, 7, 1, 5, 0, 32, 1, 154, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 147 #[test] fn c21_l147_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 127, 0, 3, 2, 1, 0, 10, 7, 1, 5, 0, 1, 33, 0, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 151 #[test] fn c22_l151_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 127, 0, 3, 2, 1, 0, 10, 11, 1, 9, 0, 67, 0, 0, 0, 0, 33, 0, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 155 #[test] fn c23_l155_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 125, 0, 3, 2, 1, 0, 10, 15, 1, 13, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 159 #[test] fn c24_l159_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 2, 124, 126, 0, 3, 2, 1, 0, 10, 15, 1, 13, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 33, 1, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 167 #[test] fn c25_l167_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 10, 1, 8, 2, 1, 127, 1, 126, 32, 3, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 171 #[test] fn c26_l171_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 13, 1, 11, 2, 1, 127, 1, 126, 32, 247, 164, 234, 6, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 176 #[test] fn c27_l176_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 2, 127, 126, 0, 3, 2, 1, 0, 10, 6, 1, 4, 0, 32, 2, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 180 #[test] fn c28_l180_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 14, 1, 12, 2, 1, 127, 1, 126, 32, 247, 242, 206, 212, 2, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 185 #[test] fn c29_l185_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 127, 0, 3, 2, 1, 0, 10, 10, 1, 8, 2, 1, 127, 1, 126, 32, 3, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 189 #[test] fn c30_l189_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 126, 0, 3, 2, 1, 0, 10, 13, 1, 11, 2, 1, 127, 1, 126, 32, 247, 168, 153, 102, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 194 #[test] fn c31_l194_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 125, 0, 3, 2, 1, 0, 10, 13, 1, 11, 1, 1, 127, 67, 0, 0, 0, 0, 33, 1, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 198 #[test] fn c32_l198_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 2, 126, 127, 0, 3, 2, 1, 0, 10, 13, 1, 11, 1, 1, 125, 67, 0, 0, 0, 0, 33, 1, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } // Line 202 #[test] fn c33_l202_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 126, 0, 3, 2, 1, 0, 10, 12, 1, 10, 2, 1, 124, 1, 126, 66, 0, 33, 1, 11]; let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new()); assert!(module.is_err(), "WASM should not compile as is invalid"); } #[test] fn test_module_1() { let mut instance = create_module_1(); // We group the calls together start_module_1(&mut instance); c1_l68_action_invoke(&mut instance); c2_l69_action_invoke(&mut instance); c3_l70_action_invoke(&mut instance); c4_l71_action_invoke(&mut instance); c5_l73_action_invoke(&mut instance); c6_l74_action_invoke(&mut instance); c7_l75_action_invoke(&mut instance); c8_l76_action_invoke(&mut instance); c9_l79_action_invoke(&mut instance); c10_l85_action_invoke(&mut instance); }