OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, 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 dev_compiler.test.utils_test; |
| 6 |
| 7 import 'package:dev_compiler/src/utils.dart'; |
| 8 import 'package:test/test.dart'; |
| 9 |
| 10 enum Foo { |
| 11 first, second |
| 12 } |
| 13 |
| 14 void main() { |
| 15 group('getEnumValue', () { |
| 16 test('gets simple names', () { |
| 17 expect(getEnumName(Foo.first), 'first'); |
| 18 }); |
| 19 test('chokes on invalid values', () { |
| 20 expect(() => getEnumName(null), throws); |
| 21 expect(() => getEnumName(''), throws); |
| 22 expect(() => getEnumName('.'), throws); |
| 23 expect(() => getEnumName('.a'), throws); |
| 24 expect(() => getEnumName('a.'), throws); |
| 25 }); |
| 26 }); |
| 27 group('parseEnum', () { |
| 28 Foo parseFoo(String s) => parseEnum(s, Foo.values); |
| 29 test('parses enums', () { |
| 30 expect(parseFoo('first'), Foo.first); |
| 31 expect(parseFoo('second'), Foo.second); |
| 32 }); |
| 33 test('chokes on unknown enums', () { |
| 34 expect(() => parseFoo(''), throws); |
| 35 expect(() => parseFoo('what'), throws); |
| 36 }); |
| 37 }); |
| 38 } |
OLD | NEW |