Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | |
| 2 | |
| 3 // Check that we can traverse very deep stacks of ConsStrings using | |
| 4 // StringCharacterStram. Check that Get(int) works on very deep stacks | |
| 5 // of ConsStrings. These operations may not be very fast, but they | |
| 6 // should be possible without getting errors due to too deep recursion. | |
| 7 | |
| 8 #include "v8.h" | |
| 9 | |
| 10 #include "objects.h" | |
| 11 #include "cctest.h" | |
|
Michael Starzinger
2013/02/12 10:03:53
Can we alpha-sort the includes?
rossberg
2013/02/13 10:04:28
Done. Also removed obsolete import of "zone-inl.h"
| |
| 12 #include "zone-inl.h" | |
| 13 | |
| 14 using namespace v8::internal; | |
| 15 | |
| 16 static v8::Persistent<v8::Context> env; | |
| 17 | |
| 18 static void InitializeVM() { | |
| 19 if (env.IsEmpty()) { | |
| 20 v8::HandleScope scope; | |
| 21 const char* extensions[] = { "v8/print" }; | |
| 22 v8::ExtensionConfiguration config(1, extensions); | |
| 23 env = v8::Context::New(&config); | |
| 24 } | |
| 25 v8::HandleScope scope; | |
| 26 env->Enter(); | |
| 27 } | |
| 28 | |
| 29 | |
| 30 TEST(Create) { | |
| 31 InitializeVM(); | |
| 32 HandleScope scope; | |
| 33 Isolate* isolate = Isolate::Current(); | |
| 34 | |
| 35 const int kNumSymbols = 30; | |
| 36 Handle<Symbol> symbols[kNumSymbols]; | |
| 37 | |
| 38 for (int i = 0; i < kNumSymbols; ++i) { | |
| 39 symbols[i] = isolate->factory()->NewSymbol(); | |
| 40 CHECK(symbols[i]->IsName()); | |
| 41 CHECK(symbols[i]->IsSymbol()); | |
| 42 CHECK(symbols[i]->HasHashCode()); | |
| 43 CHECK_GT(symbols[i]->Hash(), 0); | |
| 44 symbols[i]->ShortPrint(); | |
| 45 PrintF("\n"); | |
| 46 #if OBJECT_PRINT | |
| 47 symbols[i]->Print(); | |
| 48 #endif | |
| 49 #if VERIFY_HEAP | |
| 50 symbols[i]->Verify(); | |
| 51 #endif | |
| 52 } | |
| 53 | |
| 54 HEAP->PerformScavenge(); | |
| 55 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | |
| 56 | |
| 57 // All symbols should be distinct. | |
| 58 for (int i = 0; i < kNumSymbols; ++i) { | |
| 59 CHECK(symbols[i]->SameValue(*symbols[i])); | |
| 60 for (int j = i + 1; j < kNumSymbols; ++j) { | |
| 61 CHECK(!symbols[i]->SameValue(*symbols[j])); | |
| 62 } | |
| 63 } | |
| 64 } | |
| OLD | NEW |