blob: e1b3ea77ef83d5bb9adf6577a532c688192c79a4 [file] [log] [blame]
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +00001// 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
ulan@chromium.org57ff8812013-05-10 08:16:55 +00008// TODO(dcarney): remove
9#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
10#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
11
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +000012#include "v8.h"
13
14#include "cctest.h"
15#include "objects.h"
16
17using namespace v8::internal;
18
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +000019
20TEST(Create) {
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +000021 CcTest::InitializeVM();
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +000022 Isolate* isolate = Isolate::Current();
23 HandleScope scope(isolate);
24
25 const int kNumSymbols = 30;
26 Handle<Symbol> symbols[kNumSymbols];
27
28 for (int i = 0; i < kNumSymbols; ++i) {
29 symbols[i] = isolate->factory()->NewSymbol();
30 CHECK(symbols[i]->IsName());
31 CHECK(symbols[i]->IsSymbol());
32 CHECK(symbols[i]->HasHashCode());
33 CHECK_GT(symbols[i]->Hash(), 0);
34 symbols[i]->ShortPrint();
35 PrintF("\n");
36#if OBJECT_PRINT
37 symbols[i]->Print();
38#endif
39#if VERIFY_HEAP
40 symbols[i]->Verify();
41#endif
42 }
43
44 HEAP->PerformScavenge();
45 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
46
47 // All symbols should be distinct.
48 for (int i = 0; i < kNumSymbols; ++i) {
49 CHECK(symbols[i]->SameValue(*symbols[i]));
50 for (int j = i + 1; j < kNumSymbols; ++j) {
51 CHECK(!symbols[i]->SameValue(*symbols[j]));
52 }
53 }
54}