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

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

Issue 10199019: Make String::Empty inlineable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« src/api.cc ('K') | « src/heap.h ('k') | no next file » | 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 16432 matching lines...) Expand 10 before | Expand all | Expand 10 after
16443 TEST(SecondaryStubCache) { 16443 TEST(SecondaryStubCache) {
16444 StubCacheHelper(true); 16444 StubCacheHelper(true);
16445 } 16445 }
16446 16446
16447 16447
16448 TEST(PrimaryStubCache) { 16448 TEST(PrimaryStubCache) {
16449 StubCacheHelper(false); 16449 StubCacheHelper(false);
16450 } 16450 }
16451 16451
16452 16452
16453 static int fatal_error_callback_counter = 0;
16454 static void CountingErrorCallback(const char* location, const char* message) {
16455 printf("CountingErrorCallback(\"%s\", \"%s\")\n", location, message);
16456 fatal_error_callback_counter++;
16457 }
16458
16459
16453 TEST(StaticGetters) { 16460 TEST(StaticGetters) {
16454 v8::HandleScope scope; 16461 v8::HandleScope scope;
16455 LocalContext context; 16462 LocalContext context;
16456 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 16463 v8::Isolate* isolate = v8::Isolate::GetCurrent();
16457 i::Handle<i::Object> undefined_value = FACTORY->undefined_value(); 16464 i::Handle<i::Object> undefined_value = FACTORY->undefined_value();
16458 CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value); 16465 CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value);
16459 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value); 16466 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value);
16460 i::Handle<i::Object> null_value = FACTORY->null_value(); 16467 i::Handle<i::Object> null_value = FACTORY->null_value();
16461 CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value); 16468 CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value);
16462 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value); 16469 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value);
16463 i::Handle<i::Object> true_value = FACTORY->true_value(); 16470 i::Handle<i::Object> true_value = FACTORY->true_value();
16464 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value); 16471 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value);
16465 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value); 16472 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value);
16466 i::Handle<i::Object> false_value = FACTORY->false_value(); 16473 i::Handle<i::Object> false_value = FACTORY->false_value();
16467 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value); 16474 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value);
16468 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); 16475 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value);
16469 }
16470 16476
16471 16477 // Test after-death behavior.
16472 static int fatal_error_callback_counter = 0;
16473 static void CountingErrorCallback(const char* location, const char* message) {
16474 printf("CountingErrorCallback(\"%s\", \"%s\")\n", location, message);
16475 fatal_error_callback_counter++;
16476 }
16477
16478
16479 TEST(StaticGettersAfterDeath) {
16480 v8::HandleScope scope;
16481 LocalContext context;
16482 v8::Isolate* isolate = v8::Isolate::GetCurrent();
16483 CHECK(i::Internals::IsInitialized(isolate)); 16478 CHECK(i::Internals::IsInitialized(isolate));
16484 CHECK_EQ(0, fatal_error_callback_counter); 16479 CHECK_EQ(0, fatal_error_callback_counter);
16485 v8::V8::SetFatalErrorHandler(CountingErrorCallback); 16480 v8::V8::SetFatalErrorHandler(CountingErrorCallback);
16486 v8::Utils::ReportApiFailure("StaticGettersAfterDeath()", "Kill V8"); 16481 v8::Utils::ReportApiFailure("StaticGetters()", "Kill V8");
16487 i::Isolate::Current()->TearDown(); 16482 i::Isolate::Current()->TearDown();
16488 CHECK(!i::Internals::IsInitialized(isolate)); 16483 CHECK(!i::Internals::IsInitialized(isolate));
16489 CHECK_EQ(1, fatal_error_callback_counter); 16484 CHECK_EQ(1, fatal_error_callback_counter);
16490 CHECK(v8::Undefined().IsEmpty()); 16485 CHECK(v8::Undefined().IsEmpty());
16491 CHECK_EQ(2, fatal_error_callback_counter); 16486 CHECK_EQ(2, fatal_error_callback_counter);
16492 CHECK(v8::Undefined(isolate).IsEmpty()); 16487 CHECK(v8::Undefined(isolate).IsEmpty());
16493 CHECK_EQ(3, fatal_error_callback_counter); 16488 CHECK_EQ(3, fatal_error_callback_counter);
16494 CHECK(v8::Null().IsEmpty()); 16489 CHECK(v8::Null().IsEmpty());
16495 CHECK_EQ(4, fatal_error_callback_counter); 16490 CHECK_EQ(4, fatal_error_callback_counter);
16496 CHECK(v8::Null(isolate).IsEmpty()); 16491 CHECK(v8::Null(isolate).IsEmpty());
(...skipping 18 matching lines...) Expand all
16515 CHECK_EQ(data1, isolate->GetData()); 16510 CHECK_EQ(data1, isolate->GetData());
16516 CHECK_EQ(data1, ISOLATE->GetData()); 16511 CHECK_EQ(data1, ISOLATE->GetData());
16517 static void* data2 = reinterpret_cast<void*>(0xdecea5ed); 16512 static void* data2 = reinterpret_cast<void*>(0xdecea5ed);
16518 ISOLATE->SetData(data2); 16513 ISOLATE->SetData(data2);
16519 CHECK_EQ(data2, isolate->GetData()); 16514 CHECK_EQ(data2, isolate->GetData());
16520 CHECK_EQ(data2, ISOLATE->GetData()); 16515 CHECK_EQ(data2, ISOLATE->GetData());
16521 ISOLATE->TearDown(); 16516 ISOLATE->TearDown();
16522 CHECK_EQ(data2, isolate->GetData()); 16517 CHECK_EQ(data2, isolate->GetData());
16523 CHECK_EQ(data2, ISOLATE->GetData()); 16518 CHECK_EQ(data2, ISOLATE->GetData());
16524 } 16519 }
16520
16521
16522 TEST(StringEmpty) {
16523 v8::HandleScope scope;
16524 LocalContext context;
16525 v8::Isolate* isolate = v8::Isolate::GetCurrent();
16526 i::Handle<i::Object> empty_string = FACTORY->empty_symbol();
16527 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string);
16528 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string);
16529
16530 // Test after-death behavior.
16531 CHECK(i::Internals::IsInitialized(isolate));
16532 CHECK_EQ(0, fatal_error_callback_counter);
16533 v8::V8::SetFatalErrorHandler(CountingErrorCallback);
16534 v8::Utils::ReportApiFailure("StringEmpty()", "Kill V8");
16535 i::Isolate::Current()->TearDown();
16536 CHECK(!i::Internals::IsInitialized(isolate));
16537 CHECK_EQ(1, fatal_error_callback_counter);
16538 CHECK(v8::String::Empty().IsEmpty());
16539 CHECK_EQ(2, fatal_error_callback_counter);
16540 CHECK(v8::String::Empty(isolate).IsEmpty());
16541 CHECK_EQ(3, fatal_error_callback_counter);
16542 }
OLDNEW
« src/api.cc ('K') | « src/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698