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

Unified Diff: pkg/polymer/test/utils_test.dart

Issue 23224003: move polymer.dart into dart svn (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add --deploy to todomvc sample Created 7 years, 4 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 | « pkg/polymer/test/testing.dart ('k') | samples/third_party/todomvc/build.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/test/utils_test.dart
diff --git a/pkg/polymer/test/utils_test.dart b/pkg/polymer/test/utils_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..393d21561b2bb8a0c6873367513baf86a1c452f7
--- /dev/null
+++ b/pkg/polymer/test/utils_test.dart
@@ -0,0 +1,86 @@
+// Copyright (c) 2012, 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.
+
+/** Tests for some of the utility helper functions used by the compiler. */
+library utils_test;
+
+import 'package:unittest/compact_vm_config.dart';
+import 'package:unittest/unittest.dart';
+import 'package:polymer/src/utils.dart';
+
+main() {
+ useCompactVMConfiguration();
+
+ for (bool startUppercase in [false, true]) {
+ Matcher caseEquals(String str) {
+ if (startUppercase) str = str[0].toUpperCase() + str.substring(1);
+ return equals(str);
+ }
+
+ camelCase(str) => toCamelCase(str, startUppercase: startUppercase);
+
+ group('toCamelCase startUppercase=$startUppercase', () {
+ test('empty', () {
+ expect(camelCase(''), equals(''));
+ });
+
+ test('single token', () {
+ expect(camelCase('a'), caseEquals('a'));
+ expect(camelCase('ab'), caseEquals('ab'));
+ expect(camelCase('Ab'), caseEquals('Ab'));
+ expect(camelCase('AB'), caseEquals('AB'));
+ expect(camelCase('long_word'), caseEquals('long_word'));
+ });
+
+ test('dashes in the middle', () {
+ expect(camelCase('a-b'), caseEquals('aB'));
+ expect(camelCase('a-B'), caseEquals('aB'));
+ expect(camelCase('A-b'), caseEquals('AB'));
+ expect(camelCase('long-word'), caseEquals('longWord'));
+ });
+
+ test('leading/trailing dashes', () {
+ expect(camelCase('-hi'), caseEquals('Hi'));
+ expect(camelCase('hi-'), caseEquals('hi'));
+ expect(camelCase('hi-friend-'), caseEquals('hiFriend'));
+ });
+
+ test('consecutive dashes', () {
+ expect(camelCase('--hi-friend'), caseEquals('HiFriend'));
+ expect(camelCase('hi--friend'), caseEquals('hiFriend'));
+ expect(camelCase('hi-friend--'), caseEquals('hiFriend'));
+ });
+ });
+ }
+
+ group('toHyphenedName', () {
+ test('empty', () {
+ expect(toHyphenedName(''), '');
+ });
+
+ test('all lower case', () {
+ expect(toHyphenedName('a'), 'a');
+ expect(toHyphenedName('a-b'), 'a-b');
+ expect(toHyphenedName('aBc'), 'a-bc');
+ expect(toHyphenedName('abC'), 'ab-c');
+ expect(toHyphenedName('abc-d'), 'abc-d');
+ expect(toHyphenedName('long_word'), 'long_word');
+ });
+
+ test('capitalized letters in the middle/end', () {
+ expect(toHyphenedName('aB'), 'a-b');
+ expect(toHyphenedName('longWord'), 'long-word');
+ });
+
+ test('leading capital letters', () {
+ expect(toHyphenedName('Hi'), 'hi');
+ expect(toHyphenedName('Hi-'), 'hi-');
+ expect(toHyphenedName('HiFriend'), 'hi-friend');
+ });
+
+ test('consecutive capital letters', () {
+ expect(toHyphenedName('aBC'), 'a-b-c');
+ });
+ });
+}
« no previous file with comments | « pkg/polymer/test/testing.dart ('k') | samples/third_party/todomvc/build.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698