Added token spectests

This commit is contained in:
Syrus Akbary 2018-11-13 17:41:29 -08:00
parent c5c033c02b
commit fd8feedb51
5 changed files with 46 additions and 2 deletions

View File

@ -93,7 +93,7 @@ This spectests are currently covered:
- store_retval.wast ✅
- switch.wast ✅
- tee_local.wast ✅
- token.wast
- token.wast
- traps.wast ✅
- type.wast ✅
- typecheck.wast ✅

10
spectests/token.wast Normal file
View File

@ -0,0 +1,10 @@
;; Test tokenization
(assert_malformed
(module quote "(func (drop (i32.const0)))")
"unknown operator"
)
(assert_malformed
(module quote "(func br 0drop)")
"unknown operator"
)

View File

@ -13,7 +13,7 @@ static ENV_VAR: &str = "WASM_GENERATE_SPECTESTS";
static BANNER: &str = "// 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.\n";
const TESTS: [&str; 55] = [
const TESTS: [&str; 56] = [
"spectests/address.wast",
"spectests/align.wast",
"spectests/binary.wast",
@ -67,6 +67,7 @@ const TESTS: [&str; 55] = [
"spectests/store_retval.wast",
"spectests/switch.wast",
"spectests/tee_local.wast",
"spectests/token.wast",
"spectests/traps.wast",
"spectests/typecheck.wast",
"spectests/types.wast",

View File

@ -68,6 +68,7 @@ mod start;
mod store_retval;
mod switch;
mod tee_local;
mod token;
mod traps;
mod typecheck;
mod types;

32
src/spectests/token.rs Normal file
View File

@ -0,0 +1,32 @@
// 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/token.wast
#![allow(
warnings,
dead_code
)]
use std::panic;
use wabt::wat2wasm;
use crate::webassembly::{instantiate, compile, ImportObject, ResultObject, Instance, Export};
use super::_common::{
spectest_importobject,
NaNCheck,
};
// Line 4
#[test]
fn c0_l4_assert_malformed() {
let wasm_binary = [40, 102, 117, 110, 99, 32, 40, 100, 114, 111, 112, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 48, 41, 41, 41];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is malformed");
}
// Line 8
#[test]
fn c1_l8_assert_malformed() {
let wasm_binary = [40, 102, 117, 110, 99, 32, 98, 114, 32, 48, 100, 114, 111, 112, 41];
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), "WASM should not compile as is malformed");
}