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()); |