2018-10-28 13:59:06 +01: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/switch.wast
|
|
|
|
#![allow(
|
|
|
|
warnings,
|
|
|
|
dead_code
|
|
|
|
)]
|
|
|
|
use crate::webassembly::{instantiate, compile, ImportObject, ResultObject, VmCtx, Export};
|
|
|
|
use super::_common::spectest_importobject;
|
|
|
|
use wabt::wat2wasm;
|
|
|
|
|
|
|
|
|
|
|
|
// Line 1
|
|
|
|
fn create_module_1() -> ResultObject {
|
|
|
|
let module_str = "(module
|
|
|
|
(type (;0;) (func (param i32) (result i32)))
|
|
|
|
(type (;1;) (func (param i64) (result i64)))
|
|
|
|
(type (;2;) (func (result i32)))
|
|
|
|
(func (;0;) (type 0) (param i32) (result i32)
|
|
|
|
(local i32)
|
|
|
|
i32.const 100
|
|
|
|
set_local 1
|
|
|
|
block ;; label = @1
|
|
|
|
block ;; label = @2
|
|
|
|
block ;; label = @3
|
|
|
|
block ;; label = @4
|
|
|
|
block ;; label = @5
|
|
|
|
block ;; label = @6
|
|
|
|
block ;; label = @7
|
|
|
|
block ;; label = @8
|
|
|
|
block ;; label = @9
|
|
|
|
block ;; label = @10
|
|
|
|
get_local 0
|
|
|
|
br_table 0 (;@10;) 1 (;@9;) 2 (;@8;) 3 (;@7;) 4 (;@6;) 5 (;@5;) 6 (;@4;) 8 (;@2;) 7 (;@3;)
|
|
|
|
end
|
|
|
|
get_local 0
|
|
|
|
return
|
|
|
|
end
|
|
|
|
nop
|
|
|
|
end
|
|
|
|
end
|
|
|
|
i32.const 0
|
|
|
|
get_local 0
|
|
|
|
i32.sub
|
|
|
|
set_local 1
|
|
|
|
br 5 (;@1;)
|
|
|
|
end
|
|
|
|
br 4 (;@1;)
|
|
|
|
end
|
|
|
|
i32.const 101
|
|
|
|
set_local 1
|
|
|
|
br 3 (;@1;)
|
|
|
|
end
|
|
|
|
i32.const 101
|
|
|
|
set_local 1
|
|
|
|
end
|
|
|
|
i32.const 102
|
|
|
|
set_local 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
get_local 1
|
|
|
|
return)
|
|
|
|
(func (;1;) (type 1) (param i64) (result i64)
|
|
|
|
(local i64)
|
|
|
|
i64.const 100
|
|
|
|
set_local 1
|
|
|
|
block (result i64) ;; label = @1
|
|
|
|
block ;; label = @2
|
|
|
|
block ;; label = @3
|
|
|
|
block ;; label = @4
|
|
|
|
block ;; label = @5
|
|
|
|
block ;; label = @6
|
|
|
|
block ;; label = @7
|
|
|
|
block ;; label = @8
|
|
|
|
block ;; label = @9
|
|
|
|
block ;; label = @10
|
|
|
|
get_local 0
|
|
|
|
i32.wrap/i64
|
|
|
|
br_table 0 (;@10;) 1 (;@9;) 2 (;@8;) 3 (;@7;) 6 (;@4;) 5 (;@5;) 4 (;@6;) 8 (;@2;) 7 (;@3;)
|
|
|
|
end
|
|
|
|
get_local 0
|
|
|
|
return
|
|
|
|
end
|
|
|
|
nop
|
|
|
|
end
|
|
|
|
end
|
|
|
|
i64.const 0
|
|
|
|
get_local 0
|
|
|
|
i64.sub
|
|
|
|
br 5 (;@1;)
|
|
|
|
end
|
|
|
|
i64.const 101
|
|
|
|
set_local 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
get_local 1
|
|
|
|
br 1 (;@1;)
|
|
|
|
end
|
|
|
|
i64.const -5
|
|
|
|
end
|
|
|
|
return)
|
|
|
|
(func (;2;) (type 0) (param i32) (result i32)
|
|
|
|
block (result i32) ;; label = @1
|
|
|
|
i32.const 10
|
|
|
|
block (result i32) ;; label = @2
|
|
|
|
i32.const 100
|
|
|
|
block (result i32) ;; label = @3
|
|
|
|
i32.const 1000
|
|
|
|
block (result i32) ;; label = @4
|
|
|
|
i32.const 2
|
|
|
|
get_local 0
|
|
|
|
i32.mul
|
|
|
|
i32.const 3
|
|
|
|
get_local 0
|
|
|
|
i32.and
|
|
|
|
br_table 1 (;@3;) 2 (;@2;) 3 (;@1;) 0 (;@4;)
|
|
|
|
end
|
|
|
|
i32.add
|
|
|
|
end
|
|
|
|
i32.add
|
|
|
|
end
|
|
|
|
i32.add
|
|
|
|
end
|
|
|
|
return)
|
|
|
|
(func (;3;) (type 2) (result i32)
|
|
|
|
block ;; label = @1
|
|
|
|
i32.const 0
|
|
|
|
br_table 0 (;@1;)
|
|
|
|
end
|
|
|
|
i32.const 1)
|
|
|
|
(export \"stmt\" (func 0))
|
|
|
|
(export \"expr\" (func 1))
|
|
|
|
(export \"arg\" (func 2))
|
|
|
|
(export \"corner\" (func 3)))
|
|
|
|
";
|
|
|
|
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
|
|
|
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 120
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l120_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l120_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("stmt") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(0 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 0 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 121
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l121_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l121_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("stmt") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(1 as i32, &vm_context);
|
|
|
|
assert_eq!(result, -1 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 122
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l122_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l122_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("stmt") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(2 as i32, &vm_context);
|
|
|
|
assert_eq!(result, -2 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 123
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l123_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l123_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("stmt") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(3 as i32, &vm_context);
|
|
|
|
assert_eq!(result, -3 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 124
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l124_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l124_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("stmt") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(4 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 100 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 125
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l125_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l125_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("stmt") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(5 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 101 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 126
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l126_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l126_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("stmt") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(6 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 102 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 127
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l127_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l127_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("stmt") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(7 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 100 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 128
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l128_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l128_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("stmt") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(-10 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 102 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 130
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l130_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l130_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("expr") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(0 as i64, &vm_context);
|
|
|
|
assert_eq!(result, 0 as i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 131
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l131_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l131_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("expr") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(1 as i64, &vm_context);
|
|
|
|
assert_eq!(result, -1 as i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 132
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l132_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l132_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("expr") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(2 as i64, &vm_context);
|
|
|
|
assert_eq!(result, -2 as i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 133
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l133_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l133_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("expr") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(3 as i64, &vm_context);
|
|
|
|
assert_eq!(result, -3 as i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 134
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l134_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l134_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("expr") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(6 as i64, &vm_context);
|
|
|
|
assert_eq!(result, 101 as i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 135
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l135_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l135_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("expr") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(7 as i64, &vm_context);
|
|
|
|
assert_eq!(result, -5 as i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 136
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l136_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l136_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("expr") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(-10 as i64, &vm_context);
|
|
|
|
assert_eq!(result, 100 as i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 138
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l138_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l138_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("arg") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(0 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 110 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 139
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l139_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l139_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("arg") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(1 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 12 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 140
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l140_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l140_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("arg") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(2 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 4 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 141
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l141_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l141_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("arg") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(3 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 1116 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 142
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l142_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l142_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("arg") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(4 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 118 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 143
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l143_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l143_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("arg") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(5 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 20 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 144
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l144_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l144_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("arg") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(6 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 12 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 145
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l145_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l145_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("arg") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(7 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 1124 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 146
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l146_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l146_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("arg") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(8 as i32, &vm_context);
|
|
|
|
assert_eq!(result, 126 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 148
|
2018-10-29 14:33:00 +01:00
|
|
|
fn l148_action_invoke(result_object: &ResultObject, vm_context: &VmCtx) {
|
|
|
|
println!("Executing function {}", "l148_action_invoke");
|
2018-10-28 13:59:06 +01:00
|
|
|
let func_index = match result_object.module.info.exports.get("corner") {
|
|
|
|
Some(&Export::Function(index)) => index,
|
|
|
|
_ => panic!("Function not found"),
|
|
|
|
};
|
|
|
|
let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index);
|
|
|
|
let result = invoke_fn(&vm_context);
|
|
|
|
assert_eq!(result, 1 as i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 150
|
|
|
|
#[test]
|
|
|
|
fn l150_assert_invalid() {
|
|
|
|
let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 14, 0, 3, 11];
|
|
|
|
let compilation = compile(wasm_binary.to_vec());
|
|
|
|
assert!(compilation.is_err(), "WASM should not compile as is invalid");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_module_1() {
|
|
|
|
let result_object = create_module_1();
|
|
|
|
let vm_context = result_object.instance.generate_context();
|
|
|
|
// We group the calls together
|
2018-10-29 14:33:00 +01:00
|
|
|
l120_action_invoke(&result_object, &vm_context);
|
|
|
|
l121_action_invoke(&result_object, &vm_context);
|
|
|
|
l122_action_invoke(&result_object, &vm_context);
|
|
|
|
l123_action_invoke(&result_object, &vm_context);
|
|
|
|
l124_action_invoke(&result_object, &vm_context);
|
|
|
|
l125_action_invoke(&result_object, &vm_context);
|
|
|
|
l126_action_invoke(&result_object, &vm_context);
|
|
|
|
l127_action_invoke(&result_object, &vm_context);
|
|
|
|
l128_action_invoke(&result_object, &vm_context);
|
|
|
|
l130_action_invoke(&result_object, &vm_context);
|
|
|
|
l131_action_invoke(&result_object, &vm_context);
|
|
|
|
l132_action_invoke(&result_object, &vm_context);
|
|
|
|
l133_action_invoke(&result_object, &vm_context);
|
|
|
|
l134_action_invoke(&result_object, &vm_context);
|
|
|
|
l135_action_invoke(&result_object, &vm_context);
|
|
|
|
l136_action_invoke(&result_object, &vm_context);
|
|
|
|
l138_action_invoke(&result_object, &vm_context);
|
|
|
|
l139_action_invoke(&result_object, &vm_context);
|
|
|
|
l140_action_invoke(&result_object, &vm_context);
|
|
|
|
l141_action_invoke(&result_object, &vm_context);
|
|
|
|
l142_action_invoke(&result_object, &vm_context);
|
|
|
|
l143_action_invoke(&result_object, &vm_context);
|
|
|
|
l144_action_invoke(&result_object, &vm_context);
|
|
|
|
l145_action_invoke(&result_object, &vm_context);
|
|
|
|
l146_action_invoke(&result_object, &vm_context);
|
|
|
|
l148_action_invoke(&result_object, &vm_context);
|
2018-10-28 13:59:06 +01:00
|
|
|
}
|