| 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.src.dart.ast.utilities_test; | 5 library analyzer.test.src.dart.ast.utilities_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/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 void test_searchWithin_offsetBeforeNode() { | 413 void test_searchWithin_offsetBeforeNode() { |
| 414 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' | 414 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' |
| 415 class A {} | 415 class A {} |
| 416 class B {}'''); | 416 class B {}'''); |
| 417 NodeLocator locator = new NodeLocator(0, 0); | 417 NodeLocator locator = new NodeLocator(0, 0); |
| 418 AstNode node = locator.searchWithin(unit.declarations[1]); | 418 AstNode node = locator.searchWithin(unit.declarations[1]); |
| 419 expect(node, isNull); | 419 expect(node, isNull); |
| 420 } | 420 } |
| 421 | 421 |
| 422 void _assertLocate(CompilationUnit unit, int start, int end, | 422 void _assertLocate(CompilationUnit unit, int start, int end, |
| 423 Predicate<AstNode> predicate, Type expectedClass) { | 423 Predicate<Object> predicate, Type expectedClass) { |
| 424 NodeLocator locator = new NodeLocator(start, end); | 424 NodeLocator locator = new NodeLocator(start, end); |
| 425 AstNode node = locator.searchWithin(unit); | 425 AstNode node = locator.searchWithin(unit); |
| 426 expect(node, isNotNull); | 426 expect(node, isNotNull); |
| 427 expect(locator.foundNode, same(node)); | 427 expect(locator.foundNode, same(node)); |
| 428 expect(node.offset <= start, isTrue, reason: "Node starts after range"); | 428 expect(node.offset <= start, isTrue, reason: "Node starts after range"); |
| 429 expect(node.offset + node.length > end, isTrue, | 429 expect(node.offset + node.length > end, isTrue, |
| 430 reason: "Node ends before range"); | 430 reason: "Node ends before range"); |
| 431 EngineTestCase.assertInstanceOf(predicate, expectedClass, node); | 431 EngineTestCase.assertInstanceOf(predicate, expectedClass, node); |
| 432 } | 432 } |
| 433 } | 433 } |
| (...skipping 2886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3320 * @param expectedSource the source string that the visitor is expected to pro
duce | 3320 * @param expectedSource the source string that the visitor is expected to pro
duce |
| 3321 * @param node the AST node being visited to produce the actual source | 3321 * @param node the AST node being visited to produce the actual source |
| 3322 * @throws AFE if the visitor does not produce the expected source for the giv
en node | 3322 * @throws AFE if the visitor does not produce the expected source for the giv
en node |
| 3323 */ | 3323 */ |
| 3324 void _assertSource(String expectedSource, AstNode node) { | 3324 void _assertSource(String expectedSource, AstNode node) { |
| 3325 PrintStringWriter writer = new PrintStringWriter(); | 3325 PrintStringWriter writer = new PrintStringWriter(); |
| 3326 node.accept(new ToSourceVisitor(writer)); | 3326 node.accept(new ToSourceVisitor(writer)); |
| 3327 expect(writer.toString(), expectedSource); | 3327 expect(writer.toString(), expectedSource); |
| 3328 } | 3328 } |
| 3329 } | 3329 } |
| OLD | NEW |