11cb0ef41Sopenharmony_ci// META: global=window,dedicatedworker,jsshell 21cb0ef41Sopenharmony_ci// META: script=/wasm/jsapi/assertions.js 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_cifunction addxy(x, y) { 51cb0ef41Sopenharmony_ci return x + y 61cb0ef41Sopenharmony_ci} 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_citest(() => { 91cb0ef41Sopenharmony_ci var fun = new WebAssembly.Function({parameters: ["i32", "i32"], results: ["i32"]}, addxy); 101cb0ef41Sopenharmony_ci assert_equals(fun(1, 2), 3) 111cb0ef41Sopenharmony_ci}, "test calling function") 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_citest(() => { 141cb0ef41Sopenharmony_ci var fun = new WebAssembly.Function({parameters: ["i32", "i32"], results: ["i32"]}, addxy); 151cb0ef41Sopenharmony_ci assert_throws_js(TypeError, () => new fun(1, 2)); 161cb0ef41Sopenharmony_ci}, "test constructing function"); 17