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:pub_semver/pub_semver.dart'; | 9 import 'package:pub_semver/pub_semver.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 version: not constraint | 224 version: not constraint |
225 ''', (pubspec) => pubspec.dependencies); | 225 ''', (pubspec) => pubspec.dependencies); |
226 }); | 226 }); |
227 | 227 |
228 test("throws if 'name' is not a string", () { | 228 test("throws if 'name' is not a string", () { |
229 expectPubspecException('name: [not, a, string]', | 229 expectPubspecException('name: [not, a, string]', |
230 (pubspec) => pubspec.name); | 230 (pubspec) => pubspec.name); |
231 }); | 231 }); |
232 | 232 |
233 test("throws if version is not a string", () { | 233 test("throws if version is not a string", () { |
234 expectPubspecException('version: 1.0', (pubspec) => pubspec.version); | 234 expectPubspecException('version: [2, 0, 0]', |
| 235 (pubspec) => pubspec.version, |
| 236 '"version" field must be a string'); |
| 237 }); |
| 238 |
| 239 test("throws if version is malformed (looking like a double)", () { |
| 240 expectPubspecException('version: 2.1', |
| 241 (pubspec) => pubspec.version, |
| 242 '"version" field must have three numeric components: major, minor, ' |
| 243 'and patch. Instead of "2.1", consider "2.1.0"'); |
| 244 }); |
| 245 |
| 246 test("throws if version is malformed (looking like an int)", () { |
| 247 expectPubspecException('version: 2', |
| 248 (pubspec) => pubspec.version, |
| 249 '"version" field must have three numeric components: major, minor, ' |
| 250 'and patch. Instead of "2", consider "2.0.0"'); |
235 }); | 251 }); |
236 | 252 |
237 test("throws if version is not a version", () { | 253 test("throws if version is not a version", () { |
238 expectPubspecException('version: not version', | 254 expectPubspecException('version: not version', |
239 (pubspec) => pubspec.version); | 255 (pubspec) => pubspec.version); |
240 }); | 256 }); |
241 | 257 |
242 test("throws if transformers isn't a list", () { | 258 test("throws if transformers isn't a list", () { |
243 expectPubspecException('transformers: "not list"', | 259 expectPubspecException('transformers: "not list"', |
244 (pubspec) => pubspec.transformers, | 260 (pubspec) => pubspec.transformers, |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 test("uses the key if the value is null", () { | 508 test("uses the key if the value is null", () { |
493 var pubspec = new Pubspec.parse(''' | 509 var pubspec = new Pubspec.parse(''' |
494 executables: | 510 executables: |
495 command: | 511 command: |
496 ''', sources); | 512 ''', sources); |
497 expect(pubspec.executables['command'], equals('command')); | 513 expect(pubspec.executables['command'], equals('command')); |
498 }); | 514 }); |
499 }); | 515 }); |
500 }); | 516 }); |
501 } | 517 } |
OLD | NEW |