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

Unified Diff: test/rule_test.dart

Issue 1425293002: Lint to test for private/implementation imports. (Closed) Base URL: https://github.com/dart-lang/linter.git@master
Patch Set: Created 5 years, 2 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
Index: test/rule_test.dart
diff --git a/test/rule_test.dart b/test/rule_test.dart
index f4286eefc70bb1ebbd34911029ad5149673c2609..414f865daef919f38f6f5808b541a3af8568633a 100644
--- a/test/rule_test.dart
+++ b/test/rule_test.dart
@@ -14,6 +14,7 @@ import 'package:linter/src/io.dart';
import 'package:linter/src/linter.dart';
import 'package:linter/src/rules.dart';
import 'package:linter/src/rules/camel_case_types.dart';
+import 'package:linter/src/rules/implementation_imports.dart';
import 'package:linter/src/rules/package_prefixed_library_names.dart';
import 'package:linter/src/util.dart';
import 'package:path/path.dart' as p;
@@ -55,6 +56,62 @@ defineRuleTests() {
}
defineRuleUnitTests() {
+ group('uris', () {
+ group('isPackage', () {
+ var uris = [
+ Uri.parse('package:foo/src/bar.dart'),
+ Uri.parse('package:foo/src/baz/bar.dart')
+ ];
+ uris.forEach((uri) {
+ test(uri.toString(), () {
+ expect(isPackage(uri), isTrue);
+ });
+ });
+ var uris2 = [Uri.parse('foo/bar.dart'), Uri.parse('src/bar.dart')];
Brian Wilkerson 2015/10/31 21:04:30 Include a non-package, but absolute, URI (such as
pquitslund 2015/10/31 23:13:09 Good one. Done!
+ uris2.forEach((uri) {
+ test(uri.toString(), () {
+ expect(isPackage(uri), isFalse);
+ });
+ });
+ });
+
+ group('samePackage', () {
+ test('identity', () {
+ expect(
+ samePackage(Uri.parse('package:foo/src/bar.dart'),
+ Uri.parse('package:foo/src/bar.dart')),
+ isTrue);
+ });
+ test('foo/bar.dart', () {
+ expect(
+ samePackage(Uri.parse('package:foo/src/bar.dart'),
+ Uri.parse('package:foo/bar.dart')),
+ isTrue);
+ });
+ });
+
+ group('implementation', () {
+ var uris = [
+ Uri.parse('package:foo/src/bar.dart'),
+ Uri.parse('package:foo/src/baz/bar.dart')
+ ];
+ uris.forEach((uri) {
+ test(uri.toString(), () {
+ expect(isImplementation(uri), isTrue);
+ });
+ });
+ var uris2 = [
+ Uri.parse('package:foo/bar.dart'),
+ Uri.parse('src/bar.dart')
+ ];
+ uris2.forEach((uri) {
+ test(uri.toString(), () {
+ expect(isImplementation(uri), isFalse);
+ });
+ });
+ });
+ });
+
group('names', () {
group('keywords', () {
var good = ['class', 'if', 'assert', 'catch', 'import'];

Powered by Google App Engine
This is Rietveld 408576698