v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test-symbols.cc
Go to the documentation of this file.
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 "cctest.h"
11 #include "objects.h"
12 
13 using namespace v8::internal;
14 
15 
16 TEST(Create) {
18  Isolate* isolate = CcTest::i_isolate();
19  HandleScope scope(isolate);
20 
21  const int kNumSymbols = 30;
22  Handle<Symbol> symbols[kNumSymbols];
23 
24  for (int i = 0; i < kNumSymbols; ++i) {
25  symbols[i] = isolate->factory()->NewSymbol();
26  CHECK(symbols[i]->IsName());
27  CHECK(symbols[i]->IsSymbol());
28  CHECK(symbols[i]->HasHashCode());
29  CHECK_GT(symbols[i]->Hash(), 0);
30  symbols[i]->ShortPrint();
31  PrintF("\n");
32 #if OBJECT_PRINT
33  symbols[i]->Print();
34 #endif
35 #if VERIFY_HEAP
36  symbols[i]->Verify();
37 #endif
38  }
39 
42 
43  // All symbols should be distinct.
44  for (int i = 0; i < kNumSymbols; ++i) {
45  CHECK(symbols[i]->SameValue(*symbols[i]));
46  for (int j = i + 1; j < kNumSymbols; ++j) {
47  CHECK(!symbols[i]->SameValue(*symbols[j]));
48  }
49  }
50 }
void PrintF(const char *format,...)
Definition: v8utils.cc:40
void CollectAllGarbage(int flags, const char *gc_reason=NULL, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
Definition: heap.cc:731
#define CHECK_GT(a, b)
Definition: checks.h:260
enable upcoming ES6 features enable harmony block scoping enable harmony symbols(a.k.a.private names)") DEFINE_bool(harmony_proxies
static i::Heap * heap()
Definition: cctest.h:106
#define CHECK(condition)
Definition: checks.h:75
Factory * factory()
Definition: isolate.h:995
static const int kNoGCFlags
Definition: heap.h:1257
static i::Isolate * i_isolate()
Definition: cctest.h:102
bool CollectGarbage(AllocationSpace space, const char *gc_reason=NULL, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
Definition: heap-inl.h:554
static void InitializeVM()
Definition: cctest.h:116
Handle< Symbol > NewSymbol()
Definition: factory.cc:572