Added f32/f64 br_if tests

This commit is contained in:
Syrus Akbary 2018-10-19 01:31:31 +02:00
parent a932fef217
commit 0e50e09fc6
2 changed files with 30 additions and 2 deletions

View File

@ -325,8 +325,8 @@
(assert_return (invoke "type-i32-value") (i32.const 1))
(assert_return (invoke "type-i64-value") (i64.const 2))
;; (assert_return (invoke "type-f32-value") (f32.const 3))
;; (assert_return (invoke "type-f64-value") (f64.const 4))
(assert_return (invoke "type-f32-value") (f32.const 3))
(assert_return (invoke "type-f64-value") (f64.const 4))
(assert_return (invoke "as-block-first" (i32.const 0)) (i32.const 2))
(assert_return (invoke "as-block-first" (i32.const 1)) (i32.const 3))

View File

@ -633,6 +633,34 @@ fn l327_assert_return_invoke() {
assert_eq!(result, 2 as i64);
}
// Line 328
#[test]
fn l328_assert_return_invoke() {
let ResultObject { mut instance, module } = create_module_1();
let func_index = match module.info.exports.get("type-f32-value") {
Some(&Export::Function(index)) => index,
_ => panic!("Function not found"),
};
let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(instance, func_index);
let vm_context = instance.generate_context();
let result = invoke_fn(&vm_context);
assert_eq!(result, 3.0 as f32);
}
// Line 329
#[test]
fn l329_assert_return_invoke() {
let ResultObject { mut instance, module } = create_module_1();
let func_index = match module.info.exports.get("type-f64-value") {
Some(&Export::Function(index)) => index,
_ => panic!("Function not found"),
};
let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(instance, func_index);
let vm_context = instance.generate_context();
let result = invoke_fn(&vm_context);
assert_eq!(result, 4.0 as f64);
}
// Line 331
#[test]
fn l331_assert_return_invoke() {