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

Unified Diff: pkg/analyzer/test/src/dart/analysis/defined_names_test.dart

Issue 2670843004: Record defined top-level/class-mebber names with unlinked bundles. (Closed)
Patch Set: Created 3 years, 11 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 | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/test/src/dart/analysis/file_state_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/dart/analysis/defined_names_test.dart
diff --git a/pkg/analyzer/test/src/dart/analysis/defined_names_test.dart b/pkg/analyzer/test/src/dart/analysis/defined_names_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..bc34e50dc2621c6d9e58b582dc917ae9a638d97c
--- /dev/null
+++ b/pkg/analyzer/test/src/dart/analysis/defined_names_test.dart
@@ -0,0 +1,58 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/analysis/defined_names.dart';
+import 'package:test/test.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../../../generated/parser_test.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(DefinedNamesTest);
+ });
+}
+
+@reflectiveTest
+class DefinedNamesTest {
+ test_classMemberNames() {
+ DefinedNames names = _computeDefinedNames('''
+class A {
+ int a, b;
+ A();
+ A.c();
+ d() {}
+ get e => null;
+ set f(_) {}
+}
+class B {
+ g() {}
+}
+''');
+ expect(names.topLevelNames, unorderedEquals(['A', 'B']));
+ expect(names.classMemberNames,
+ unorderedEquals(['a', 'b', 'd', 'e', 'f', 'g']));
+ }
+
+ test_topLevelNames() {
+ DefinedNames names = _computeDefinedNames('''
+class A {}
+class B = Object with A;
+typedef C {}
+D() {}
+get E => null;
+set F(_) {}
+var G, H;
+''');
+ expect(names.topLevelNames,
+ unorderedEquals(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']));
+ expect(names.classMemberNames, isEmpty);
+ }
+
+ DefinedNames _computeDefinedNames(String code) {
+ CompilationUnit unit = ParserTestCase.parseCompilationUnit2(code);
+ return computeDefinedNames(unit);
+ }
+}
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/test/src/dart/analysis/file_state_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698