v8/test/mjsunit/wasm/exceptions-utils.js
Thibaud Michaud 27a517b892 [wasm][eh] Add WebAssembly.Exception.getArg()
Also introduce a separate error type for WebAssembly.Exception,
since the properties should not be added to RuntimeError.

R=jkummerow@chromium.org

Bug: v8:11992
Change-Id: I8f4ae0da9a95184366e07dc43e58a5a9ff4382ae
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3055304
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76061}
2021-08-03 14:25:50 +00:00

29 lines
994 B
JavaScript

// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// This file is intended to be loaded by other tests to provide utility methods
// requiring natives syntax (and hence not suited for the mjsunit.js file).
function assertWasmThrows(instance, runtime_id, values, code) {
try {
if (typeof code === 'function') {
code();
} else {
eval(code);
}
} catch (e) {
assertInstanceof(e, WebAssembly.Exception);
var e_runtime_id = %GetWasmExceptionTagId(e, instance);
assertTrue(Number.isInteger(e_runtime_id));
assertEquals(e_runtime_id, runtime_id);
var e_values = %GetWasmExceptionValues(e);
assertArrayEquals(values, e_values);
return; // Success.
}
throw new MjsUnitAssertionError('Did not throw expected <' + runtime_id +
'> with values: ' + values);
}