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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/polymer/test/testing.dart ('k') | samples/third_party/todomvc/build.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, 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 /** Tests for some of the utility helper functions used by the compiler. */
6 library utils_test;
7
8 import 'package:unittest/compact_vm_config.dart';
9 import 'package:unittest/unittest.dart';
10 import 'package:polymer/src/utils.dart';
11
12 main() {
13 useCompactVMConfiguration();
14
15 for (bool startUppercase in [false, true]) {
16 Matcher caseEquals(String str) {
17 if (startUppercase) str = str[0].toUpperCase() + str.substring(1);
18 return equals(str);
19 }
20
21 camelCase(str) => toCamelCase(str, startUppercase: startUppercase);
22
23 group('toCamelCase startUppercase=$startUppercase', () {
24 test('empty', () {
25 expect(camelCase(''), equals(''));
26 });
27
28 test('single token', () {
29 expect(camelCase('a'), caseEquals('a'));
30 expect(camelCase('ab'), caseEquals('ab'));
31 expect(camelCase('Ab'), caseEquals('Ab'));
32 expect(camelCase('AB'), caseEquals('AB'));
33 expect(camelCase('long_word'), caseEquals('long_word'));
34 });
35
36 test('dashes in the middle', () {
37 expect(camelCase('a-b'), caseEquals('aB'));
38 expect(camelCase('a-B'), caseEquals('aB'));
39 expect(camelCase('A-b'), caseEquals('AB'));
40 expect(camelCase('long-word'), caseEquals('longWord'));
41 });
42
43 test('leading/trailing dashes', () {
44 expect(camelCase('-hi'), caseEquals('Hi'));
45 expect(camelCase('hi-'), caseEquals('hi'));
46 expect(camelCase('hi-friend-'), caseEquals('hiFriend'));
47 });
48
49 test('consecutive dashes', () {
50 expect(camelCase('--hi-friend'), caseEquals('HiFriend'));
51 expect(camelCase('hi--friend'), caseEquals('hiFriend'));
52 expect(camelCase('hi-friend--'), caseEquals('hiFriend'));
53 });
54 });
55 }
56
57 group('toHyphenedName', () {
58 test('empty', () {
59 expect(toHyphenedName(''), '');
60 });
61
62 test('all lower case', () {
63 expect(toHyphenedName('a'), 'a');
64 expect(toHyphenedName('a-b'), 'a-b');
65 expect(toHyphenedName('aBc'), 'a-bc');
66 expect(toHyphenedName('abC'), 'ab-c');
67 expect(toHyphenedName('abc-d'), 'abc-d');
68 expect(toHyphenedName('long_word'), 'long_word');
69 });
70
71 test('capitalized letters in the middle/end', () {
72 expect(toHyphenedName('aB'), 'a-b');
73 expect(toHyphenedName('longWord'), 'long-word');
74 });
75
76 test('leading capital letters', () {
77 expect(toHyphenedName('Hi'), 'hi');
78 expect(toHyphenedName('Hi-'), 'hi-');
79 expect(toHyphenedName('HiFriend'), 'hi-friend');
80 });
81
82 test('consecutive capital letters', () {
83 expect(toHyphenedName('aBC'), 'a-b-c');
84 });
85 });
86 }
OLDNEW
« 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