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

Side by Side Diff: pkg/smoke/lib/src/common.dart

Issue 204143002: Changes in smoke in preparation of polymer's codegen: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « pkg/smoke/lib/smoke.dart ('k') | pkg/smoke/lib/static.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Some common utilities used by other libraries in this package. 5 /// Some common utilities used by other libraries in this package.
6 library smoke.src.common; 6 library smoke.src.common;
7 7
8 import 'package:smoke/smoke.dart' as smoke show isSubclassOf; 8 import 'package:smoke/smoke.dart' as smoke show isSubclassOf;
9 9
10 /// Returns [input] adjusted to be within [min] and [max] length. Truncating it 10 /// Returns [input] adjusted to be within [min] and [max] length. Truncating it
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 /// mandatory arguments, this function returns `-1`, but if the funtion takes 70 /// mandatory arguments, this function returns `-1`, but if the funtion takes
71 /// `2` mandatory arguments and 10 optional arguments, this function returns 71 /// `2` mandatory arguments and 10 optional arguments, this function returns
72 /// `3`. 72 /// `3`.
73 int maxArgs(Function f) { 73 int maxArgs(Function f) {
74 if (f is _Func3) return 3; 74 if (f is _Func3) return 3;
75 if (f is _Func2) return 2; 75 if (f is _Func2) return 2;
76 if (f is _Func1) return 1; 76 if (f is _Func1) return 1;
77 if (f is _Func0) return 0; 77 if (f is _Func0) return 0;
78 return -1; 78 return -1;
79 } 79 }
80
81 /// Shallow comparison of two lists.
82 bool compareLists(List a, List b, {bool unordered: false}) {
83 if (a == null && b != null) return false;
84 if (a != null && b == null) return false;
85 if (a.length != b.length) return false;
86 if (unordered) {
87 var bSet = new Set()..addAll(b);
88 for (int i = 0; i < a.length; i++) {
89 if (!bSet.contains(a[i])) return false;
90 }
91 } else {
92 for (int i = 0; i < a.length; i++) {
93 if (a[i] != b[i]) return false;
94 }
95 }
96 return true;
97 }
98
99 /// Shallow comparison of two maps.
100 bool compareMaps(Map a, Map b) {
101 if (a == null && b != null) return false;
102 if (a != null && b == null) return false;
103 if (a.length != b.length) return false;
104 for (var k in a.keys) {
105 if (!b.containsKey(k) || a[k] != b[k]) return false;
106 }
107 return true;
108 }
OLDNEW
« no previous file with comments | « pkg/smoke/lib/smoke.dart ('k') | pkg/smoke/lib/static.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698