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

Side by Side Diff: third_party/pkg/angular/lib/utils.dart

Issue 180873006: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review feedback Created 6 years, 9 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
OLDNEW
1 library angular.util; 1 library angular.util;
2 2
3 toBool(x) { 3 bool toBool(x) {
4 if (x is bool) return x; 4 if (x is bool) return x;
5 if (x is num) return x != 0; 5 if (x is num) return x != 0;
6 return false; 6 return false;
7 } 7 }
8 8
9 typedef FnWith0Args(); 9 typedef FnWith0Args();
10 typedef FnWith1Args(a0); 10 typedef FnWith1Args(a0);
11 typedef FnWith2Args(a0, a1); 11 typedef FnWith2Args(a0, a1);
12 typedef FnWith3Args(a0, a1, a2); 12 typedef FnWith3Args(a0, a1, a2);
13 typedef FnWith4Args(a0, a1, a2, a3); 13 typedef FnWith4Args(a0, a1, a2, a3);
(...skipping 23 matching lines...) Expand all
37 } 37 }
38 } 38 }
39 39
40 relaxFnArgs1(Function fn) { 40 relaxFnArgs1(Function fn) {
41 if (fn is FnWith3Args) return (_1) => fn(_1, null, null); 41 if (fn is FnWith3Args) return (_1) => fn(_1, null, null);
42 if (fn is FnWith2Args) return (_1) => fn(_1, null); 42 if (fn is FnWith2Args) return (_1) => fn(_1, null);
43 if (fn is FnWith1Args) return fn; 43 if (fn is FnWith1Args) return fn;
44 if (fn is FnWith0Args) return (_1) => fn(); 44 if (fn is FnWith0Args) return (_1) => fn();
45 } 45 }
46 46
47 relaxFnArgs2(Function fn) {
48 if (fn is FnWith2Args) return fn;
49 if (fn is FnWith1Args) return (_1, _2) => fn(_1);
50 if (fn is FnWith0Args) return (_1, _2) => fn();
51 }
52
47 relaxFnArgs3(Function fn) { 53 relaxFnArgs3(Function fn) {
48 if (fn is FnWith3Args) return fn; 54 if (fn is FnWith3Args) return fn;
49 if (fn is FnWith2Args) return (_1, _2, _3) => fn(_1, null); 55 if (fn is FnWith2Args) return (_1, _2, _3) => fn(_1, null);
50 if (fn is FnWith1Args) return (_1, _2, _3) => fn(_1); 56 if (fn is FnWith1Args) return (_1, _2, _3) => fn(_1);
51 if (fn is FnWith0Args) return (_1, _2, _3) => fn(); 57 if (fn is FnWith0Args) return (_1, _2, _3) => fn();
52 } 58 }
53 59
54 relaxFnArgs(Function fn) { 60 relaxFnArgs(Function fn) {
55 if (fn is FnWith5Args) { 61 if (fn is FnWith5Args) {
56 return ([a0, a1, a2, a3, a4]) => fn(a0, a1, a2, a3, a4); 62 return ([a0, a1, a2, a3, a4]) => fn(a0, a1, a2, a3, a4);
57 } else if (fn is FnWith4Args) { 63 } else if (fn is FnWith4Args) {
58 return ([a0, a1, a2, a3, a4]) => fn(a0, a1, a2, a3); 64 return ([a0, a1, a2, a3, a4]) => fn(a0, a1, a2, a3);
59 } else if (fn is FnWith3Args) { 65 } else if (fn is FnWith3Args) {
60 return ([a0, a1, a2, a3, a4]) => fn(a0, a1, a2); 66 return ([a0, a1, a2, a3, a4]) => fn(a0, a1, a2);
61 } else if (fn is FnWith2Args) { 67 } else if (fn is FnWith2Args) {
62 return ([a0, a1, a2, a3, a4]) => fn(a0, a1); 68 return ([a0, a1, a2, a3, a4]) => fn(a0, a1);
63 } else if (fn is FnWith1Args) { 69 } else if (fn is FnWith1Args) {
64 return ([a0, a1, a2, a3, a4]) => fn(a0); 70 return ([a0, a1, a2, a3, a4]) => fn(a0);
65 } else if (fn is FnWith0Args) { 71 } else if (fn is FnWith0Args) {
66 return ([a0, a1, a2, a3, a4]) => fn(); 72 return ([a0, a1, a2, a3, a4]) => fn();
67 } else { 73 } else {
68 return ([a0, a1, a2, a3, a4]) { 74 return ([a0, a1, a2, a3, a4]) {
69 throw "Unknown function type, expecting 0 to 5 args."; 75 throw "Unknown function type, expecting 0 to 5 args.";
70 }; 76 };
71 } 77 }
72 } 78 }
73 79
74 camelcase(String s) {
75 var part = s.split('-').map((s) => s.toLowerCase());
76 if (part.length <= 1) {
77 return part.join();
78 }
79 return part.first + part.skip(1).map(capitalize).join();
80 }
81
82 capitalize(String s) => s.substring(0, 1).toUpperCase() + s.substring(1); 80 capitalize(String s) => s.substring(0, 1).toUpperCase() + s.substring(1);
83 81
84 var SNAKE_CASE_REGEXP = new RegExp("[A-Z]");
85 82
86 snakecase(String name, [separator = '-']) => 83 /// Returns whether or not the given identifier is a reserved word in Dart.
87 name.replaceAllMapped(SNAKE_CASE_REGEXP, (Match match) => 84 bool isReservedWord(String identifier) => RESERVED_WORDS.contains(identifier);
88 (match.start != 0 ? separator : '') + match.group(0).toLowerCase()); 85
86 final Set<String> RESERVED_WORDS = new Set<String>.from(const [
87 "assert",
88 "break",
89 "case",
90 "catch",
91 "class",
92 "const",
93 "continue",
94 "default",
95 "do",
96 "else",
97 "enum",
98 "extends",
99 "false",
100 "final",
101 "finally",
102 "for",
103 "if",
104 "in",
105 "is",
106 "new",
107 "null",
108 "rethrow",
109 "return",
110 "super",
111 "switch",
112 "this",
113 "throw",
114 "true",
115 "try",
116 "var",
117 "void",
118 "while",
119 "with"
120 ]);
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/tools/template_cache_generator.dart ('k') | third_party/pkg/angular/package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698