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 pubspec_test; | 5 library pubspec_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 | 10 |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 publish_to: none | 437 publish_to: none |
438 ''', sources); | 438 ''', sources); |
439 expect(pubspec.publishTo, equals("none")); | 439 expect(pubspec.publishTo, equals("none")); |
440 }); | 440 }); |
441 | 441 |
442 test("throws on other strings", () { | 442 test("throws on other strings", () { |
443 expectPubspecException('publish_to: http://bad.url:not-port', | 443 expectPubspecException('publish_to: http://bad.url:not-port', |
444 (pubspec) => pubspec.publishTo); | 444 (pubspec) => pubspec.publishTo); |
445 }); | 445 }); |
446 }); | 446 }); |
| 447 |
| 448 group("executables", () { |
| 449 test("defaults to an empty map if omitted", () { |
| 450 var pubspec = new Pubspec.parse('', sources); |
| 451 expect(pubspec.executables, isEmpty); |
| 452 }); |
| 453 |
| 454 test("allows simple names for keys and most characters in values", () { |
| 455 var pubspec = new Pubspec.parse(''' |
| 456 executables: |
| 457 abcDEF-123_: "abc DEF-123._" |
| 458 ''', sources); |
| 459 expect(pubspec.executables['abcDEF-123_'], equals('abc DEF-123._')); |
| 460 }); |
| 461 |
| 462 test("throws if not a map", () { |
| 463 expectPubspecException('executables: not map', |
| 464 (pubspec) => pubspec.executables); |
| 465 }); |
| 466 |
| 467 test("throws if key is not a string", () { |
| 468 expectPubspecException('executables: {123: value}', |
| 469 (pubspec) => pubspec.executables); |
| 470 }); |
| 471 |
| 472 test("throws if a key isn't a simple name", () { |
| 473 expectPubspecException('executables: {funny/name: ok}', |
| 474 (pubspec) => pubspec.executables); |
| 475 }); |
| 476 |
| 477 test("throws if a value is not a string", () { |
| 478 expectPubspecException('executables: {command: 123}', |
| 479 (pubspec) => pubspec.executables); |
| 480 }); |
| 481 |
| 482 test("throws if a value contains a path separator", () { |
| 483 expectPubspecException('executables: {command: funny_name/part}', |
| 484 (pubspec) => pubspec.executables); |
| 485 }); |
| 486 |
| 487 test("throws if a value contains a windows path separator", () { |
| 488 expectPubspecException(r'executables: {command: funny_name\part}', |
| 489 (pubspec) => pubspec.executables); |
| 490 }); |
| 491 |
| 492 test("uses the key if the value is null", () { |
| 493 var pubspec = new Pubspec.parse(''' |
| 494 executables: |
| 495 command: |
| 496 ''', sources); |
| 497 expect(pubspec.executables['command'], equals('command')); |
| 498 }); |
| 499 }); |
447 }); | 500 }); |
448 } | 501 } |
OLD | NEW |