OLD | NEW |
| 1 // Copyright (c) 2012, 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 |
1 library lock_file_test; | 5 library lock_file_test; |
| 6 |
2 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 |
3 import '../lib/src/ascii_tree.dart' as tree; | 9 import '../lib/src/ascii_tree.dart' as tree; |
4 import '../lib/src/utils.dart'; | 10 import '../lib/src/utils.dart'; |
| 11 |
5 main() { | 12 main() { |
6 runningAsTest = true; | 13 runningAsTest = true; |
| 14 |
7 group('tree.fromFiles', () { | 15 group('tree.fromFiles', () { |
8 test('no files', () { | 16 test('no files', () { |
9 expect(tree.fromFiles([]), equals("")); | 17 expect(tree.fromFiles([]), equals("")); |
10 }); | 18 }); |
| 19 |
11 test('up to ten files in one directory are shown', () { | 20 test('up to ten files in one directory are shown', () { |
12 var files = [ | 21 var files = [ |
13 "dir/a.dart", | 22 "dir/a.dart", |
14 "dir/b.dart", | 23 "dir/b.dart", |
15 "dir/c.dart", | 24 "dir/c.dart", |
16 "dir/d.dart", | 25 "dir/d.dart", |
17 "dir/e.dart", | 26 "dir/e.dart", |
18 "dir/f.dart", | 27 "dir/f.dart", |
19 "dir/g.dart", | 28 "dir/g.dart", |
20 "dir/h.dart", | 29 "dir/h.dart", |
21 "dir/i.dart", | 30 "dir/i.dart", |
22 "dir/j.dart"]; | 31 "dir/j.dart"]; |
23 expect(tree.fromFiles(files), equals(""" | 32 expect(tree.fromFiles(files), equals(""" |
24 '-- dir | 33 '-- dir |
25 |-- a.dart | 34 |-- a.dart |
26 |-- b.dart | 35 |-- b.dart |
27 |-- c.dart | 36 |-- c.dart |
28 |-- d.dart | 37 |-- d.dart |
29 |-- e.dart | 38 |-- e.dart |
30 |-- f.dart | 39 |-- f.dart |
31 |-- g.dart | 40 |-- g.dart |
32 |-- h.dart | 41 |-- h.dart |
33 |-- i.dart | 42 |-- i.dart |
34 '-- j.dart | 43 '-- j.dart |
35 """)); | 44 """)); |
36 }); | 45 }); |
| 46 |
37 test('files are elided if there are more than ten', () { | 47 test('files are elided if there are more than ten', () { |
38 var files = [ | 48 var files = [ |
39 "dir/a.dart", | 49 "dir/a.dart", |
40 "dir/b.dart", | 50 "dir/b.dart", |
41 "dir/c.dart", | 51 "dir/c.dart", |
42 "dir/d.dart", | 52 "dir/d.dart", |
43 "dir/e.dart", | 53 "dir/e.dart", |
44 "dir/f.dart", | 54 "dir/f.dart", |
45 "dir/g.dart", | 55 "dir/g.dart", |
46 "dir/h.dart", | 56 "dir/h.dart", |
47 "dir/i.dart", | 57 "dir/i.dart", |
48 "dir/j.dart", | 58 "dir/j.dart", |
49 "dir/k.dart"]; | 59 "dir/k.dart"]; |
50 expect(tree.fromFiles(files), equals(""" | 60 expect(tree.fromFiles(files), equals(""" |
51 '-- dir | 61 '-- dir |
52 |-- a.dart | 62 |-- a.dart |
53 |-- b.dart | 63 |-- b.dart |
54 |-- c.dart | 64 |-- c.dart |
55 | (5 more...) | 65 | (5 more...) |
56 |-- i.dart | 66 |-- i.dart |
57 |-- j.dart | 67 |-- j.dart |
58 '-- k.dart | 68 '-- k.dart |
59 """)); | 69 """)); |
60 }); | 70 }); |
| 71 |
61 test('files are not elided at the top level', () { | 72 test('files are not elided at the top level', () { |
62 var files = [ | 73 var files = [ |
63 "a.dart", | 74 "a.dart", |
64 "b.dart", | 75 "b.dart", |
65 "c.dart", | 76 "c.dart", |
66 "d.dart", | 77 "d.dart", |
67 "e.dart", | 78 "e.dart", |
68 "f.dart", | 79 "f.dart", |
69 "g.dart", | 80 "g.dart", |
70 "h.dart", | 81 "h.dart", |
71 "i.dart", | 82 "i.dart", |
72 "j.dart", | 83 "j.dart", |
73 "k.dart"]; | 84 "k.dart"]; |
74 expect(tree.fromFiles(files), equals(""" | 85 expect(tree.fromFiles(files), equals(""" |
75 |-- a.dart | 86 |-- a.dart |
76 |-- b.dart | 87 |-- b.dart |
77 |-- c.dart | 88 |-- c.dart |
78 |-- d.dart | 89 |-- d.dart |
79 |-- e.dart | 90 |-- e.dart |
80 |-- f.dart | 91 |-- f.dart |
81 |-- g.dart | 92 |-- g.dart |
82 |-- h.dart | 93 |-- h.dart |
83 |-- i.dart | 94 |-- i.dart |
84 |-- j.dart | 95 |-- j.dart |
85 '-- k.dart | 96 '-- k.dart |
86 """)); | 97 """)); |
87 }); | 98 }); |
| 99 |
88 test('a complex example', () { | 100 test('a complex example', () { |
89 var files = [ | 101 var files = [ |
90 "TODO", | 102 "TODO", |
91 "example/console_example.dart", | 103 "example/console_example.dart", |
92 "example/main.dart", | 104 "example/main.dart", |
93 "example/web copy/web_example.dart", | 105 "example/web copy/web_example.dart", |
94 "test/absolute_test.dart", | 106 "test/absolute_test.dart", |
95 "test/basename_test.dart", | 107 "test/basename_test.dart", |
96 "test/dirname_test.dart", | 108 "test/dirname_test.dart", |
97 "test/extension_test.dart", | 109 "test/extension_test.dart", |
98 "test/is_absolute_test.dart", | 110 "test/is_absolute_test.dart", |
99 "test/is_relative_test.dart", | 111 "test/is_relative_test.dart", |
100 "test/join_test.dart", | 112 "test/join_test.dart", |
101 "test/normalize_test.dart", | 113 "test/normalize_test.dart", |
102 "test/relative_test.dart", | 114 "test/relative_test.dart", |
103 "test/split_test.dart", | 115 "test/split_test.dart", |
104 ".gitignore", | 116 ".gitignore", |
105 "README.md", | 117 "README.md", |
106 "lib/path.dart", | 118 "lib/path.dart", |
107 "pubspec.yaml", | 119 "pubspec.yaml", |
108 "test/all_test.dart", | 120 "test/all_test.dart", |
109 "test/path_posix_test.dart", | 121 "test/path_posix_test.dart", |
110 "test/path_windows_test.dart"]; | 122 "test/path_windows_test.dart"]; |
| 123 |
111 expect(tree.fromFiles(files), equals(""" | 124 expect(tree.fromFiles(files), equals(""" |
112 |-- .gitignore | 125 |-- .gitignore |
113 |-- README.md | 126 |-- README.md |
114 |-- TODO | 127 |-- TODO |
115 |-- example | 128 |-- example |
116 | |-- console_example.dart | 129 | |-- console_example.dart |
117 | |-- main.dart | 130 | |-- main.dart |
118 | '-- web copy | 131 | '-- web copy |
119 | '-- web_example.dart | 132 | '-- web_example.dart |
120 |-- lib | 133 |-- lib |
121 | '-- path.dart | 134 | '-- path.dart |
122 |-- pubspec.yaml | 135 |-- pubspec.yaml |
123 '-- test | 136 '-- test |
124 |-- absolute_test.dart | 137 |-- absolute_test.dart |
125 |-- all_test.dart | 138 |-- all_test.dart |
126 |-- basename_test.dart | 139 |-- basename_test.dart |
127 | (7 more...) | 140 | (7 more...) |
128 |-- path_windows_test.dart | 141 |-- path_windows_test.dart |
129 |-- relative_test.dart | 142 |-- relative_test.dart |
130 '-- split_test.dart | 143 '-- split_test.dart |
131 """)); | 144 """)); |
132 }); | 145 }); |
133 }); | 146 }); |
| 147 |
134 group('treeFromMap', () { | 148 group('treeFromMap', () { |
135 test('empty map', () { | 149 test('empty map', () { |
136 expect(tree.fromMap({}), equals("")); | 150 expect(tree.fromMap({}), equals("")); |
137 }); | 151 }); |
| 152 |
138 test('a complex example', () { | 153 test('a complex example', () { |
139 var map = { | 154 var map = { |
140 ".gitignore": {}, | 155 ".gitignore": {}, |
141 "README.md": {}, | 156 "README.md": {}, |
142 "TODO": {}, | 157 "TODO": {}, |
143 "example": { | 158 "example": { |
144 "console_example.dart": {}, | 159 "console_example.dart": {}, |
145 "main.dart": {}, | 160 "main.dart": {}, |
146 "web copy": { | 161 "web copy": { |
147 "web_example.dart": {} | 162 "web_example.dart": {} |
148 } | 163 }, |
149 }, | 164 }, |
150 "lib": { | 165 "lib": { |
151 "path.dart": {} | 166 "path.dart": {} |
152 }, | 167 }, |
153 "pubspec.yaml": {}, | 168 "pubspec.yaml": {}, |
154 "test": { | 169 "test": { |
155 "absolute_test.dart": {}, | 170 "absolute_test.dart": {}, |
156 "basename_test.dart": {}, | 171 "basename_test.dart": {}, |
157 "dirname_test.dart": {}, | 172 "dirname_test.dart": {}, |
158 "extension_test.dart": {}, | 173 "extension_test.dart": {}, |
159 "is_absolute_test.dart": {}, | 174 "is_absolute_test.dart": {}, |
160 "is_relative_test.dart": {}, | 175 "is_relative_test.dart": {}, |
161 "join_test.dart": {}, | 176 "join_test.dart": {}, |
162 "normalize_test.dart": {}, | 177 "normalize_test.dart": {}, |
163 "relative_test.dart": {}, | 178 "relative_test.dart": {}, |
164 "split_test.dart": {} | 179 "split_test.dart": {} |
165 } | 180 } |
166 }; | 181 }; |
| 182 |
167 expect(tree.fromMap(map), equals(""" | 183 expect(tree.fromMap(map), equals(""" |
168 |-- .gitignore | 184 |-- .gitignore |
169 |-- README.md | 185 |-- README.md |
170 |-- TODO | 186 |-- TODO |
171 |-- example | 187 |-- example |
172 | |-- console_example.dart | 188 | |-- console_example.dart |
173 | |-- main.dart | 189 | |-- main.dart |
174 | '-- web copy | 190 | '-- web copy |
175 | '-- web_example.dart | 191 | '-- web_example.dart |
176 |-- lib | 192 |-- lib |
177 | '-- path.dart | 193 | '-- path.dart |
178 |-- pubspec.yaml | 194 |-- pubspec.yaml |
179 '-- test | 195 '-- test |
180 |-- absolute_test.dart | 196 |-- absolute_test.dart |
181 |-- basename_test.dart | 197 |-- basename_test.dart |
182 |-- dirname_test.dart | 198 |-- dirname_test.dart |
183 |-- extension_test.dart | 199 |-- extension_test.dart |
184 |-- is_absolute_test.dart | 200 |-- is_absolute_test.dart |
185 |-- is_relative_test.dart | 201 |-- is_relative_test.dart |
186 |-- join_test.dart | 202 |-- join_test.dart |
187 |-- normalize_test.dart | 203 |-- normalize_test.dart |
188 |-- relative_test.dart | 204 |-- relative_test.dart |
189 '-- split_test.dart | 205 '-- split_test.dart |
190 """)); | 206 """)); |
191 }); | 207 }); |
192 }); | 208 }); |
| 209 |
193 test('does not elide children if showAllChildren is true', () { | 210 test('does not elide children if showAllChildren is true', () { |
194 var map = { | 211 var map = { |
195 'dir': { | 212 'dir': { |
196 'a.dart': {}, | 213 'a.dart': {}, |
197 'b.dart': {}, | 214 'b.dart': {}, |
198 'c.dart': {}, | 215 'c.dart': {}, |
199 'd.dart': {}, | 216 'd.dart': {}, |
200 'e.dart': {}, | 217 'e.dart': {}, |
201 'f.dart': {}, | 218 'f.dart': {}, |
202 'g.dart': {}, | 219 'g.dart': {}, |
203 'h.dart': {}, | 220 'h.dart': {}, |
204 'i.dart': {}, | 221 'i.dart': {}, |
205 'j.dart': {}, | 222 'j.dart': {}, |
206 'k.dart': {}, | 223 'k.dart': {}, |
207 'l.dart': {} | 224 'l.dart': {}, |
208 } | 225 } |
209 }; | 226 }; |
210 expect(tree.fromMap(map, showAllChildren: true), equals(""" | 227 expect(tree.fromMap(map, showAllChildren: true), equals(""" |
211 '-- dir | 228 '-- dir |
212 |-- a.dart | 229 |-- a.dart |
213 |-- b.dart | 230 |-- b.dart |
214 |-- c.dart | 231 |-- c.dart |
215 |-- d.dart | 232 |-- d.dart |
216 |-- e.dart | 233 |-- e.dart |
217 |-- f.dart | 234 |-- f.dart |
218 |-- g.dart | 235 |-- g.dart |
219 |-- h.dart | 236 |-- h.dart |
220 |-- i.dart | 237 |-- i.dart |
221 |-- j.dart | 238 |-- j.dart |
222 |-- k.dart | 239 |-- k.dart |
223 '-- l.dart | 240 '-- l.dart |
224 """)); | 241 """)); |
225 }); | 242 }); |
| 243 |
226 } | 244 } |
OLD | NEW |