2018-10-19 11:31:02 +02:00
|
|
|
// Rust test file autogenerated with cargo build (src/build_spectests.rs).
|
|
|
|
// Please do NOT modify it by hand, as it will be reseted on next build.
|
|
|
|
// Test based on spectests/types.wast
|
2018-10-19 01:29:12 +02:00
|
|
|
use crate::webassembly::{instantiate, compile, ImportObject, ResultObject, VmCtx, Export};
|
2018-10-23 15:43:35 +02:00
|
|
|
use super::_common::spectest_importobject;
|
2018-10-19 01:29:12 +02:00
|
|
|
use wabt::wat2wasm;
|
|
|
|
|
|
|
|
|
|
|
|
// Line 3
|
|
|
|
fn create_module_1() -> ResultObject {
|
|
|
|
let module_str = "(module
|
|
|
|
(type (;0;) (func))
|
|
|
|
(type (;1;) (func))
|
|
|
|
(type (;2;) (func (param i32)))
|
|
|
|
(type (;3;) (func (param i32)))
|
|
|
|
(type (;4;) (func (result i32)))
|
|
|
|
(type (;5;) (func (param i32) (result i32)))
|
|
|
|
(type (;6;) (func (param i32) (result i32)))
|
|
|
|
(type (;7;) (func (param f32 f64)))
|
|
|
|
(type (;8;) (func (param f32 f64)))
|
|
|
|
(type (;9;) (func (param f32 f64)))
|
|
|
|
(type (;10;) (func (param f32 f64)))
|
|
|
|
(type (;11;) (func (param f32 f64)))
|
|
|
|
(type (;12;) (func (param f32 f64 i32 f64 i32 i32)))
|
|
|
|
(type (;13;) (func (param f32 f64 i32))))
|
|
|
|
";
|
|
|
|
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
2018-10-23 15:43:35 +02:00
|
|
|
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
2018-10-19 01:29:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Line 44
|
|
|
|
#[test]
|
|
|
|
fn l44_assert_malformed() {
|
|
|
|
let wasm_binary = [40, 116, 121, 112, 101, 32, 40, 102, 117, 110, 99, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 41, 41];
|
|
|
|
let compilation = compile(wasm_binary.to_vec());
|
|
|
|
assert!(compilation.is_err(), "WASM should not compile as is malformed");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 48
|
|
|
|
#[test]
|
|
|
|
fn l48_assert_malformed() {
|
|
|
|
let wasm_binary = [40, 116, 121, 112, 101, 32, 40, 102, 117, 110, 99, 32, 40, 114, 101, 115, 117, 108, 116, 32, 36, 120, 32, 105, 51, 50, 41, 41, 41];
|
|
|
|
let compilation = compile(wasm_binary.to_vec());
|
|
|
|
assert!(compilation.is_err(), "WASM should not compile as is malformed");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 53
|
|
|
|
#[test]
|
|
|
|
fn l53_assert_invalid() {
|
|
|
|
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 0, 2, 127, 127];
|
|
|
|
let compilation = compile(wasm_binary.to_vec());
|
|
|
|
assert!(compilation.is_err(), "WASM should not compile as is invalid");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 57
|
|
|
|
#[test]
|
|
|
|
fn l57_assert_invalid() {
|
|
|
|
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 0, 2, 127, 127];
|
|
|
|
let compilation = compile(wasm_binary.to_vec());
|
|
|
|
assert!(compilation.is_err(), "WASM should not compile as is invalid");
|
|
|
|
}
|