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

Side by Side Diff: pkg/watcher/test/path_set_test.dart

Issue 68683004: Make path_set_test use Windows-friendly paths where necessary. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: typo Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:path/path.dart' as p; 5 import 'package:path/path.dart' as p;
6 import 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:watcher/src/path_set.dart'; 7 import 'package:watcher/src/path_set.dart';
8 8
9 import 'utils.dart'; 9 import 'utils.dart';
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 test("that's not beneath the root throws an error", () { 48 test("that's not beneath the root throws an error", () {
49 expect(() => set.add("path/to/file"), throwsArgumentError); 49 expect(() => set.add("path/to/file"), throwsArgumentError);
50 }); 50 });
51 }); 51 });
52 52
53 group("removing a path", () { 53 group("removing a path", () {
54 test("that's in the set removes and returns that path", () { 54 test("that's in the set removes and returns that path", () {
55 set.add("root/path/to/file"); 55 set.add("root/path/to/file");
56 expect(set.remove("root/path/to/file"), 56 expect(set.remove("root/path/to/file"),
57 unorderedEquals(["root/path/to/file"])); 57 unorderedEquals([p.normalize("root/path/to/file")]));
58 expect(set, isNot(containsPath("root/path/to/file"))); 58 expect(set, isNot(containsPath("root/path/to/file")));
59 }); 59 });
60 60
61 test("that's not in the set returns an empty set", () { 61 test("that's not in the set returns an empty set", () {
62 set.add("root/path/to/file"); 62 set.add("root/path/to/file");
63 expect(set.remove("root/path/to/nothing"), isEmpty); 63 expect(set.remove("root/path/to/nothing"), isEmpty);
64 }); 64 });
65 65
66 test("that's a directory removes and returns all files beneath it", () { 66 test("that's a directory removes and returns all files beneath it", () {
67 set.add("root/outside"); 67 set.add("root/outside");
68 set.add("root/path/to/one"); 68 set.add("root/path/to/one");
69 set.add("root/path/to/two"); 69 set.add("root/path/to/two");
70 set.add("root/path/to/sub/three"); 70 set.add("root/path/to/sub/three");
71 71
72 expect(set.remove("root/path"), unorderedEquals([ 72 expect(set.remove("root/path"), unorderedEquals([
73 "root/path/to/one", 73 "root/path/to/one",
74 "root/path/to/two", 74 "root/path/to/two",
75 "root/path/to/sub/three" 75 "root/path/to/sub/three"
76 ])); 76 ].map(p.normalize)));
77 77
78 expect(set, containsPath("root/outside")); 78 expect(set, containsPath("root/outside"));
79 expect(set, isNot(containsPath("root/path/to/one"))); 79 expect(set, isNot(containsPath("root/path/to/one")));
80 expect(set, isNot(containsPath("root/path/to/two"))); 80 expect(set, isNot(containsPath("root/path/to/two")));
81 expect(set, isNot(containsPath("root/path/to/sub/three"))); 81 expect(set, isNot(containsPath("root/path/to/sub/three")));
82 }); 82 });
83 83
84 test("that's a directory in the set removes and returns it and all files " 84 test("that's a directory in the set removes and returns it and all files "
85 "beneath it", () { 85 "beneath it", () {
86 set.add("root/path"); 86 set.add("root/path");
87 set.add("root/path/to/one"); 87 set.add("root/path/to/one");
88 set.add("root/path/to/two"); 88 set.add("root/path/to/two");
89 set.add("root/path/to/sub/three"); 89 set.add("root/path/to/sub/three");
90 90
91 expect(set.remove("root/path"), unorderedEquals([ 91 expect(set.remove("root/path"), unorderedEquals([
92 "root/path", 92 "root/path",
93 "root/path/to/one", 93 "root/path/to/one",
94 "root/path/to/two", 94 "root/path/to/two",
95 "root/path/to/sub/three" 95 "root/path/to/sub/three"
96 ])); 96 ].map(p.normalize)));
97 97
98 expect(set, isNot(containsPath("root/path"))); 98 expect(set, isNot(containsPath("root/path")));
99 expect(set, isNot(containsPath("root/path/to/one"))); 99 expect(set, isNot(containsPath("root/path/to/one")));
100 expect(set, isNot(containsPath("root/path/to/two"))); 100 expect(set, isNot(containsPath("root/path/to/two")));
101 expect(set, isNot(containsPath("root/path/to/sub/three"))); 101 expect(set, isNot(containsPath("root/path/to/sub/three")));
102 }); 102 });
103 103
104 test("that's not normalized removes and returns the normalized path", () { 104 test("that's not normalized removes and returns the normalized path", () {
105 set.add("root/path/to/file"); 105 set.add("root/path/to/file");
106 expect(set.remove("root/../root/path/to/../to/./file"), 106 expect(set.remove("root/../root/path/to/../to/./file"),
107 unorderedEquals(["root/path/to/file"])); 107 unorderedEquals([p.normalize("root/path/to/file")]));
108 }); 108 });
109 109
110 test("that's absolute removes and returns the normalized path", () { 110 test("that's absolute removes and returns the normalized path", () {
111 set.add("root/path/to/file"); 111 set.add("root/path/to/file");
112 expect(set.remove(p.absolute("root/path/to/file")), 112 expect(set.remove(p.absolute("root/path/to/file")),
113 unorderedEquals(["root/path/to/file"])); 113 unorderedEquals([p.normalize("root/path/to/file")]));
114 }); 114 });
115 115
116 test("that's not beneath the root throws an error", () { 116 test("that's not beneath the root throws an error", () {
117 expect(() => set.remove("path/to/file"), throwsArgumentError); 117 expect(() => set.remove("path/to/file"), throwsArgumentError);
118 }); 118 });
119 }); 119 });
120 120
121 group("containsPath()", () { 121 group("containsPath()", () {
122 test("returns false for a non-existent path", () { 122 test("returns false for a non-existent path", () {
123 set.add("root/path/to/file"); 123 set.add("root/path/to/file");
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 group("toSet", () { 203 group("toSet", () {
204 test("returns paths added to the set", () { 204 test("returns paths added to the set", () {
205 set.add("root/path"); 205 set.add("root/path");
206 set.add("root/path/to/one"); 206 set.add("root/path/to/one");
207 set.add("root/path/to/two"); 207 set.add("root/path/to/two");
208 208
209 expect(set.toSet(), unorderedEquals([ 209 expect(set.toSet(), unorderedEquals([
210 "root/path", 210 "root/path",
211 "root/path/to/one", 211 "root/path/to/one",
212 "root/path/to/two", 212 "root/path/to/two",
213 ])); 213 ].map(p.normalize)));
214 }); 214 });
215 215
216 test("doesn't return paths removed from the set", () { 216 test("doesn't return paths removed from the set", () {
217 set.add("root/path/to/one"); 217 set.add("root/path/to/one");
218 set.add("root/path/to/two"); 218 set.add("root/path/to/two");
219 set.remove("root/path/to/two"); 219 set.remove("root/path/to/two");
220 220
221 expect(set.toSet(), unorderedEquals(["root/path/to/one"])); 221 expect(set.toSet(), unorderedEquals([p.normalize("root/path/to/one")]));
222 }); 222 });
223 }); 223 });
224 224
225 group("clear", () { 225 group("clear", () {
226 test("removes all paths from the set", () { 226 test("removes all paths from the set", () {
227 set.add("root/path"); 227 set.add("root/path");
228 set.add("root/path/to/one"); 228 set.add("root/path/to/one");
229 set.add("root/path/to/two"); 229 set.add("root/path/to/two");
230 230
231 set.clear(); 231 set.clear();
232 expect(set.toSet(), isEmpty); 232 expect(set.toSet(), isEmpty);
233 }); 233 });
234 }); 234 });
235 } 235 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698