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 { first, second } | |
11 | |
12 void main() { | |
13 group('getEnumValue', () { | |
14 test('gets simple names', () { | |
15 expect(getEnumName(Foo.first), 'first'); | |
16 }); | |
17 test('chokes on invalid values', () { | |
18 expect(() => getEnumName(null), throws); | |
19 expect(() => getEnumName(''), throws); | |
20 expect(() => getEnumName('.'), throws); | |
21 expect(() => getEnumName('.a'), throws); | |
22 expect(() => getEnumName('a.'), throws); | |
23 }); | |
24 }); | |
25 group('parseEnum', () { | |
26 Foo parseFoo(String s) => parseEnum(s, Foo.values); | |
27 test('parses enums', () { | |
28 expect(parseFoo('first'), Foo.first); | |
29 expect(parseFoo('second'), Foo.second); | |
30 }); | |
31 test('chokes on unknown enums', () { | |
32 expect(() => parseFoo(''), throws); | |
33 expect(() => parseFoo('what'), throws); | |
34 }); | |
35 }); | |
36 } | |
OLD | NEW |