Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: test/unittests/wasm/ast-decoder-unittest.cc

Issue 2222193004: [WASM] Exception handling prototype. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addresses comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/wasm/ast-decoder-unittest.cc
diff --git a/test/unittests/wasm/ast-decoder-unittest.cc b/test/unittests/wasm/ast-decoder-unittest.cc
index 0a9ce865edba94e653b8020227ce25a7f0495d0a..621040ae17206dca8475ecf0542eba1c07741738 100644
--- a/test/unittests/wasm/ast-decoder-unittest.cc
+++ b/test/unittests/wasm/ast-decoder-unittest.cc
@@ -1829,6 +1829,91 @@ TEST_F(AstDecoderTest, Select_TypeCheck) {
WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_I64V_1(0)));
}
+TEST_F(AstDecoderTest, Throw) {
+ FLAG_wasm_eh_prototype = true;
+ EXPECT_VERIFIES_INLINE(sigs.v_i(), WASM_GET_LOCAL(0), kExprThrow);
+
+ // TODO(jpp): can't throw d, f, or l.
+ EXPECT_VERIFIES_INLINE(sigs.i_d(), WASM_GET_LOCAL(0), kExprThrow,
+ WASM_I32V(0));
+ EXPECT_VERIFIES_INLINE(sigs.i_f(), WASM_GET_LOCAL(0), kExprThrow,
+ WASM_I32V(0));
+ EXPECT_VERIFIES_INLINE(sigs.l_l(), WASM_GET_LOCAL(0), kExprThrow,
+ WASM_I64V(0));
+}
+
+#define WASM_CATCH(local) kExprCatch, static_cast<byte>(local)
+TEST_F(AstDecoderTest, TryCatch) {
+ FLAG_wasm_eh_prototype = true;
+ EXPECT_VERIFIES_INLINE(sigs.v_i(), kExprTryCatch, WASM_CATCH(0), kExprEnd);
+
+ // Missing catch.
+ EXPECT_FAILURE_INLINE(sigs.v_v(), kExprTryCatch, kExprEnd);
+
+ // Missing end.
+ EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatch, WASM_CATCH(0));
+
+ // Double catch.
+ EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatch, WASM_CATCH(0), WASM_CATCH(0),
+ kExprEnd);
+
+ // Unexpected finally.
+ EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatch, WASM_CATCH(0), kExprFinally,
+ kExprEnd);
+}
+
+TEST_F(AstDecoderTest, TryFinally) {
+ FLAG_wasm_eh_prototype = true;
+ EXPECT_VERIFIES_INLINE(sigs.v_v(), kExprTryFinally, kExprFinally, kExprEnd);
+
+ // Mising finally.
+ EXPECT_FAILURE_INLINE(sigs.v_v(), kExprTryFinally, kExprEnd);
+
+ // Missing end.
+ EXPECT_FAILURE_INLINE(sigs.v_v(), kExprTryFinally, kExprFinally);
+
+ // Double finally.
+ EXPECT_FAILURE_INLINE(sigs.v_v(), kExprTryFinally, kExprFinally, kExprFinally,
+ kExprEnd);
+
+ // Unexpected catch.
+ EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatch, WASM_CATCH(0), kExprFinally,
+ kExprEnd);
+}
+
+TEST_F(AstDecoderTest, TryCatchFinally) {
+ FLAG_wasm_eh_prototype = true;
+ EXPECT_VERIFIES_INLINE(sigs.v_i(), kExprTryCatchFinally, WASM_CATCH(0),
+ kExprFinally, kExprEnd);
+
+ // Missing catch.
+ EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, kExprFinally,
+ kExprEnd);
+
+ // Double catch.
+ EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, WASM_CATCH(0),
+ WASM_CATCH(0), kExprFinally, kExprEnd);
+
+ // Missing finally.
+ EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, WASM_CATCH(0),
+ kExprEnd);
+
+ // Double finally.
+ EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, WASM_CATCH(0),
+ kExprFinally, kExprFinally, kExprEnd);
+
+ // Finally before catch.
+ EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, kExprFinally,
+ WASM_CATCH(0), kExprEnd);
+
+ // Missing both try and finally.
+ EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, kExprEnd);
+
+ // Missing end.
+ EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, WASM_CATCH(0),
+ kExprFinally);
+}
+
class WasmOpcodeLengthTest : public TestWithZone {
public:
WasmOpcodeLengthTest() : TestWithZone() {}
@@ -1856,6 +1941,12 @@ TEST_F(WasmOpcodeLengthTest, Statements) {
EXPECT_LENGTH(1, kExprSelect);
EXPECT_LENGTH(3, kExprBr);
EXPECT_LENGTH(3, kExprBrIf);
+ EXPECT_LENGTH(1, kExprThrow);
+ EXPECT_LENGTH(1, kExprTryCatch);
+ EXPECT_LENGTH(1, kExprTryFinally);
+ EXPECT_LENGTH(1, kExprTryCatchFinally);
+ EXPECT_LENGTH(2, kExprCatch);
+ EXPECT_LENGTH(1, kExprFinally);
}
TEST_F(WasmOpcodeLengthTest, MiscExpressions) {
@@ -2097,6 +2188,13 @@ TEST_F(WasmOpcodeArityTest, Control) {
EXPECT_ARITY(0, kExprReturn, ARITY_0);
EXPECT_ARITY(1, kExprReturn, ARITY_1);
}
+
+ EXPECT_ARITY(0, kExprThrow);
+ EXPECT_ARITY(0, kExprTryCatch);
+ EXPECT_ARITY(0, kExprTryFinally);
+ EXPECT_ARITY(0, kExprTryCatchFinally);
+ EXPECT_ARITY(1, kExprCatch, 2);
+ EXPECT_ARITY(0, kExprFinally);
}
TEST_F(WasmOpcodeArityTest, Misc) {
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698