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

Unified Diff: test/matcher/completion_test.dart

Issue 934413002: Replace the existing unittest APIs with the new runner infrastructure. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Code review changes 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 | « test/loader_test.dart ('k') | test/matcher/prints_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/matcher/completion_test.dart
diff --git a/test/matcher/completion_test.dart b/test/matcher/completion_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..360a5cf2a454d2c216f7f36aa3b2ead0e8a29993
--- /dev/null
+++ b/test/matcher/completion_test.dart
@@ -0,0 +1,100 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+
+import 'package:unittest/unittest.dart';
+
+import '../utils.dart';
+
+void main() {
+ group("[completes]", () {
+ test("blocks the test until the Future completes", () {
+ return expectTestBlocks(() {
+ var completer = new Completer();
+ expect(completer.future, completes);
+ return completer;
+ }, (completer) => completer.complete());
+ });
+
+ test("with an error", () {
+ return runTest(() {
+ expect(new Future.error('X'), completes);
+ }).then((liveTest) {
+ expectTestFailed(liveTest, startsWith(
+ "Expected future to complete successfully, but it failed with X"));
+ });
+ });
+
+ test("with a failure", () {
+ return runTest(() {
+ expect(new Future.error(new TestFailure('oh no')), completes);
+ }).then((liveTest) {
+ expectTestFailed(liveTest, "oh no");
+ });
+ });
+
+ test("with a non-function", () {
+ return runTest(() {
+ expect(10, completes);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ "Expected: completes successfully\n"
+ " Actual: <10>\n");
+ });
+ });
+
+ test("with a successful future", () {
+ expect(new Future.value('1'), completes);
+ });
+ });
+
+ group("[completion]", () {
+ test("blocks the test until the Future completes", () {
+ return expectTestBlocks(() {
+ var completer = new Completer();
+ expect(completer.future, completion(isNull));
+ return completer;
+ }, (completer) => completer.complete());
+ });
+
+ test("with an error", () {
+ return runTest(() {
+ expect(new Future.error('X'), completion(isNull));
+ }).then((liveTest) {
+ expectTestFailed(liveTest, startsWith(
+ "Expected future to complete successfully, but it failed with X"));
+ });
+ });
+
+ test("with a failure", () {
+ return runTest(() {
+ expect(new Future.error(new TestFailure('oh no')), completion(isNull));
+ }).then((liveTest) {
+ expectTestFailed(liveTest, "oh no");
+ });
+ });
+
+ test("with a non-function", () {
+ return runTest(() {
+ expect(10, completion(equals(10)));
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ "Expected: completes to a value that <10>\n"
+ " Actual: <10>\n");
+ });
+ });
+
+ test("with an incorrect value", () {
+ return runTest(() {
+ expect(new Future.value('a'), completion(equals('b')));
+ }).then((liveTest) {
+ expectTestFailed(liveTest, startsWith(
+ "Expected: 'b'\n"
+ " Actual: 'a'\n"
+ " Which: is different."));;
+ });
+ });
+ });
+}
« no previous file with comments | « test/loader_test.dart ('k') | test/matcher/prints_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698