From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../wasm/spec/exception-handling/throw.wast.js | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 js/src/jit-test/tests/wasm/spec/exception-handling/throw.wast.js (limited to 'js/src/jit-test/tests/wasm/spec/exception-handling/throw.wast.js') diff --git a/js/src/jit-test/tests/wasm/spec/exception-handling/throw.wast.js b/js/src/jit-test/tests/wasm/spec/exception-handling/throw.wast.js new file mode 100644 index 0000000000..cb0baf0d4c --- /dev/null +++ b/js/src/jit-test/tests/wasm/spec/exception-handling/throw.wast.js @@ -0,0 +1,87 @@ +/* Copyright 2021 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ./test/core/throw.wast + +// ./test/core/throw.wast:3 +let $0 = instantiate(`(module + (tag $$e0) + (tag $$e-i32 (param i32)) + (tag $$e-f32 (param f32)) + (tag $$e-i64 (param i64)) + (tag $$e-f64 (param f64)) + (tag $$e-i32-i32 (param i32 i32)) + + (func $$throw-if (export "throw-if") (param i32) (result i32) + (local.get 0) + (i32.const 0) (if (i32.ne) (then (throw $$e0))) + (i32.const 0) + ) + + (func (export "throw-param-f32") (param f32) (local.get 0) (throw $$e-f32)) + + (func (export "throw-param-i64") (param i64) (local.get 0) (throw $$e-i64)) + + (func (export "throw-param-f64") (param f64) (local.get 0) (throw $$e-f64)) + + (func $$throw-1-2 (i32.const 1) (i32.const 2) (throw $$e-i32-i32)) + (func (export "test-throw-1-2") + (try + (do (call $$throw-1-2)) + (catch $$e-i32-i32 + (i32.const 2) + (if (i32.ne) (then (unreachable))) + (i32.const 1) + (if (i32.ne) (then (unreachable))) + ) + ) + ) +)`); + +// ./test/core/throw.wast:37 +assert_return(() => invoke($0, `throw-if`, [0]), [value("i32", 0)]); + +// ./test/core/throw.wast:38 +assert_exception(() => invoke($0, `throw-if`, [10])); + +// ./test/core/throw.wast:39 +assert_exception(() => invoke($0, `throw-if`, [-1])); + +// ./test/core/throw.wast:41 +assert_exception(() => invoke($0, `throw-param-f32`, [value("f32", 5)])); + +// ./test/core/throw.wast:42 +assert_exception(() => invoke($0, `throw-param-i64`, [5n])); + +// ./test/core/throw.wast:43 +assert_exception(() => invoke($0, `throw-param-f64`, [value("f64", 5)])); + +// ./test/core/throw.wast:45 +assert_return(() => invoke($0, `test-throw-1-2`, []), []); + +// ./test/core/throw.wast:47 +assert_invalid(() => instantiate(`(module (func (throw 0)))`), `unknown tag 0`); + +// ./test/core/throw.wast:48 +assert_invalid( + () => instantiate(`(module (tag (param i32)) (func (throw 0)))`), + `type mismatch: instruction requires [i32] but stack has []`, +); + +// ./test/core/throw.wast:50 +assert_invalid( + () => instantiate(`(module (tag (param i32)) (func (i64.const 5) (throw 0)))`), + `type mismatch: instruction requires [i32] but stack has [i64]`, +); -- cgit v1.2.3