Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Unified Diff: test/utils_test.dart

Issue 1612083002: Initial --modules=es6 support (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: addressed comments (legacy, doc) + test enum utils Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/codegen_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ });
+ });
+}
« no previous file with comments | « test/codegen_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698