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

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

Issue 1632213002: [Interpreter] Implement do expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 11 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
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 20a919691e8ebd82ee83a2e984764a349ef15045..17823340625c67ef6ac616771ae959fd034d0355 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -7549,6 +7549,68 @@ TEST(WideRegisters) {
}
}
+TEST(DoExpression) {
+ bool old_flag = FLAG_harmony_do_expressions;
+ FLAG_harmony_do_expressions = true;
+
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ ExpectedSnippet<const char*> snippets[] = {
+ {"var a = do { }; return a;",
+ 2 * kPointerSize,
+ 1,
+ 5,
+ {
+ B(Ldar), R(0), //
+ B(Star), R(1), //
+ B(Return) //
+ },
+ 0},
+ {"var a = do { var x = 100; }; return a;",
+ 3 * kPointerSize,
+ 1,
+ 10,
+ {
+ B(LdaSmi8), U8(100), //
+ B(Star), R(1), //
+ B(LdaUndefined), //
+ B(Star), R(0), //
+ B(Star), R(2), //
+ B(Return) //
+ },
+ 0},
+ {"while(true) { var a = 10; a = do { ++a; break; }; a = 20; }",
+ 2 * kPointerSize,
+ 1,
+ 24,
+ {
+ B(LdaSmi8), U8(10), //
+ B(Star), R(1), //
+ B(ToNumber), //
+ B(Inc), //
+ B(Star), R(1), //
+ B(Star), R(0), //
+ B(Jump), U8(12), //
+ B(Ldar), R(0), //
+ B(Star), R(1), //
+ B(LdaSmi8), U8(20), //
+ B(Star), R(1), //
+ B(Jump), U8(-20), //
+ B(LdaUndefined), //
+ B(Return), //
+ },
+ 0},
+ };
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
+ }
+ FLAG_harmony_do_expressions = old_flag;
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698