Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: pkg/analyzer/test/generated/ast_test.dart

Issue 1490933002: New NodeLocator which uses positions of characters, not between them. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/ast_test.dart
diff --git a/pkg/analyzer/test/generated/ast_test.dart b/pkg/analyzer/test/generated/ast_test.dart
index 24958de3a3a80bcfb3dc1d2f797e2393fa32e4f3..fd888ccec26c3eb1346c6aa1a73fa612d5f3fc65 100644
--- a/pkg/analyzer/test/generated/ast_test.dart
+++ b/pkg/analyzer/test/generated/ast_test.dart
@@ -29,6 +29,7 @@ main() {
runReflectiveTests(IndexExpressionTest);
runReflectiveTests(NodeListTest);
runReflectiveTests(NodeLocatorTest);
+ runReflectiveTests(NodeLocator2Test);
runReflectiveTests(SimpleIdentifierTest);
runReflectiveTests(SimpleStringLiteralTest);
runReflectiveTests(StringInterpolationTest);
@@ -945,6 +946,35 @@ class NodeListTest extends EngineTestCase {
}
@reflectiveTest
+class NodeLocator2Test extends ParserTestCase {
+ void test_onlyStartOffset() {
+ CompilationUnit unit = ParserTestCase.parseCompilationUnit(' int vv;');
+ TopLevelVariableDeclaration declaration = unit.declarations[0];
+ VariableDeclarationList variableList = declaration.variables;
+ Identifier typeName = variableList.type.name;
+ expect(new NodeLocator2(0).searchWithin(unit), same(unit));
+ expect(new NodeLocator2(1).searchWithin(unit), same(typeName));
+ expect(new NodeLocator2(2).searchWithin(unit), same(typeName));
+ expect(new NodeLocator2(3).searchWithin(unit), same(typeName));
+ expect(new NodeLocator2(4).searchWithin(unit), same(variableList));
+ }
+
+ void test_startEndOffset() {
+ CompilationUnit unit = ParserTestCase.parseCompilationUnit(' int vv; ');
+ TopLevelVariableDeclaration declaration = unit.declarations[0];
+ VariableDeclarationList variableList = declaration.variables;
+ Identifier typeName = variableList.type.name;
+ SimpleIdentifier varName = variableList.variables[0].name;
+ expect(new NodeLocator2(0, 2).searchWithin(unit), same(unit));
+ expect(new NodeLocator2(1, 2).searchWithin(unit), same(typeName));
+ expect(new NodeLocator2(1, 3).searchWithin(unit), same(typeName));
+ expect(new NodeLocator2(1, 4).searchWithin(unit), same(variableList));
+ expect(new NodeLocator2(5, 6).searchWithin(unit), same(varName));
+ expect(new NodeLocator2(5, 7).searchWithin(unit), same(declaration));
+ }
+}
+
+@reflectiveTest
class NodeLocatorTest extends ParserTestCase {
void test_range() {
CompilationUnit unit =
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698