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

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: Review fixes. 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
« no previous file with comments | « lib/src/rules/implementation_imports.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/rule_test.dart
diff --git a/test/rule_test.dart b/test/rule_test.dart
index f4286eefc70bb1ebbd34911029ad5149673c2609..76ee4d511410daf3c512d58ded16114a7b371fa4 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,66 @@ 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'),
+ Uri.parse('dart:async')
+ ];
+ 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'];
« no previous file with comments | « lib/src/rules/implementation_imports.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698