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

Side by Side Diff: test/cctest/test-api.cc

Issue 1749353004: Ship ES2015 Function.name reform (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | test/mjsunit/debug-backtrace.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 13503 matching lines...) Expand 10 before | Expand all | Expand 10 after
13514 13514
13515 THREADED_TEST(ObjectGetConstructorName) { 13515 THREADED_TEST(ObjectGetConstructorName) {
13516 v8::Isolate* isolate = CcTest::isolate(); 13516 v8::Isolate* isolate = CcTest::isolate();
13517 LocalContext context; 13517 LocalContext context;
13518 v8::HandleScope scope(isolate); 13518 v8::HandleScope scope(isolate);
13519 v8_compile( 13519 v8_compile(
13520 "function Parent() {};" 13520 "function Parent() {};"
13521 "function Child() {};" 13521 "function Child() {};"
13522 "Child.prototype = new Parent();" 13522 "Child.prototype = new Parent();"
13523 "Child.prototype.constructor = Child;" 13523 "Child.prototype.constructor = Child;"
13524 "var outer = { inner: function() { } };" 13524 "var outer = { inner: (0, function() { }) };"
13525 "var p = new Parent();" 13525 "var p = new Parent();"
13526 "var c = new Child();" 13526 "var c = new Child();"
13527 "var x = new outer.inner();" 13527 "var x = new outer.inner();"
13528 "var proto = Child.prototype;") 13528 "var proto = Child.prototype;")
13529 ->Run(context.local()) 13529 ->Run(context.local())
13530 .ToLocalChecked(); 13530 .ToLocalChecked();
13531 13531
13532 Local<v8::Value> p = 13532 Local<v8::Value> p =
13533 context->Global()->Get(context.local(), v8_str("p")).ToLocalChecked(); 13533 context->Global()->Get(context.local(), v8_str("p")).ToLocalChecked();
13534 CHECK(p->IsObject() && 13534 CHECK(p->IsObject() &&
(...skipping 4835 matching lines...) Expand 10 before | Expand all | Expand 10 after
18370 ->Run(env.local()) 18370 ->Run(env.local())
18371 .ToLocalChecked(); 18371 .ToLocalChecked();
18372 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 18372 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
18373 env->Global()->Get(env.local(), v8_str("f")).ToLocalChecked()); 18373 env->Global()->Get(env.local(), v8_str("f")).ToLocalChecked());
18374 CHECK_EQ(0, 18374 CHECK_EQ(0,
18375 strcmp("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName()))); 18375 strcmp("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName())));
18376 } 18376 }
18377 18377
18378 18378
18379 THREADED_TEST(FunctionGetDebugName) { 18379 THREADED_TEST(FunctionGetDebugName) {
18380 i::FLAG_harmony_function_name = true;
18380 LocalContext env; 18381 LocalContext env;
18381 v8::HandleScope scope(env->GetIsolate()); 18382 v8::HandleScope scope(env->GetIsolate());
18382 const char* code = 18383 const char* code =
18383 "var error = false;" 18384 "var error = false;"
18384 "function a() { this.x = 1; };" 18385 "function a() { this.x = 1; };"
18385 "a.displayName = 'display_a';" 18386 "a.displayName = 'display_a';"
18386 "var b = (function() {" 18387 "var b = (function() {"
18387 " var f = function() { this.x = 2; };" 18388 " var f = function() { this.x = 2; };"
18388 " f.displayName = 'display_b';" 18389 " f.displayName = 'display_b';"
18389 " return f;" 18390 " return f;"
(...skipping 23 matching lines...) Expand all
18413 " arguments.callee.displayName = 'set_in_runtime';" 18414 " arguments.callee.displayName = 'set_in_runtime';"
18414 "}; g();" 18415 "}; g();"
18415 "var h = function() {};" 18416 "var h = function() {};"
18416 "h.displayName = 'displayName';" 18417 "h.displayName = 'displayName';"
18417 "Object.defineProperty(h, 'name', { value: 'function.name' });" 18418 "Object.defineProperty(h, 'name', { value: 'function.name' });"
18418 "var i = function() {};" 18419 "var i = function() {};"
18419 "i.displayName = 239;" 18420 "i.displayName = 239;"
18420 "Object.defineProperty(i, 'name', { value: 'function.name' });" 18421 "Object.defineProperty(i, 'name', { value: 'function.name' });"
18421 "var j = function() {};" 18422 "var j = function() {};"
18422 "Object.defineProperty(j, 'name', { value: 'function.name' });" 18423 "Object.defineProperty(j, 'name', { value: 'function.name' });"
18423 "var foo = { bar : { baz : function() {}}}; var k = foo.bar.baz;"; 18424 "var foo = { bar : { baz : (0, function() {})}}; var k = foo.bar.baz;"
18425 "var foo = { bar : { baz : function() {} }}; var l = foo.bar.baz;";
18424 v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test")); 18426 v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test"));
18425 v8::Script::Compile(env.local(), v8_str(code), &origin) 18427 v8::Script::Compile(env.local(), v8_str(code), &origin)
18426 .ToLocalChecked() 18428 .ToLocalChecked()
18427 ->Run(env.local()) 18429 ->Run(env.local())
18428 .ToLocalChecked(); 18430 .ToLocalChecked();
18429 v8::Local<v8::Value> error = 18431 v8::Local<v8::Value> error =
18430 env->Global()->Get(env.local(), v8_str("error")).ToLocalChecked(); 18432 env->Global()->Get(env.local(), v8_str("error")).ToLocalChecked();
18431 CHECK_EQ(false, error->BooleanValue(env.local()).FromJust()); 18433 CHECK_EQ(false, error->BooleanValue(env.local()).FromJust());
18432 const char* functions[] = {"a", "display_a", 18434 const char* functions[] = {"a", "display_a",
18433 "b", "display_b", 18435 "b", "display_b",
18434 "c", "c", 18436 "c", "c",
18435 "d", "d", 18437 "d", "d",
18436 "e", "e", 18438 "e", "e",
18437 "f", "f", 18439 "f", "f",
18438 "g", "set_in_runtime", 18440 "g", "set_in_runtime",
18439 "h", "displayName", 18441 "h", "displayName",
18440 "i", "function.name", 18442 "i", "function.name",
18441 "j", "function.name", 18443 "j", "function.name",
18442 "k", "foo.bar.baz"}; 18444 "k", "foo.bar.baz",
18445 "l", "baz"};
18443 for (size_t i = 0; i < sizeof(functions) / sizeof(functions[0]) / 2; ++i) { 18446 for (size_t i = 0; i < sizeof(functions) / sizeof(functions[0]) / 2; ++i) {
18444 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 18447 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
18445 env->Global() 18448 env->Global()
18446 ->Get(env.local(), 18449 ->Get(env.local(),
18447 v8::String::NewFromUtf8(env->GetIsolate(), functions[i * 2], 18450 v8::String::NewFromUtf8(env->GetIsolate(), functions[i * 2],
18448 v8::NewStringType::kNormal) 18451 v8::NewStringType::kNormal)
18449 .ToLocalChecked()) 18452 .ToLocalChecked())
18450 .ToLocalChecked()); 18453 .ToLocalChecked());
18451 CHECK_EQ(0, strcmp(functions[i * 2 + 1], 18454 CHECK_EQ(0, strcmp(functions[i * 2 + 1],
18452 *v8::String::Utf8Value(f->GetDebugName()))); 18455 *v8::String::Utf8Value(f->GetDebugName())));
(...skipping 6519 matching lines...) Expand 10 before | Expand all | Expand 10 after
24972 CHECK(proxy->GetTarget()->SameValue(target)); 24975 CHECK(proxy->GetTarget()->SameValue(target));
24973 CHECK(proxy->GetHandler()->SameValue(handler)); 24976 CHECK(proxy->GetHandler()->SameValue(handler));
24974 24977
24975 proxy->Revoke(); 24978 proxy->Revoke();
24976 CHECK(proxy->IsProxy()); 24979 CHECK(proxy->IsProxy());
24977 CHECK(!target->IsProxy()); 24980 CHECK(!target->IsProxy());
24978 CHECK(proxy->IsRevoked()); 24981 CHECK(proxy->IsRevoked());
24979 CHECK(proxy->GetTarget()->SameValue(target)); 24982 CHECK(proxy->GetTarget()->SameValue(target));
24980 CHECK(proxy->GetHandler()->IsNull()); 24983 CHECK(proxy->GetHandler()->IsNull());
24981 } 24984 }
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | test/mjsunit/debug-backtrace.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698