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