Add test for referring function name for classes.

R=mvstanton@chromium.org
BUG=v8:4333
LOG=N

Review URL: https://codereview.chromium.org/1264603002

Cr-Commit-Position: refs/heads/master@{#29922}
This commit is contained in:
yangguo 2015-07-30 02:21:16 -07:00 committed by Commit bot
parent 496bd53bcc
commit 67efca8be6
2 changed files with 44 additions and 0 deletions

View File

@ -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-inference/UpperCaseClass': [FAIL],
'test-func-name-inference/LowerCaseClass': [FAIL],
##############################################################################
# TurboFan compiler failures.

View File

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