OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/ast.h" | 6 #include "vm/ast.h" |
7 #include "vm/heap.h" | 7 #include "vm/heap.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
11 #include "vm/unit_test.h" | 11 #include "vm/unit_test.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 TEST_CASE(Ast) { | 15 TEST_CASE(Ast) { |
16 LocalVariable* v = new LocalVariable(Scanner::kNoSourcePos, | 16 LocalVariable* v = new LocalVariable(Scanner::kNoSourcePos, |
17 String::ZoneHandle(String::New("v")), | 17 String::ZoneHandle(Symbols::New("v")), |
18 Type::ZoneHandle(Type::DynamicType())); | 18 Type::ZoneHandle(Type::DynamicType())); |
19 AstNode* ll = new LoadLocalNode(Scanner::kNoSourcePos, v); | 19 AstNode* ll = new LoadLocalNode(Scanner::kNoSourcePos, v); |
20 EXPECT(ll->IsLoadLocalNode()); | 20 EXPECT(ll->IsLoadLocalNode()); |
21 EXPECT(!ll->IsLiteralNode()); | 21 EXPECT(!ll->IsLiteralNode()); |
22 LoadLocalNode* lln = ll->AsLoadLocalNode(); | 22 LoadLocalNode* lln = ll->AsLoadLocalNode(); |
23 EXPECT(NULL != lln); | 23 EXPECT(NULL != lln); |
24 v->set_index(1); | 24 v->set_index(1); |
25 EXPECT_EQ(1, v->index()); | 25 EXPECT_EQ(1, v->index()); |
26 | 26 |
27 LocalVariable* p = new LocalVariable(Scanner::kNoSourcePos, | 27 LocalVariable* p = new LocalVariable(Scanner::kNoSourcePos, |
28 String::ZoneHandle(String::New("p")), | 28 String::ZoneHandle(Symbols::New("p")), |
29 Type::ZoneHandle(Type::DynamicType())); | 29 Type::ZoneHandle(Type::DynamicType())); |
30 EXPECT(!p->HasIndex()); | 30 EXPECT(!p->HasIndex()); |
31 p->set_index(-1); | 31 p->set_index(-1); |
32 EXPECT(p->HasIndex()); | 32 EXPECT(p->HasIndex()); |
33 EXPECT_EQ(-1, p->index()); | 33 EXPECT_EQ(-1, p->index()); |
34 | 34 |
35 ReturnNode* r = new ReturnNode(Scanner::kNoSourcePos, lln); | 35 ReturnNode* r = new ReturnNode(Scanner::kNoSourcePos, lln); |
36 EXPECT_EQ(lln, r->value()); | 36 EXPECT_EQ(lln, r->value()); |
37 | 37 |
38 LiteralNode* l = | 38 LiteralNode* l = |
(...skipping 15 matching lines...) Expand all Loading... |
54 SequenceNode* sequence_node = new SequenceNode(1, new LocalScope(NULL, 0, 0)); | 54 SequenceNode* sequence_node = new SequenceNode(1, new LocalScope(NULL, 0, 0)); |
55 LiteralNode* literal_node = new LiteralNode(2, Smi::ZoneHandle(Smi::New(3))); | 55 LiteralNode* literal_node = new LiteralNode(2, Smi::ZoneHandle(Smi::New(3))); |
56 ReturnNode* return_node = new ReturnNode(3, literal_node); | 56 ReturnNode* return_node = new ReturnNode(3, literal_node); |
57 sequence_node->Add(return_node); | 57 sequence_node->Add(return_node); |
58 GrowableArray<AstNode*> nodes; | 58 GrowableArray<AstNode*> nodes; |
59 sequence_node->CollectAllNodes(&nodes); | 59 sequence_node->CollectAllNodes(&nodes); |
60 EXPECT_EQ(3, nodes.length()); | 60 EXPECT_EQ(3, nodes.length()); |
61 } | 61 } |
62 | 62 |
63 } // namespace dart | 63 } // namespace dart |
OLD | NEW |