Revision: 7733
Author:   [email protected]
Date:     Fri Apr 29 13:59:29 2011
Log:      Add some more (failing) tests for function names inference.

After the "Naming Anonymous JavaScript Functions" paper by
S. M. Ecole, J. J. Barton, C. Petitpierre.

[email protected]
BUG=1354
TEST=test-func-name-inference/*

Review URL: http://codereview.chromium.org/6893135
http://code.google.com/p/v8/source/detail?r=7733

Modified:
 /branches/bleeding_edge/test/cctest/cctest.status
 /branches/bleeding_edge/test/cctest/test-func-name-inference.cc

=======================================
--- /branches/bleeding_edge/test/cctest/cctest.status Tue Apr 19 03:34:34 2011 +++ /branches/bleeding_edge/test/cctest/cctest.status Fri Apr 29 13:59:29 2011
@@ -41,6 +41,14 @@
 test-serialize/TestThatAlwaysFails: FAIL
 test-serialize/DependentTestThatAlwaysFails: FAIL

+##############################################################################
+# BUG(1354): Bad function name inference
+test-func-name-inference/FactoryHashmapConditional: FAIL
+test-func-name-inference/FactoryHashmapVariable: FAIL
+test-func-name-inference/FactoryHashmap: FAIL
+test-func-name-inference/MultipleAssignments: FAIL
+test-func-name-inference/PassedAsConstructorParameter: FAIL
+
##############################################################################
 [ $arch == arm ]

@@ -95,6 +103,3 @@
 test-strings: SKIP
 test-threads: SKIP
 test-thread-termination: SKIP
-
-##############################################################################
-# Tests that time out with Isolates
=======================================
--- /branches/bleeding_edge/test/cctest/test-func-name-inference.cc Fri Mar 18 13:35:07 2011 +++ /branches/bleeding_edge/test/cctest/test-func-name-inference.cc Fri Apr 29 13:59:29 2011
@@ -281,3 +281,74 @@
       "}");
   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)");
+}

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to