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

Unified 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. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/engine.dart ('k') | test/engine_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 526724128f9831a090650af448acdc7a557ac8ef..da2192764a1af63e56830205f26e5129dc3acd06 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -56,3 +56,20 @@ Trace getTrace(stack, bool formatStacks, bool filterStacks) {
return frame.package != 'unittest' || frame.member != 'TestCase._runTest';
})).terse.foldFrames((frame) => frame.package == 'unittest' || frame.isCore);
}
+
+/// Flattens nested [Iterable]s inside an [Iterable] into a single [List]
+/// containing only non-[Iterable] elements.
+List flatten(Iterable nested) {
+ var result = [];
+ helper(iter) {
+ for (var element in iter) {
+ if (element is Iterable) {
+ helper(element);
+ } else {
+ result.add(element);
+ }
+ }
+ }
+ helper(nested);
+ return result;
+}
« 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
This is Rietveld 408576698