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

Unified Diff: dart/tests/try/poi/poi_find_test.dart

Issue 394543002: Find token at position and query Dart Mind if identifier or keyword. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r39130. Created 6 years, 4 months 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 | « dart/tests/try/poi/data/empty_main.dart ('k') | dart/tests/try/poi/poi_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/try/poi/poi_find_test.dart
diff --git a/dart/tests/try/poi/poi_find_test.dart b/dart/tests/try/poi/poi_find_test.dart
index 3830020c65ddb0d32749660fc6c3dc0ae44b2dc1..495e59f7c983fd71ddabdf11fe80b18db3843ee6 100644
--- a/dart/tests/try/poi/poi_find_test.dart
+++ b/dart/tests/try/poi/poi_find_test.dart
@@ -27,13 +27,47 @@ import 'package:compiler/implementation/source_file_provider.dart' show
Future testPoi() {
Uri script = Platform.script.resolve('data/empty_main.dart');
FormattingDiagnosticHandler handler = new FormattingDiagnosticHandler();
- handler.verbose = true;
+ handler.verbose = false;
Future future = poi.runPoi(script, 225, handler.provider, handler);
return future.then((Element element) {
Uri foundScript = element.compilationUnit.script.resourceUri;
Expect.stringEquals('$script', '$foundScript');
Expect.stringEquals('main', element.name);
+
+ String source = handler.provider.sourceFiles['$script'].slowText();
+ final int position = source.indexOf('main()');
+ Expect.isTrue(position > 0, '$position > 0');
+
+ var token;
+
+ // When the cursor is at the same character offset as "main()", it
+ // corresponds to having the cursor just before "main()". So we find the
+ // "void" token.
+ token = poi.findToken(element, position);
+ Expect.isNotNull(token, 'token');
+ Expect.stringEquals('void', token.value);
+
+ // Cursor at position + 1 corresponds to having the cursor just after "m"
+ // in "main()". So we find the "main" token.
+ token = poi.findToken(element, position + 1);
+ Expect.isNotNull(token, 'token');
+ Expect.equals(position, token.charOffset);
+ Expect.stringEquals('main', token.value);
+
+ // This corresponds to the cursor after "main", but before "()" in
+ // "main()". So we find the "main" token.
+ token = poi.findToken(element, position + 4);
+ Expect.isNotNull(token, 'token');
+ Expect.equals(position, token.charOffset);
+ Expect.stringEquals('main', token.value);
+
+ // This corresponds to the cursor after "(" in "main()". So we find the "("
+ // token.
+ token = poi.findToken(element, position + 5);
+ Expect.isNotNull(token, 'token');
+ Expect.equals(position + 4, token.charOffset, '$token');
+ Expect.stringEquals('(', token.value);
});
}
« no previous file with comments | « dart/tests/try/poi/data/empty_main.dart ('k') | dart/tests/try/poi/poi_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698