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

Unified Diff: pkg/unittest/test/unittest_expect_async_test.dart

Issue 193643003: pkg/unittest: support up to 6 arguments in expectAsync[Until] (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: doc comments Created 6 years, 9 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
Index: pkg/unittest/test/unittest_expect_async_test.dart
diff --git a/pkg/unittest/test/unittest_expect_async_test.dart b/pkg/unittest/test/unittest_expect_async_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a8bbde5f412a76a728e3a4157df477e59bb436be
--- /dev/null
+++ b/pkg/unittest/test/unittest_expect_async_test.dart
@@ -0,0 +1,95 @@
+// Copyright (c) 2013, 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.
+
+library unittestTest;
+import 'dart:isolate';
+import 'dart:async';
+import 'package:unittest/unittest.dart';
+
+part 'unittest_test_utils.dart';
+
+var testFunction = (TestConfiguration testConfig) {
+ test('expectAsync zero params', () {
+ _defer(expectAsync(() {
+ ++testConfig.count;
+ }));
+ });
+
+ test('expectAsync 1 param', () {
+ var func = expectAsync((arg) {
+ expect(arg, 0);
+ ++testConfig.count;
+ });
+ _defer(() => func(0));
+ });
+
+ test('expectAsync 2 param', () {
+ var func = expectAsync((arg0, arg1) {
+ expect(arg0, 0);
+ expect(arg1, 1);
+ ++testConfig.count;
+ });
+ _defer(() => func(0, 1));
+ });
+
+ test('single arg to Future.catchError', () {
+ var func = expectAsync((error) {
+ expect(error, isStateError);
+ ++testConfig.count;
+ });
+
+ new Future(() {
+ throw new StateError('test');
+ }).catchError(func);
+ });
+
+ test('2 args to Future.catchError', () {
+ var func = expectAsync((error, stack) {
+ expect(error, isStateError);
+ expect(stack is StackTrace, isTrue);
+ ++testConfig.count;
+ });
+
+ new Future(() {
+ throw new StateError('test');
+ }).catchError(func);
+ });
+
+ test('zero of two optional positional args', () {
+ var func = expectAsync(([arg0 = true, arg1 = true]) {
+ expect(arg0, isTrue);
+ expect(arg1, isTrue);
+ ++testConfig.count;
+ });
+
+ _defer(() => func());
+ });
+
+ test('one of two optional positional args', () {
+ var func = expectAsync(([arg0 = true, arg1 = true]) {
+ expect(arg0, isFalse);
+ expect(arg1, isTrue);
+ ++testConfig.count;
+ });
+
+ _defer(() => func(false));
+ });
+
+ test('two of two optional positional args', () {
+ var func = expectAsync(([arg0 = true, arg1 = true]) {
+ expect(arg0, isFalse);
+ expect(arg1, isNull);
+ ++testConfig.count;
+ });
+
+ _defer(() => func(false, null));
+ });
+};
+
+final expected = '8:0:0:8:8:::null:expectAsync zero params:'
+ ':expectAsync 1 param::expectAsync 2 param:'
+ ':single arg to Future.catchError::2 args to Future.catchError:'
+ ':zero of two optional positional args:'
+ ':one of two optional positional args:'
+ ':two of two optional positional args:';
« no previous file with comments | « pkg/unittest/test/unittest_expect_async_args_test.dart ('k') | pkg/unittest/test/unittest_late_exception_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698