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

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: address comments Created 5 years 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 | « lib/src/runner/parse_metadata.dart ('k') | lib/test.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) 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
205 /// Returns a sink that maps events sent to [original] using [fn]. 192 /// Returns a sink that maps events sent to [original] using [fn].
206 StreamSink mapSink(StreamSink original, fn(event)) { 193 StreamSink mapSink(StreamSink original, fn(event)) {
207 var controller = new StreamController(sync: true); 194 var controller = new StreamController(sync: true);
208 controller.stream.listen( 195 controller.stream.listen(
209 (event) => original.add(fn(event)), 196 (event) => original.add(fn(event)),
210 onError: (error, stackTrace) => original.addError(error, stackTrace), 197 onError: (error, stackTrace) => original.addError(error, stackTrace),
211 onDone: () => original.close()); 198 onDone: () => original.close());
212 return controller.sink; 199 return controller.sink;
213 } 200 }
214 201
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 var pathHandler = new PathHandler()..add(beneath, handler); 402 var pathHandler = new PathHandler()..add(beneath, handler);
416 return pathHandler.handler; 403 return pathHandler.handler;
417 }; 404 };
418 } 405 }
419 406
420 /// Returns `true` iff [a] and [b] are both not null and share at least one 407 /// Returns `true` iff [a] and [b] are both not null and share at least one
421 /// element. 408 /// element.
422 bool intersect(Iterable a, Iterable b) { 409 bool intersect(Iterable a, Iterable b) {
423 return a != null && b != null && a.any(b.contains); 410 return a != null && b != null && a.any(b.contains);
424 } 411 }
OLDNEW
« no previous file with comments | « lib/src/runner/parse_metadata.dart ('k') | lib/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698