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

Unified Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1410863002: [Interpreter] Add support for Throw. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/interpreter/test-bytecode-generator.cc
diff --git a/test/cctest/interpreter/test-bytecode-generator.cc b/test/cctest/interpreter/test-bytecode-generator.cc
index 3614c111115be784a60a4606ab19b8c152786296..aeaa0a0afb5ba47ff2ee076e1b1c8b2e65adb151 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -2688,6 +2688,56 @@ TEST(TryFinally) {
}
+TEST(Throw) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ // TODO(rmcilroy): modify tests when we have real try catch support.
+ ExpectedSnippet<const char*> snippets[] = {
+ {"throw 1;",
+ 0,
+ 1,
+ 3,
+ {
+ B(LdaSmi8), U8(1), //
+ B(Throw), //
+ },
+ 0},
+ {"throw 'Error';",
+ 0,
+ 1,
+ 3,
+ {
+ B(LdaConstant), U8(0), //
+ B(Throw), //
+ },
+ 1,
+ {"Error"}},
+ {"if ('test') { throw 'Error'; };",
+ 0,
+ 1,
+ 10,
+ {
+ B(LdaConstant), U8(0), //
+ B(ToBoolean), //
+ B(JumpIfFalse), U8(5), //
+ B(LdaConstant), U8(1), //
+ B(Throw), //
+ B(LdaUndefined), //
+ B(Return), //
+ },
+ 2,
+ {"test", "Error"}},
+ };
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
+ }
+}
+
+
TEST(CallNew) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698