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 "src/v8.h"
9 
10 #include "src/objects.h"
11 #include "src/ostreams.h"
12 #include "test/cctest/cctest.h"
13 
14 using namespace v8::internal;
15 
16 
TEST(Create)17 TEST(Create) {
18   CcTest::InitializeVM();
19   Isolate* isolate = CcTest::i_isolate();
20   HandleScope scope(isolate);
21 
22   const int kNumSymbols = 30;
23   Handle<Symbol> symbols[kNumSymbols];
24 
25   OFStream os(stdout);
26   for (int i = 0; i < kNumSymbols; ++i) {
27     symbols[i] = isolate->factory()->NewSymbol();
28     CHECK(symbols[i]->IsName());
29     CHECK(symbols[i]->IsSymbol());
30     CHECK(symbols[i]->HasHashCode());
31     CHECK_GT(symbols[i]->Hash(), 0);
32     os << Brief(*symbols[i]) << "\n";
33 #if OBJECT_PRINT
34     symbols[i]->Print(os);
35 #endif
36 #if VERIFY_HEAP
37     symbols[i]->ObjectVerify();
38 #endif
39   }
40 
41   CcTest::heap()->CollectGarbage(i::NEW_SPACE);
42   CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
43 
44   // All symbols should be distinct.
45   for (int i = 0; i < kNumSymbols; ++i) {
46     CHECK(symbols[i]->SameValue(*symbols[i]));
47     for (int j = i + 1; j < kNumSymbols; ++j) {
48       CHECK(!symbols[i]->SameValue(*symbols[j]));
49     }
50   }
51 }
52