Index: test/utils_test.dart |
diff --git a/test/utils_test.dart b/test/utils_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..51bf1f48477ccccb6c284059f991bc65ac690e8e |
--- /dev/null |
+++ b/test/utils_test.dart |
@@ -0,0 +1,38 @@ |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library dev_compiler.test.utils_test; |
+ |
+import 'package:dev_compiler/src/utils.dart'; |
+import 'package:test/test.dart'; |
+ |
+enum Foo { |
+ first, second |
+} |
+ |
+void main() { |
+ group('getEnumValue', () { |
+ test('gets simple names', () { |
+ expect(getEnumName(Foo.first), 'first'); |
+ }); |
+ test('chokes on invalid values', () { |
+ expect(() => getEnumName(null), throws); |
+ expect(() => getEnumName(''), throws); |
+ expect(() => getEnumName('.'), throws); |
+ expect(() => getEnumName('.a'), throws); |
+ expect(() => getEnumName('a.'), throws); |
+ }); |
+ }); |
+ group('parseEnum', () { |
+ Foo parseFoo(String s) => parseEnum(s, Foo.values); |
+ test('parses enums', () { |
+ expect(parseFoo('first'), Foo.first); |
+ expect(parseFoo('second'), Foo.second); |
+ }); |
+ test('chokes on unknown enums', () { |
+ expect(() => parseFoo(''), throws); |
+ expect(() => parseFoo('what'), throws); |
+ }); |
+ }); |
+} |