Chromium Code Reviews| 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 #import('mock_compiler.dart'); | |
| 5 #import('parser_helper.dart'); | 6 #import('parser_helper.dart'); |
| 7 #import("../../../lib/compiler/implementation/elements/elements.dart"); | |
| 6 #import("../../../lib/compiler/implementation/tree/tree.dart"); | 8 #import("../../../lib/compiler/implementation/tree/tree.dart"); |
| 7 | 9 |
| 8 testUnparse(String statement) { | 10 testUnparse(String statement) { |
| 9 Node node = parseStatement(statement); | 11 Node node = parseStatement(statement); |
| 10 Expect.equals(statement, node.unparse()); | 12 Expect.equals(statement, node.unparse()); |
| 11 } | 13 } |
| 12 | 14 |
| 13 testGenericTypes() { | 15 testGenericTypes() { |
| 14 testUnparse('var x=new List<List<int>>();'); | 16 testUnparse('var x=new List<List<int>>();'); |
| 15 testUnparse('var x=new List<List<List<int>>>();'); | 17 testUnparse('var x=new List<List<List<int>>>();'); |
| 16 testUnparse('var x=new List<List<List<List<int>>>>();'); | 18 testUnparse('var x=new List<List<List<List<int>>>>();'); |
| 17 testUnparse('var x=new List<List<List<List<List<int>>>>>();'); | 19 testUnparse('var x=new List<List<List<List<List<int>>>>>();'); |
| 18 } | 20 } |
| 19 | 21 |
| 20 testForLoop() { | 22 testForLoop() { |
| 21 testUnparse('for(;i<100;i++){}'); | 23 testUnparse('for(;i<100;i++){}'); |
| 22 testUnparse('for(i=0;i<100;i++){}'); | 24 testUnparse('for(i=0;i<100;i++){}'); |
| 23 } | 25 } |
| 24 | 26 |
| 25 testEmptyList() { | 27 testEmptyList() { |
| 26 testUnparse('var x= [];'); | 28 testUnparse('var x= [];'); |
| 27 } | 29 } |
| 28 | 30 |
| 31 testIndexedOperatorDecl() { | |
| 32 MockCompiler compiler = new MockCompiler(); | |
|
ahe
2012/06/19 16:42:45
Could you use this instead:
Node parseMember(Stri
Anton Muhin
2012/06/19 18:02:05
Neat, thanks, done (almost veni, vidi, vici :)
On
| |
| 33 var elements = parseUnit( | |
| 34 'class A { operator[](int i) => null; }', | |
| 35 compiler, compiler.mainApp); | |
| 36 ClassElement cls = elements.head.ensureResolved(compiler); | |
| 37 FunctionElement func = cls.members.head; | |
| 38 Node node = func.parseNode(compiler); | |
| 39 Expect.equals('operator[](int i)=> null;', '${node}'); | |
| 40 } | |
| 41 | |
| 29 main() { | 42 main() { |
| 30 testGenericTypes(); | 43 testGenericTypes(); |
| 31 testForLoop(); | 44 testForLoop(); |
| 32 testEmptyList(); | 45 testEmptyList(); |
| 46 testIndexedOperatorDecl(); | |
| 33 } | 47 } |
| OLD | NEW |