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("throws if not a map", () { |
| 455 expectPubspecException('executables: not map', |
| 456 (pubspec) => pubspec.executables); |
| 457 }); |
| 458 |
| 459 test("throws if key is not a string", () { |
| 460 expectPubspecException('executables: {123: value}', |
| 461 (pubspec) => pubspec.executables); |
| 462 }); |
| 463 |
| 464 test("throws if a key isn't a simple name", () { |
| 465 expectPubspecException('executables: {funny/name: ok}', |
| 466 (pubspec) => pubspec.executables); |
| 467 }); |
| 468 |
| 469 test("throws if a value is not a string", () { |
| 470 expectPubspecException('executables: {command: 123}', |
| 471 (pubspec) => pubspec.executables); |
| 472 }); |
| 473 |
| 474 test("throws if a value isn't a simple name", () { |
| 475 expectPubspecException('executables: {command: funny_name/part}', |
| 476 (pubspec) => pubspec.executables); |
| 477 }); |
| 478 |
| 479 test("uses the key if the value is null", () { |
| 480 var pubspec = new Pubspec.parse(''' |
| 481 executables: |
| 482 command: |
| 483 ''', sources); |
| 484 expect(pubspec.executables['command'], equals('command')); |
| 485 }); |
| 486 }); |
447 }); | 487 }); |
448 } | 488 } |
OLD | NEW |