adf6842f6c
Known issues: - Import syntax: using 'dart/core' right now, but should be './dart/core' or something else? - _jsModuleValue not supported in es6 output yet (how is it meant to be used?) BUG= R=jmesserly@google.com Review URL: https://codereview.chromium.org/1612083002 .
39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
// 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);
|
|
});
|
|
});
|
|
}
|