| 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::kDummyTokenIndex, | 16 LocalVariable* v = new LocalVariable(Scanner::kDummyTokenIndex, |
| 17 String::ZoneHandle(String::New("v")), | 17 String::ZoneHandle(String::New("v")), |
| 18 Type::ZoneHandle(Type::DynamicType())); | 18 Type::ZoneHandle(Type::DynamicType())); |
| 19 AstNode* ll = new LoadLocalNode(Scanner::kDummyTokenIndex, *v); | 19 AstNode* ll = new LoadLocalNode(Scanner::kDummyTokenIndex, 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::kDummyTokenIndex, | 27 LocalVariable* p = new LocalVariable(Scanner::kDummyTokenIndex, |
| 28 String::ZoneHandle(String::New("p")), | 28 String::ZoneHandle(String::New("p")), |
| 29 Type::ZoneHandle(Type::DynamicType())); | 29 Type::ZoneHandle(Type::DynamicType())); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 53 SequenceNode* sequence_node = new SequenceNode(1, new LocalScope(NULL, 0, 0)); | 53 SequenceNode* sequence_node = new SequenceNode(1, new LocalScope(NULL, 0, 0)); |
| 54 LiteralNode* literal_node = new LiteralNode(2, Smi::ZoneHandle(Smi::New(3))); | 54 LiteralNode* literal_node = new LiteralNode(2, Smi::ZoneHandle(Smi::New(3))); |
| 55 ReturnNode* return_node = new ReturnNode(3, literal_node); | 55 ReturnNode* return_node = new ReturnNode(3, literal_node); |
| 56 sequence_node->Add(return_node); | 56 sequence_node->Add(return_node); |
| 57 GrowableArray<AstNode*> nodes; | 57 GrowableArray<AstNode*> nodes; |
| 58 sequence_node->CollectAllNodes(&nodes); | 58 sequence_node->CollectAllNodes(&nodes); |
| 59 EXPECT_EQ(3, nodes.length()); | 59 EXPECT_EQ(3, nodes.length()); |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace dart | 62 } // namespace dart |
| OLD | NEW |