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

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

Issue 1417053004: [Interpreter] Add conditional expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_prologue
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
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 aa77d417aacd46cac67744461e7b6b7d74a758fb..dccd05afd4c3668c7f2996f47b9068f653e2870b 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -3492,6 +3492,52 @@ TEST(IllegalRedeclaration) {
}
}
+
+TEST(Conditional) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ ExpectedSnippet<int> snippets[] = {
+ {"return 1 ? 2 : 3;",
+ 0,
+ 1,
+ 12,
+ {
+ B(LdaSmi8), U8(1), //
+ B(ToBoolean), //
+ B(JumpIfFalse), U8(6), //
+ B(LdaSmi8), U8(2), //
+ B(Jump), U8(4), //
+ B(LdaSmi8), U8(3), //
+ B(Return), //
+ }},
+ {"return 1 ? 2 ? 3 : 4 : 5;",
+ 0,
+ 1,
+ 21,
+ {
+ B(LdaSmi8), U8(1), //
+ B(ToBoolean), //
+ B(JumpIfFalse), U8(15), //
+ B(LdaSmi8), U8(2), //
+ B(ToBoolean), //
+ B(JumpIfFalse), U8(6), //
+ B(LdaSmi8), U8(3), //
+ B(Jump), U8(4), //
+ B(LdaSmi8), U8(4), //
+ B(Jump), U8(4), //
+ B(LdaSmi8), U8(5), //
+ B(Return), //
+ }},
+ };
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
+ }
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698