2018-12-10 09:14:30 +00:00
|
|
|
// 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) {
|
2021-08-03 11:53:48 +00:00
|
|
|
assertInstanceof(e, WebAssembly.Exception);
|
2021-07-29 11:09:02 +00:00
|
|
|
var e_runtime_id = %GetWasmExceptionTagId(e, instance);
|
2018-12-10 09:14:30 +00:00
|
|
|
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);
|
|
|
|
}
|