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

Side by Side Diff: tests/servicec/camelize_test.dart

Issue 2035023003: Remove service-compiler related code. (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « tests/service_tests/service_tests.dart ('k') | tests/servicec/input_files/bad_field_1.idl » ('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) 2015, 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 import 'dart:async' show
6 Future;
7
8 import 'test.dart' show
9 Test;
10
11 import 'package:expect/expect.dart' show
12 Expect;
13
14 import 'package:servicec/util.dart' show
15 camelize,
16 underscore;
17
18 class CamelizeTest extends Test {
19 CamelizeTest()
20 : super('camelize');
21
22 Future perform() {
23 // Simple uses.
24 Expect.equals("HelloWorld", camelize("hello_world"));
25 Expect.throws(() => camelize("hello world"), null,
26 "Should fail on bad symbols");
27 Expect.equals("hello_world", underscore("HelloWorld"));
28 Expect.equals("hello_world", underscore("helloWorld"));
29 Expect.throws(() => underscore("hello world"), null,
30 "Should fail on bad symbols");
31
32 // Multiple underscores.
33 Expect.equals("HelloThereWorld", camelize("hello_there_world"));
34 Expect.equals("HelloThereBigWideWorldHowAreYou",
35 camelize("hello_there_big_wide_world_how_are_you"));
36 Expect.equals("HelloWorld", camelize("hello___world"));
37 Expect.equals("Hello", camelize("___hello"));
38 Expect.equals("Hello", camelize("___Hello"));
39 Expect.equals("Hello", camelize("Hello___"));
40 Expect.equals("Hello", camelize("hello___"));
41 Expect.equals("HelloWorld", camelize("___hello___world___"));
42 Expect.equals("Just1Chance", camelize("just_1_chance"));
43
44 // Multiple words.
45 Expect.equals("hello_there_world", underscore("HelloThereWorld"));
46 Expect.equals("hello_there_big_wide_world_how_are_you",
47 underscore("HelloThereBigWideWorldHowAreYou"));
48 Expect.equals("parsed_html", underscore("parsedHtml"));
49
50 // Acronyms and digits.
51 Expect.equals("d_e_b_u_g", underscore("DEBUG"));
52 Expect.equals("h_o_w_a_b_o_u_t_c_o_n_s_t_a_n_t_s",
53 underscore("HOW_ABOUT_CONSTANTS"));
54 Expect.equals("employee_i_d", underscore("employeeID"));
55 Expect.equals("parsed_h_t_m_l", underscore("parsedHTML"));
56 Expect.equals("Just1chance", camelize("just_1chance"));
57 Expect.equals("just_1chance", underscore("Just1chance"));
58 Expect.equals("just_1_chance", underscore("Just1Chance"));
59
60 // Bad argument names
61 Expect.throws(() => camelize("___"), null,
62 "Should fail on input without alphabetic characters (1)");
63 Expect.throws(() => camelize("__1word__"), null,
64 "Should fail on input without alphabetic characters (2)");
65 Expect.throws(() => camelize("__1word"), null,
66 "Should fail on input without alphabetic characters (3)");
67 Expect.throws(() => camelize("1word__"), null,
68 "Should fail on input without alphabetic characters (4)");
69 Expect.throws(() => camelize("1word"), null,
70 "Should fail on input without alphabetic characters (5)");
71
72 Expect.throws(() => camelize("hello_world™"), null,
73 "Should fail on non-ascii characters (1)");
74 Expect.throws(() => camelize("hello_world⛐ "), null,
75 "Should fail on non-ascii characters (2)");
76 Expect.throws(() => camelize("▁▂▃▄▅▆▇█▉"), null,
77 "Should fail on non-ascii characters (3)");
78
79
80 // Underscores in input for underscore.
81 Expect.equals("_", underscore("_"));
82 Expect.equals( "hello_world" , underscore( "Hello_World" ));
83 Expect.equals( "_hello" , underscore( "_Hello" ));
84 Expect.equals( "hello_" , underscore( "Hello_" ));
85 Expect.equals( "_hello_world" , underscore( "_HelloWorld" ));
86 Expect.equals("__hello_world" , underscore("__HelloWorld" ));
87 Expect.equals( "hello_world_" , underscore( "HelloWorld_" ));
88 Expect.equals( "hello_world__", underscore( "HelloWorld__" ));
89 Expect.equals( "_hello_world_" , underscore( "_HelloWorld_" ));
90 Expect.equals("__hello_world__", underscore("__HelloWorld__" ));
91 Expect.equals( "hello_world" , underscore( "Hello_World" ));
92 Expect.equals( "hello___world", underscore( "Hello___World"));
93 }
94 }
OLDNEW
« no previous file with comments | « tests/service_tests/service_tests.dart ('k') | tests/servicec/input_files/bad_field_1.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698