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

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

Issue 2793923002: [Interpreter] Optimize code of the form 'if (x === undefined)'. (Closed)
Patch Set: Rebase Created 3 years, 9 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 4acc5964c62c70739bb5d5645f96a57da5f58574..ffb41018703e58f47f0b2d9b7821180527dc5c62 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -1027,6 +1027,61 @@ TEST(CompareTypeOf) {
LoadGolden("CompareTypeOf.golden")));
}
+TEST(CompareNil) {
+ InitializedIgnitionHandleScope scope;
+ BytecodeExpectationsPrinter printer(CcTest::isolate());
+
+ const char* snippets[] = {
+ "var a = 1;\n"
+ "return a === null;\n",
+
+ "var a = undefined;\n"
+ "return undefined === a;\n",
+
+ "var a = undefined;\n"
+ "return undefined !== a;\n",
+
+ "var a = 2;\n"
+ "return a != null;\n",
+
+ "var a = undefined;\n"
+ "return undefined == a;\n",
+
+ "var a = undefined;\n"
+ "return undefined === a ? 1 : 2;\n",
+
+ "var a = 0;\n"
+ "return null == a ? 1 : 2;\n",
+
+ "var a = 0;\n"
+ "return undefined !== a ? 1 : 2;\n",
+
+ "var a = 0;\n"
+ "return a === null ? 1 : 2;\n",
+
+ "var a = 0;\n"
+ "if (a === null) {\n"
+ " return 1;\n"
+ "} else {\n"
+ " return 2;\n"
+ "}\n",
+
+ "var a = 0;\n"
+ "if (a != undefined) {\n"
+ " return 1;\n"
+ "}\n",
+
+ "var a = undefined;\n"
+ "var b = 0;\n"
+ "while (a !== undefined) {\n"
+ " b++;\n"
+ "}\n",
+ };
+
+ CHECK(CompareTexts(BuildActual(printer, snippets),
+ LoadGolden("CompareNil.golden")));
+}
+
TEST(Delete) {
InitializedIgnitionHandleScope scope;
BytecodeExpectationsPrinter printer(CcTest::isolate());

Powered by Google App Engine
This is Rietveld 408576698