Skip to content

Commit

Permalink
parse testsuite script
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakov Zaytsev committed Sep 19, 2019
1 parent f1df903 commit e7a2f4b
Show file tree
Hide file tree
Showing 5 changed files with 1,126 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
129 changes: 129 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "wasm2llvm"
version = "0.1.0"
authors = ["Yakov Zaytsev <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
wabt = "0.9.0"
29 changes: 29 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
extern crate wabt;

#[cfg(test)]
mod tests {
use wabt::script::{ScriptParser, Command, CommandKind, Action, Value, Error};

#[test]
fn it_works() -> Result<(), Error> {
use std::fs;

let wast = fs::read_to_string("testsuite/i32.wast").unwrap();
let mut parser: ScriptParser = ScriptParser::from_str(&wast)?;
while let Some(Command { kind, .. }) = parser.next()? {
if let CommandKind::AssertReturn { action, expected } = kind {
if let Action::Invoke {
module,
field,
args
} = action {
println!("{} {:?} {:?}", field, args, expected);

break;
}
}
}

Ok(())
}
}
Loading

0 comments on commit e7a2f4b

Please sign in to comment.