OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 library validator_test; | 5 library validator_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:json'; | 8 import 'dart:json'; |
9 | 9 |
10 import 'test_pub.dart'; | 10 import 'test_pub.dart'; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 expectValidationError(name); | 203 expectValidationError(name); |
204 run(); | 204 run(); |
205 }); | 205 }); |
206 | 206 |
207 test('has a package name that contains upper-case letters', () { | 207 test('has a package name that contains upper-case letters', () { |
208 dir(appPath, [libPubspec("TestPkg", "1.0.0")]).scheduleCreate(); | 208 dir(appPath, [libPubspec("TestPkg", "1.0.0")]).scheduleCreate(); |
209 expectValidationWarning(name); | 209 expectValidationWarning(name); |
210 run(); | 210 run(); |
211 }); | 211 }); |
212 | 212 |
213 test('has a package name that is a Dart identifier', () { | 213 test('has a package name that is a Dart reserved word', () { |
214 dir(appPath, [libPubspec("operator", "1.0.0")]).scheduleCreate(); | 214 dir(appPath, [libPubspec("operator", "1.0.0")]).scheduleCreate(); |
215 expectValidationError(name); | 215 expectValidationError(name); |
216 run(); | 216 run(); |
217 }); | 217 }); |
218 | 218 |
219 test('has a library name with an invalid character', () { | 219 test('has a library name with an invalid character', () { |
220 dir(appPath, [ | 220 dir(appPath, [ |
221 libPubspec("test_pkg", "1.0.0"), | 221 libPubspec("test_pkg", "1.0.0"), |
222 dir("lib", [file("test-pkg.dart", "int i = 0;")]) | 222 dir("lib", [file("test-pkg.dart", "int i = 0;")]) |
223 ]).scheduleCreate(); | 223 ]).scheduleCreate(); |
(...skipping 12 matching lines...) Expand all Loading... |
236 | 236 |
237 test('has a library name that contains upper-case letters', () { | 237 test('has a library name that contains upper-case letters', () { |
238 dir(appPath, [ | 238 dir(appPath, [ |
239 libPubspec("test_pkg", "1.0.0"), | 239 libPubspec("test_pkg", "1.0.0"), |
240 dir("lib", [file("TestPkg.dart", "int i = 0;")]) | 240 dir("lib", [file("TestPkg.dart", "int i = 0;")]) |
241 ]).scheduleCreate(); | 241 ]).scheduleCreate(); |
242 expectValidationWarning(name); | 242 expectValidationWarning(name); |
243 run(); | 243 run(); |
244 }); | 244 }); |
245 | 245 |
246 test('has a library name that is a Dart identifier', () { | 246 test('has a library name that is a Dart reserved word', () { |
247 dir(appPath, [ | 247 dir(appPath, [ |
248 libPubspec("test_pkg", "1.0.0"), | 248 libPubspec("test_pkg", "1.0.0"), |
249 dir("lib", [file("operator.dart", "int i = 0;")]) | 249 dir("lib", [file("operator.dart", "int i = 0;")]) |
250 ]).scheduleCreate(); | 250 ]).scheduleCreate(); |
251 expectValidationError(name); | 251 expectValidationError(name); |
252 run(); | 252 run(); |
253 }); | 253 }); |
254 | 254 |
| 255 test('has a single library named differently than the package', () { |
| 256 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); |
| 257 dir(appPath, [ |
| 258 dir("lib", [file("best_pkg.dart", "int i = 0;")]) |
| 259 ]).scheduleCreate(); |
| 260 expectValidationWarning(name); |
| 261 run(); |
| 262 }); |
| 263 |
255 test('has no lib directory', () { | 264 test('has no lib directory', () { |
256 dir(join(appPath, "lib")).scheduleDelete(); | 265 dir(join(appPath, "lib")).scheduleDelete(); |
257 expectValidationError(lib); | 266 expectValidationError(lib); |
258 run(); | 267 run(); |
259 }); | 268 }); |
260 | 269 |
261 test('has an empty lib directory', () { | 270 test('has an empty lib directory', () { |
262 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); | 271 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); |
263 expectValidationError(lib); | 272 expectValidationError(lib); |
264 run(); | 273 run(); |
265 }); | 274 }); |
266 | 275 |
267 test('has a lib directory containing only src', () { | 276 test('has a lib directory containing only src', () { |
268 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); | 277 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); |
269 dir(appPath, [ | 278 dir(appPath, [ |
270 dir("lib", [ | 279 dir("lib", [ |
271 dir("src", [file("test_pkg.dart", "int i = 0;")]) | 280 dir("src", [file("test_pkg.dart", "int i = 0;")]) |
272 ]) | 281 ]) |
273 ]).scheduleCreate(); | 282 ]).scheduleCreate(); |
274 expectValidationError(lib); | 283 expectValidationError(lib); |
275 run(); | 284 run(); |
276 }); | 285 }); |
277 }); | 286 }); |
278 } | 287 } |
OLD | NEW |