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

Side by Side Diff: packages/analyzer/test/src/util/absolute_path_test.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library analyzer.test.src.util.absolute_path_test;
6
7 import 'package:analyzer/src/util/absolute_path.dart';
8 import 'package:test_reflective_loader/test_reflective_loader.dart';
9 import 'package:unittest/unittest.dart';
10
11 import '../../utils.dart';
12
13 main() {
14 initializeTestEnvironment();
15 defineReflectiveTests(AbsolutePathContextPosixTest);
16 defineReflectiveTests(AbsolutePathContextWindowsTest);
17 }
18
19 @reflectiveTest
20 class AbsolutePathContextPosixTest {
21 AbsolutePathContext context = new AbsolutePathContext(false);
22
23 void test_append() {
24 expect(context.append(r'/path/to', r'foo.dart'), r'/path/to/foo.dart');
25 }
26
27 void test_basename() {
28 expect(context.basename(r'/path/to/foo.dart'), r'foo.dart');
29 expect(context.basename(r'/path/to'), r'to');
30 expect(context.basename(r'/path'), r'path');
31 expect(context.basename(r'/'), r'');
32 }
33
34 void test_dirname() {
35 expect(context.dirname(r'/path/to/foo.dart'), r'/path/to');
36 expect(context.dirname(r'/path/to'), r'/path');
37 expect(context.dirname(r'/path'), r'/');
38 expect(context.dirname(r'/'), r'/');
39 }
40
41 void test_isValid_absolute() {
42 expect(context.isValid(r'/foo/bar'), isTrue);
43 expect(context.isValid(r'/foo'), isTrue);
44 expect(context.isValid(r'/'), isTrue);
45 expect(context.isValid(r''), isFalse);
46 expect(context.isValid(r'foo/bar'), isFalse);
47 }
48
49 void test_isValid_normalized() {
50 expect(context.isValid(r'/foo/bar'), isTrue);
51 expect(context.isValid(r'/foo/..bar'), isTrue);
52 expect(context.isValid(r'/foo/.bar/baz'), isTrue);
53 expect(context.isValid(r'/foo/...'), isTrue);
54 expect(context.isValid(r'/foo/bar..'), isTrue);
55 expect(context.isValid(r'/foo/.../bar'), isTrue);
56 expect(context.isValid(r'/foo/.bar/.'), isFalse);
57 expect(context.isValid(r'/foo/bar/../baz'), isFalse);
58 expect(context.isValid(r'/foo/bar/..'), isFalse);
59 expect(context.isValid(r'/foo/./bar'), isFalse);
60 expect(context.isValid(r'/.'), isFalse);
61 }
62
63 void test_isWithin() {
64 expect(context.isWithin(r'/root/path', r'/root/path/a'), isTrue);
65 expect(context.isWithin(r'/root/path', r'/root/other'), isFalse);
66 expect(context.isWithin(r'/root/path', r'/root/path'), isFalse);
67 }
68
69 void test_split() {
70 expect(context.split(r'/path/to/foo'), [r'', r'path', r'to', r'foo']);
71 expect(context.split(r'/path'), [r'', r'path']);
72 }
73
74 void test_suffix() {
75 expect(context.suffix(r'/root/path', r'/root/path/a/b.dart'), r'a/b.dart');
76 expect(context.suffix(r'/root/path', r'/root/other.dart'), isNull);
77 }
78 }
79
80 @reflectiveTest
81 class AbsolutePathContextWindowsTest {
82 AbsolutePathContext context = new AbsolutePathContext(true);
83
84 void test_append() {
85 expect(context.append(r'C:\path\to', r'foo.dart'), r'C:\path\to\foo.dart');
86 }
87
88 void test_basename() {
89 expect(context.basename(r'C:\path\to\foo.dart'), r'foo.dart');
90 expect(context.basename(r'C:\path\to'), r'to');
91 expect(context.basename(r'C:\path'), r'path');
92 expect(context.basename(r'C:\'), r'');
93 }
94
95 void test_dirname() {
96 expect(context.dirname(r'C:\path\to\foo.dart'), r'C:\path\to');
97 expect(context.dirname(r'C:\path\to'), r'C:\path');
98 expect(context.dirname(r'C:\path'), r'C:\');
99 expect(context.dirname(r'C:\'), r'C:\');
100 }
101
102 void test_isValid_absolute() {
103 expect(context.isValid(r'C:\foo\bar'), isTrue);
104 expect(context.isValid(r'c:\foo\bar'), isTrue);
105 expect(context.isValid(r'D:\foo\bar'), isTrue);
106 expect(context.isValid(r'C:\foo'), isTrue);
107 expect(context.isValid(r'C:\'), isTrue);
108 expect(context.isValid(r''), isFalse);
109 expect(context.isValid(r'foo\bar'), isFalse);
110 }
111
112 void test_isValid_normalized() {
113 expect(context.isValid(r'C:\foo\bar'), isTrue);
114 expect(context.isValid(r'C:\foo\..bar'), isTrue);
115 expect(context.isValid(r'C:\foo\.bar\baz'), isTrue);
116 expect(context.isValid(r'C:\foo\...'), isTrue);
117 expect(context.isValid(r'C:\foo\bar..'), isTrue);
118 expect(context.isValid(r'C:\foo\...\bar'), isTrue);
119 expect(context.isValid(r'C:\foo\.bar\.'), isFalse);
120 expect(context.isValid(r'C:\foo\bar\..\baz'), isFalse);
121 expect(context.isValid(r'C:\foo\bar\..'), isFalse);
122 expect(context.isValid(r'C:\foo\.\bar'), isFalse);
123 expect(context.isValid(r'C:\.'), isFalse);
124 }
125
126 void test_isWithin() {
127 expect(context.isWithin(r'C:\root\path', r'C:\root\path\a'), isTrue);
128 expect(context.isWithin(r'C:\root\path', r'C:\root\other'), isFalse);
129 expect(context.isWithin(r'C:\root\path', r'C:\root\path'), isFalse);
130 }
131
132 void test_split() {
133 expect(context.split(r'C:\path\to\foo'), [r'C:', r'path', r'to', r'foo']);
134 expect(context.split(r'C:\path'), [r'C:', r'path']);
135 }
136
137 void test_suffix() {
138 expect(
139 context.suffix(r'C:\root\path', r'C:\root\path\a\b.dart'), r'a\b.dart');
140 expect(context.suffix(r'C:\root\path', r'C:\root\other.dart'), isNull);
141 }
142 }
OLDNEW
« no previous file with comments | « packages/analyzer/test/src/test_all.dart ('k') | packages/analyzer/test/src/util/asserts_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698