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

Side by Side Diff: lib/src/utils.dart

Issue 1405633004: feature: tag tests; choose tags on command line Base URL: git@github.com:yjbanov/test.git@tags
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library test.utils; 5 library test.utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:math' as math; 9 import 'dart:math' as math;
10 10
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 var result = {}; 182 var result = {};
183 map1.forEach((key, value) { 183 map1.forEach((key, value) {
184 result[key] = value; 184 result[key] = value;
185 }); 185 });
186 map2.forEach((key, value) { 186 map2.forEach((key, value) {
187 result[key] = value; 187 result[key] = value;
188 }); 188 });
189 return result; 189 return result;
190 } 190 }
191 191
192 /// Returns a new list with all elements in both [list1] and [list2].
193 ///
194 /// If an element exists in both lists, it is listed only once in the result.
195 List mergeLists(List list1, List list2) {
196 var result = []..addAll(list1);
197 list2.forEach((element) {
198 if (!result.contains(element)) {
199 result.add(element);
200 }
201 });
202 return result;
203 }
204
192 /// Returns a sink that maps events sent to [original] using [fn]. 205 /// Returns a sink that maps events sent to [original] using [fn].
193 StreamSink mapSink(StreamSink original, fn(event)) { 206 StreamSink mapSink(StreamSink original, fn(event)) {
194 var controller = new StreamController(sync: true); 207 var controller = new StreamController(sync: true);
195 controller.stream.listen( 208 controller.stream.listen(
196 (event) => original.add(fn(event)), 209 (event) => original.add(fn(event)),
197 onError: (error, stackTrace) => original.addError(error, stackTrace), 210 onError: (error, stackTrace) => original.addError(error, stackTrace),
198 onDone: () => original.close()); 211 onDone: () => original.close());
199 return controller.sink; 212 return controller.sink;
200 } 213 }
201 214
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 urlSafe: urlSafe, addLineSeparator: addLineSeparator); 409 urlSafe: urlSafe, addLineSeparator: addLineSeparator);
397 } 410 }
398 411
399 /// Returns middleware that nests all requests beneath the URL prefix [beneath]. 412 /// Returns middleware that nests all requests beneath the URL prefix [beneath].
400 shelf.Middleware nestingMiddleware(String beneath) { 413 shelf.Middleware nestingMiddleware(String beneath) {
401 return (handler) { 414 return (handler) {
402 var pathHandler = new PathHandler()..add(beneath, handler); 415 var pathHandler = new PathHandler()..add(beneath, handler);
403 return pathHandler.handler; 416 return pathHandler.handler;
404 }; 417 };
405 } 418 }
419
420 /// Returns `true` iff [a] and [b] are both not null and share at least one
421 /// element.
422 bool intersect(Iterable a, Iterable b) {
423 return a != null && b != null && a.any(b.contains);
424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698