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

Unified Diff: pkg/async/test/result_test.dart

Issue 297033002: Add Result.flatten. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Making factory properly factory. Created 6 years, 7 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
« pkg/async/pubspec.yaml ('K') | « pkg/async/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/async/test/result_test.dart
diff --git a/pkg/async/test/result_test.dart b/pkg/async/test/result_test.dart
index 53472ec905917cd5de0ac331da93213ab7c8f10a..d101b4894f7142a6ee98b6486a68561fb9232543 100644
--- a/pkg/async/test/result_test.dart
+++ b/pkg/async/test/result_test.dart
@@ -231,6 +231,26 @@ void main() {
c.add(new Result.value(37));
c.close();
});
+
+
+ test("flatten error 1", () {
+ Result<int> error = new Result<int>.error("BAD", stack);
+ Result<int> flattened = Result.flatten(error);
+ expectResult(flattened, error);
+ });
+
+ test("flatten error 2", () {
+ Result<int> error = new Result<int>.error("BAD", stack);
+ Result<Result<int>> result = new Result<Result<int>>.value(error);
+ Result<int> flattened = Result.flatten(result);
+ expectResult(flattened, error);
+ });
+
+ test("flatten value", () {
+ Result<Result<int>> result =
+ new Result<Result<int>>.value(new Result<int>.value(42));
+ expectResult(Result.flatten(result), new Result<int>.value(42));
+ });
}
void expectResult(Result actual, Result expected) {
« pkg/async/pubspec.yaml ('K') | « pkg/async/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698