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

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

Issue 2630343002: [Parser] Introduce AstStringConstants to share constants across AstValueFactory (Closed)
Patch Set: Fix test Created 3 years, 11 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
« no previous file with comments | « test/cctest/asmjs/test-asm-typer.cc ('k') | test/cctest/test-parsing.cc » ('j') | 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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 29
30 #include "src/v8.h" 30 #include "src/v8.h"
31 31
32 #include "src/ast/ast.h" 32 #include "src/ast/ast.h"
33 #include "src/isolate.h"
33 #include "src/objects-inl.h" 34 #include "src/objects-inl.h"
34 #include "src/zone/accounting-allocator.h" 35 #include "src/zone/accounting-allocator.h"
35 #include "test/cctest/cctest.h" 36 #include "test/cctest/cctest.h"
36 37
37 using namespace v8::internal; 38 using namespace v8::internal;
38 39
39 TEST(List) { 40 TEST(List) {
41 v8::V8::Initialize();
42 Isolate* isolate = CcTest::i_isolate();
43
40 List<AstNode*>* list = new List<AstNode*>(0); 44 List<AstNode*>* list = new List<AstNode*>(0);
41 CHECK_EQ(0, list->length()); 45 CHECK_EQ(0, list->length());
42 46
43 v8::internal::AccountingAllocator allocator; 47 v8::internal::AccountingAllocator allocator;
44 Zone zone(&allocator, ZONE_NAME); 48 Zone zone(&allocator, ZONE_NAME);
45 AstValueFactory value_factory(&zone, 0); 49 AstValueFactory value_factory(&zone, isolate->ast_string_constants(),
50 isolate->heap()->HashSeed());
46 AstNodeFactory factory(&value_factory); 51 AstNodeFactory factory(&value_factory);
47 AstNode* node = factory.NewEmptyStatement(kNoSourcePosition); 52 AstNode* node = factory.NewEmptyStatement(kNoSourcePosition);
48 list->Add(node); 53 list->Add(node);
49 CHECK_EQ(1, list->length()); 54 CHECK_EQ(1, list->length());
50 CHECK_EQ(node, list->at(0)); 55 CHECK_EQ(node, list->at(0));
51 CHECK_EQ(node, list->last()); 56 CHECK_EQ(node, list->last());
52 57
53 const int kElements = 100; 58 const int kElements = 100;
54 for (int i = 0; i < kElements; i++) { 59 for (int i = 0; i < kElements; i++) {
55 list->Add(node); 60 list->Add(node);
56 } 61 }
57 CHECK_EQ(1 + kElements, list->length()); 62 CHECK_EQ(1 + kElements, list->length());
58 63
59 list->Clear(); 64 list->Clear();
60 CHECK_EQ(0, list->length()); 65 CHECK_EQ(0, list->length());
61 delete list; 66 delete list;
62 } 67 }
OLDNEW
« no previous file with comments | « test/cctest/asmjs/test-asm-typer.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698