| OLD | NEW |
| (Empty) | |
| 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('source_test'); |
| 6 |
| 7 #import('../../../lib/unittest/unittest.dart'); |
| 8 #import('../../pub/pubspec.dart'); |
| 9 #import('../../pub/source.dart'); |
| 10 #import('../../pub/utils.dart'); |
| 11 |
| 12 class MockSource extends Source { |
| 13 final String name = "mock"; |
| 14 final bool shouldCache = false; |
| 15 void validateDescription(description) { |
| 16 if (description != 'ok') throw new FormatException('Bad'); |
| 17 } |
| 18 } |
| 19 |
| 20 main() { |
| 21 group('Pubspec', () { |
| 22 group('parse()', () { |
| 23 test("throws if the description isn't valid", () { |
| 24 var sources = new SourceRegistry(); |
| 25 sources.register(new MockSource()); |
| 26 |
| 27 throwsBadFormat(() { |
| 28 new Pubspec.parse(''' |
| 29 dependencies: |
| 30 foo: |
| 31 mock: bad |
| 32 ''', sources); |
| 33 }); |
| 34 }); |
| 35 }); |
| 36 }); |
| 37 } |
| 38 |
| 39 throwsBadFormat(function) { |
| 40 expectThrow(function, (e) => e is FormatException); |
| 41 } |
| OLD | NEW |