(types_str, types, values)
| 152 | })(); |
| 153 | |
| 154 | function TestCatchJS(types_str, types, values) { |
| 155 | // Create a JS exception, catch it in wasm and check the unpacked value(s). |
| 156 | let builder = new WasmModuleBuilder(); |
| 157 | let js_tag = new WebAssembly.Tag({parameters: types_str}); |
| 158 | let js_func_index = builder.addImport('m', 'js_func', kSig_v_v); |
| 159 | let sig1 = makeSig(types, []); |
| 160 | let sig2 = makeSig([], types); |
| 161 | let js_tag_index = builder.addImportedTag("m", "js_tag", sig1); |
| 162 | let tag_index = builder.addTag(sig1); |
| 163 | let return_type = builder.addType(sig2); |
| 164 | builder.addExportOfKind("wasm_tag", kExternalTag, tag_index); |
| 165 | builder.addFunction("catch", sig2) |
| 166 | .addBody([ |
| 167 | kExprTry, return_type, |
| 168 | kExprCallFunction, js_func_index, |
| 169 | kExprUnreachable, |
| 170 | kExprCatch, js_tag_index, |
| 171 | kExprCatch, tag_index, |
| 172 | kExprEnd |
| 173 | ]).exportFunc(); |
| 174 | let exception; |
| 175 | function js_func() { |
| 176 | throw exception; |
| 177 | } |
| 178 | let expected = values.length == 1 ? values[0] : values; |
| 179 | let instance = builder.instantiate({m: {js_func, js_tag}}); |
| 180 | exception = new WebAssembly.Exception(js_tag, values); |
| 181 | assertEquals(expected, instance.exports.catch()); |
| 182 | exception = new WebAssembly.Exception(instance.exports.wasm_tag, values); |
| 183 | assertEquals(expected, instance.exports.catch()); |
| 184 | } |
| 185 | |
| 186 | (function TestCatchJSExceptionWithPayload() { |
| 187 | print(arguments.callee.name); |
no test coverage detected
searching dependent graphs…