Reviewers: mvstanton,

Description:
Add test for referring function name for classes.

[email protected]
BUG=v8:4333
LOG=N

Please review this at https://codereview.chromium.org/1264603002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+44, -0 lines):
  M test/cctest/cctest.status
  M test/cctest/test-func-name-inference.cc


Index: test/cctest/cctest.status
diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status
index dc712a3c55b8fdfefcb868b5613b9229d7ba0508..6dd206496e7a809f123c2732409925bd5bd9390f 100644
--- a/test/cctest/cctest.status
+++ b/test/cctest/cctest.status
@@ -100,6 +100,10 @@
   # BUG(2340). Preprocessing stack traces is disabled at the moment.
   'test-heap/PreprocessStackTrace': [FAIL],

+  # BUG(4333). Function name inferrer does not work for ES6 clases.
+  'test-func-name-inferrence/UpperCaseClass': [FAIL],
+  'test-func-name-inferrence/LowerCaseClass': [FAIL],
+
##############################################################################
   # TurboFan compiler failures.

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 e423c0f26203a347d5280a476674d9ff24c8f67b..d01a938590fddc4a6e50610bb49aaeac0628881c 100644
--- a/test/cctest/test-func-name-inference.cc
+++ b/test/cctest/test-func-name-inference.cc
@@ -87,6 +87,8 @@ static void CheckFunctionName(v8::Handle<v8::Script> script,
   // Verify inferred function name.
   SmartArrayPointer<char> inferred_name =
       shared_func_info->inferred_name()->ToCString();
+  i::PrintF("expected: %s, found: %s\n", ref_inferred_name,
+            inferred_name.get());
   CHECK_EQ(0, strcmp(ref_inferred_name, inferred_name.get()));
 }

@@ -222,6 +224,44 @@ TEST(ObjectLiteral) {
 }


+TEST(UpperCaseClass) {
+  CcTest::InitializeVM();
+  v8::HandleScope scope(CcTest::isolate());
+
+  v8::Handle<v8::Script> script = Compile(CcTest::isolate(),
+                                          "'use strict';\n"
+                                          "class MyClass {\n"
+                                          "  constructor() {\n"
+                                          "    this.value = 1;\n"
+                                          "  }\n"
+                                          "  method() {\n"
+                                          "    this.value = 2;\n"
+                                          "  }\n"
+                                          "}");
+  CheckFunctionName(script, "this.value = 1", "MyClass");
+  CheckFunctionName(script, "this.value = 2", "MyClass.method");
+}
+
+
+TEST(LowerCaseClass) {
+  CcTest::InitializeVM();
+  v8::HandleScope scope(CcTest::isolate());
+
+  v8::Handle<v8::Script> script = Compile(CcTest::isolate(),
+                                          "'use strict';\n"
+                                          "class myclass {\n"
+                                          "  constructor() {\n"
+                                          "    this.value = 1;\n"
+                                          "  }\n"
+                                          "  method() {\n"
+                                          "    this.value = 2;\n"
+                                          "  }\n"
+                                          "}");
+  CheckFunctionName(script, "this.value = 1", "myclass");
+  CheckFunctionName(script, "this.value = 2", "myclass.method");
+}
+
+
 TEST(AsParameter) {
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to