| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library analyzer.test.dart.ast.visitor_test; | 5 library analyzer.test.dart.ast.visitor_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/visitor.dart'; | 8 import 'package:analyzer/dart/ast/visitor.dart'; |
| 9 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; |
| 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 return q() + 4; | 33 return q() + 4; |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 A f(var p) { | 36 A f(var p) { |
| 37 if ((p as A).g) { | 37 if ((p as A).g) { |
| 38 return p; | 38 return p; |
| 39 } else { | 39 } else { |
| 40 return null; | 40 return null; |
| 41 } | 41 } |
| 42 }'''; | 42 }'''; |
| 43 CompilationUnit unit = ParserTestCase.parseCompilationUnit(source); | 43 CompilationUnit unit = parseCompilationUnit(source); |
| 44 List<AstNode> nodes = new List<AstNode>(); | 44 List<AstNode> nodes = new List<AstNode>(); |
| 45 BreadthFirstVisitor<Object> visitor = | 45 BreadthFirstVisitor<Object> visitor = |
| 46 new _BreadthFirstVisitorTestHelper(nodes); | 46 new _BreadthFirstVisitorTestHelper(nodes); |
| 47 visitor.visitAllNodes(unit); | 47 visitor.visitAllNodes(unit); |
| 48 expect(nodes, hasLength(59)); | 48 expect(nodes, hasLength(59)); |
| 49 EngineTestCase.assertInstanceOf( | 49 EngineTestCase.assertInstanceOf( |
| 50 (obj) => obj is CompilationUnit, CompilationUnit, nodes[0]); | 50 (obj) => obj is CompilationUnit, CompilationUnit, nodes[0]); |
| 51 EngineTestCase.assertInstanceOf( | 51 EngineTestCase.assertInstanceOf( |
| 52 (obj) => obj is ClassDeclaration, ClassDeclaration, nodes[2]); | 52 (obj) => obj is ClassDeclaration, ClassDeclaration, nodes[2]); |
| 53 EngineTestCase.assertInstanceOf( | 53 EngineTestCase.assertInstanceOf( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 List<AstNode> nodes; | 70 List<AstNode> nodes; |
| 71 | 71 |
| 72 _BreadthFirstVisitorTestHelper(this.nodes) : super(); | 72 _BreadthFirstVisitorTestHelper(this.nodes) : super(); |
| 73 | 73 |
| 74 @override | 74 @override |
| 75 Object visitNode(AstNode node) { | 75 Object visitNode(AstNode node) { |
| 76 nodes.add(node); | 76 nodes.add(node); |
| 77 return super.visitNode(node); | 77 return super.visitNode(node); |
| 78 } | 78 } |
| 79 } | 79 } |
| OLD | NEW |