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

Unified Diff: test/cctest/test-func-name-inference.cc

Issue 6893135: Add some more (failing) tests for function names inference. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 8 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
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-func-name-inference.cc
diff --git a/test/cctest/test-func-name-inference.cc b/test/cctest/test-func-name-inference.cc
index dea5c47735b8d847f442c16884ff8377611642ae..80f9bd189a06fe3cf4ad1b219f93ce00846c1222 100644
--- a/test/cctest/test-func-name-inference.cc
+++ b/test/cctest/test-func-name-inference.cc
@@ -281,3 +281,74 @@ TEST(Issue380) {
"}");
CheckFunctionName(script, "return p", "");
}
+
+
+TEST(MultipleAssignments) {
+ InitializeVM();
+ v8::HandleScope scope;
+
+ v8::Handle<v8::Script> script = Compile(
+ "var fun1 = fun2 = function () { return 1; }");
+ CheckFunctionName(script, "return 1", "fun2");
+}
+
+
+TEST(PassedAsConstructorParameter) {
+ InitializeVM();
+ v8::HandleScope scope;
+
+ v8::Handle<v8::Script> script = Compile(
+ "function Foo() {}\n"
+ "var foo = new Foo(function() { return 1; })");
+ CheckFunctionName(script, "return 1", "");
+}
+
+
+TEST(FactoryHashmap) {
+ InitializeVM();
+ v8::HandleScope scope;
+
+ v8::Handle<v8::Script> script = Compile(
+ "function createMyObj() {\n"
+ " var obj = {};\n"
+ " obj[\"method1\"] = function() { return 1; }\n"
+ " obj[\"method2\"] = function() { return 2; }\n"
+ " return obj;\n"
+ "}");
+ CheckFunctionName(script, "return 1", "obj.method1");
+ CheckFunctionName(script, "return 2", "obj.method2");
+}
+
+
+TEST(FactoryHashmapVariable) {
+ InitializeVM();
+ v8::HandleScope scope;
+
+ v8::Handle<v8::Script> script = Compile(
+ "function createMyObj() {\n"
+ " var obj = {};\n"
+ " var methodName = \"method1\";\n"
+ " obj[methodName] = function() { return 1; }\n"
+ " methodName = \"method2\";\n"
+ " obj[methodName] = function() { return 2; }\n"
+ " return obj;\n"
+ "}");
+ // Can't infer function names statically.
+ CheckFunctionName(script, "return 1", "obj.(anonymous function)");
+ CheckFunctionName(script, "return 2", "obj.(anonymous function)");
+}
+
+
+TEST(FactoryHashmapConditional) {
+ InitializeVM();
+ v8::HandleScope scope;
+
+ v8::Handle<v8::Script> script = Compile(
+ "function createMyObj() {\n"
+ " var obj = {};\n"
+ " obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n"
+ " return obj;\n"
+ "}");
+ // Can't infer the function name statically.
+ CheckFunctionName(script, "return 1", "obj.(anonymous function)");
+}
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698