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

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

Issue 1402943002: [Interpreter] Support for operator new. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporate review comments on patch sets 2 and 3. 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-interpreter.cc
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc
index 188b3e61d99c5f8aef53684ba6eeff20819e06ac..22e603883b54d252da431d6bf52acbdab1b282f4 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -1637,3 +1637,61 @@ TEST(InterpreterFunctionLiteral) {
Handle<Smi>(Smi::FromInt(3), handles.main_isolate())).ToHandleChecked();
CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(5));
}
+
+
+TEST(InterpreterConstruct) {
+ HandleAndZoneScope handles;
+
+ std::string source(
+ "function counter() { this.count = 0; }\n"
+ "function " +
+ InterpreterTester::function_name() +
+ "() {\n"
+ " var c = new counter();\n"
+ " return c.count;\n"
+ "}");
+ InterpreterTester tester(handles.main_isolate(), source.c_str());
+ auto callable = tester.GetCallable<>();
+
+ Handle<Object> return_val = callable().ToHandleChecked();
+ CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0));
+}
+
+
+TEST(InterpreterConstructWithArgument) {
+ HandleAndZoneScope handles;
+
+ std::string source(
+ "function counter(arg0) { this.count = 17; this.x = arg0; }\n"
+ "function " +
+ InterpreterTester::function_name() +
+ "() {\n"
+ " var c = new counter(3);\n"
+ " return c.x;\n"
+ "}");
+ InterpreterTester tester(handles.main_isolate(), source.c_str());
+ auto callable = tester.GetCallable<>();
+
+ Handle<Object> return_val = callable().ToHandleChecked();
+ CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(3));
+}
+
+
+TEST(InterpreterConstructWithArguments) {
+ HandleAndZoneScope handles;
+
+ std::string source(
+ "function counter(arg0, arg1) { this.count = 17; this.x = arg0; this.y = "
rmcilroy 2015/10/14 10:18:35 nit - newline after '{'
oth 2015/10/14 16:02:19 Done.
+ "arg1; }\n"
+ "function " +
+ InterpreterTester::function_name() +
+ "() {\n"
+ " var c = new counter(3, 4);\n"
+ " return c.y;\n"
+ "}");
+ InterpreterTester tester(handles.main_isolate(), source.c_str());
+ auto callable = tester.GetCallable<>();
+
+ Handle<Object> return_val = callable().ToHandleChecked();
+ CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(4));
+}

Powered by Google App Engine
This is Rietveld 408576698