use indoc!

This commit is contained in:
NikVolf
2019-01-27 12:14:14 +03:00
parent 5b2cd9c4c6
commit 38e0f254b0
3 changed files with 79 additions and 80 deletions

View File

@ -16,6 +16,7 @@ byteorder = { version = "1", default-features = false }
tempdir = "0.3" tempdir = "0.3"
wabt = "0.2" wabt = "0.2"
diff = "0.1.11" diff = "0.1.11"
indoc = "0.3"
[features] [features]
default = ["std"] default = ["std"]

View File

@ -792,15 +792,13 @@ mod tests {
#[test] #[test]
fn smoky() { fn smoky() {
let sample = load_sample(r#" let sample = load_sample(indoc!(r#"
(module (module
(type (func)) (type (func))
(func (type 0)) (func (type 0))
(memory 0 1) (memory 0 1)
(export "simple" (func 0)) (export "simple" (func 0)))"#
) ));
"#
);
assert_eq!(sample.types.len(), 1); assert_eq!(sample.types.len(), 1);
assert_eq!(sample.funcs.len(), 1); assert_eq!(sample.funcs.len(), 1);
@ -814,26 +812,26 @@ mod tests {
#[test] #[test]
fn table() { fn table() {
let mut sample = load_sample(r#" let mut sample = load_sample(indoc!(r#"
(module (module
(import "env" "foo" (func $foo)) (import "env" "foo" (func $foo))
(func (param i32) (func (param i32)
get_local 0 get_local 0
i32.const 0 i32.const 0
call $i32.add call $i32.add
drop drop
) )
(func $i32.add (export "i32.add") (param i32 i32) (result i32) (func $i32.add (export "i32.add") (param i32 i32) (result i32)
get_local 0 get_local 0
get_local 1 get_local 1
i32.add i32.add
) )
(table 10 anyfunc) (table 10 anyfunc)
;; Refer all types of functions: imported, defined not exported and defined exported. ;; Refer all types of functions: imported, defined not exported and defined exported.
(elem (i32.const 0) 0 1 2) (elem (i32.const 0) 0 1 2)
)"# )"#
); ));
{ {
let element_func = &sample.elements[0].value[1]; let element_func = &sample.elements[0].value[1];
@ -864,23 +862,23 @@ mod tests {
#[test] #[test]
fn new_import() { fn new_import() {
let mut sample = load_sample(r#" let mut sample = load_sample(indoc!(r#"
(module (module
(type (;0;) (func)) (type (;0;) (func))
(type (;1;) (func (param i32 i32) (result i32))) (type (;1;) (func (param i32 i32) (result i32)))
(import "env" "foo" (func (type 1))) (import "env" "foo" (func (type 1)))
(func (param i32) (func (param i32)
get_local 0 get_local 0
i32.const 0 i32.const 0
call 0 call 0
drop drop
) )
(func (type 0) (func (type 0)
i32.const 0 i32.const 0
call 1 call 1
) )
)"# )"#
); ));
{ {
let type_ref_0 = sample.types.clone_ref(0); let type_ref_0 = sample.types.clone_ref(0);
@ -922,39 +920,38 @@ mod tests {
#[test] #[test]
fn simple_opt() { fn simple_opt() {
let mut sample = load_sample(r#" let mut sample = load_sample(indoc!(r#"
(module (module
(type (;0;) (func)) (type (;0;) (func))
(type (;1;) (func (param i32 i32) (result i32))) (type (;1;) (func (param i32 i32) (result i32)))
(type (;2;) (func (param i32 i32) (result i32))) (type (;2;) (func (param i32 i32) (result i32)))
(type (;3;) (func (param i32 i32) (result i32))) (type (;3;) (func (param i32 i32) (result i32)))
(import "env" "foo" (func (type 1))) (import "env" "foo" (func (type 1)))
(import "env" "foo2" (func (type 2))) (import "env" "foo2" (func (type 2)))
(import "env" "foo3" (func (type 3))) (import "env" "foo3" (func (type 3)))
(func (type 0) (func (type 0)
i32.const 1 i32.const 1
i32.const 1 i32.const 1
call 0 call 0
drop drop
) )
(func (type 0) (func (type 0)
i32.const 2 i32.const 2
i32.const 2 i32.const 2
call 1 call 1
drop drop
) )
(func (type 0) (func (type 0)
i32.const 3 i32.const 3
i32.const 3 i32.const 3
call 2 call 2
drop drop
) )
(func (type 0) (func (type 0)
call 3 call 3
) )
)"#
)"# ));
);
validate_sample(&sample); validate_sample(&sample);

View File

@ -7,8 +7,9 @@ extern crate alloc;
extern crate byteorder; extern crate byteorder;
extern crate parity_wasm; extern crate parity_wasm;
#[macro_use] #[macro_use] extern crate log;
extern crate log; #[cfg(test)] #[macro_use] extern crate indoc;
pub mod rules; pub mod rules;