Chromium Code Reviews

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

Issue 891493004: Add an Engine class for running groups of test suites. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « lib/src/engine.dart ('k') | test/engine_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 unittest.utils; 5 library unittest.utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
10 10
(...skipping 38 matching lines...)
49 49
50 if (!filterStacks) return trace; 50 if (!filterStacks) return trace;
51 51
52 // Format the stack trace by removing everything above TestCase._runTest, 52 // Format the stack trace by removing everything above TestCase._runTest,
53 // which is usually going to be irrelevant. Also fold together unittest and 53 // which is usually going to be irrelevant. Also fold together unittest and
54 // core library calls so only the function the user called is visible. 54 // core library calls so only the function the user called is visible.
55 return new Trace(trace.frames.takeWhile((frame) { 55 return new Trace(trace.frames.takeWhile((frame) {
56 return frame.package != 'unittest' || frame.member != 'TestCase._runTest'; 56 return frame.package != 'unittest' || frame.member != 'TestCase._runTest';
57 })).terse.foldFrames((frame) => frame.package == 'unittest' || frame.isCore); 57 })).terse.foldFrames((frame) => frame.package == 'unittest' || frame.isCore);
58 } 58 }
59
60 /// Flattens nested [Iterable]s inside an [Iterable] into a single [List]
61 /// containing only non-[Iterable] elements.
62 List flatten(Iterable nested) {
63 var result = [];
64 helper(iter) {
65 for (var element in iter) {
66 if (element is Iterable) {
67 helper(element);
68 } else {
69 result.add(element);
70 }
71 }
72 }
73 helper(nested);
74 return result;
75 }
OLDNEW
« no previous file with comments | « lib/src/engine.dart ('k') | test/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine