Skip to content

Commit

Permalink
Bump wabt's version to 0.4 and add two more test cases (#114)
Browse files Browse the repository at this point in the history
* bump wabt version to 0.4

It has some interface changes.

* bump up testsuite and add two more test cases

* use the same expect string
  • Loading branch information
Guanqun Lu authored and pepyakin committed Jul 30, 2018
1 parent 43b8d52 commit 5c86c1c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ nan-preserving-float = "0.1.0"

[dev-dependencies]
assert_matches = "1.1"
wabt = "0.3"
wabt = "0.4"
2 changes: 2 additions & 0 deletions tests/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ run_test!("call_indirect", wasm_call_indirect);
run_test!("comments", wasm_comments);
run_test!("const", wasm_const);
run_test!("conversions", wasm_conversions);
run_test!("custom", wasm_custom);
run_test!("custom_section", wasm_custom_section);
run_test!("data", wasm_data);
run_test!("elem", wasm_elem);
run_test!("endianness", wasm_endianness);
run_test!("exports", wasm_exports);
Expand Down
15 changes: 11 additions & 4 deletions tests/spec/run.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg(test)]

use std::fs::File;
use std::collections::HashMap;

use wabt::script::{self, Action, Command, CommandKind, ScriptParser, Value};
Expand Down Expand Up @@ -340,7 +341,13 @@ pub fn spec(name: &str) {
fn try_spec(name: &str) -> Result<(), Error> {
let mut spec_driver = SpecDriver::new();
let spec_script_path = format!("tests/spec/testsuite/{}.wast", name);
let mut parser = ScriptParser::from_file(spec_script_path).expect("Can't read spec script");

use std::io::Read;
let mut spec_source = Vec::new();
let mut spec_file = File::open(&spec_script_path).expect("Can't open file");
spec_file.read_to_end(&mut spec_source).expect("Can't read file");

let mut parser = ScriptParser::from_source_and_name(&spec_source, &format!("{}.wast", name)).expect("Can't read spec script");
let mut errors = vec![];

while let Some(Command { kind, line }) = parser.next()? {
Expand All @@ -364,7 +371,7 @@ fn try_spec(name: &str) -> Result<(), Error> {

match kind {
CommandKind::Module { name, module, .. } => {
load_module(&module.into_vec()?, &name, &mut spec_driver)
load_module(&module.into_vec(), &name, &mut spec_driver)
.expect("Failed to load module");
}
CommandKind::AssertReturn { action, expected } => {
Expand Down Expand Up @@ -446,14 +453,14 @@ fn try_spec(name: &str) -> Result<(), Error> {
CommandKind::AssertInvalid { module, .. }
| CommandKind::AssertMalformed { module, .. }
| CommandKind::AssertUnlinkable { module, .. } => {
let module_load = try_load(&module.into_vec()?, &mut spec_driver);
let module_load = try_load(&module.into_vec(), &mut spec_driver);
match module_load {
Ok(_) => panic!("Expected invalid module definition, got some module!"),
Err(_e) => {},
}
}
CommandKind::AssertUninstantiable { module, .. } => {
match try_load(&module.into_vec()?, &mut spec_driver) {
match try_load(&module.into_vec(), &mut spec_driver) {
Ok(_) => panic!("Expected error running start function at line {}", line),
Err(_e) => {},
}
Expand Down

0 comments on commit 5c86c1c

Please sign in to comment.