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

Unified Diff: test/matcher/throws_type_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/matcher/throws_test.dart ('k') | test/matchers_minified_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/matcher/throws_type_test.dart
diff --git a/test/matcher/throws_type_test.dart b/test/matcher/throws_type_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0e9a2cefcc4f65e82b1445c9b69d4a09f1dbc8f6
--- /dev/null
+++ b/test/matcher/throws_type_test.dart
@@ -0,0 +1,178 @@
+// 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 'package:unittest/unittest.dart';
+
+import '../utils.dart';
+
+void main() {
+ group('[throwsArgumentError]', () {
+ test("passes when a ArgumentError is thrown", () {
+ expect(() => throw new ArgumentError(''), throwsArgumentError);
+ });
+
+ test("fails when a non-ArgumentError is thrown", () {
+ return runTest(() {
+ expect(() => throw new Exception(), throwsArgumentError);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ startsWith("Expected: throws ArgumentError"));
+ });
+ });
+ });
+
+ group('[throwsConcurrentModificationError]', () {
+ test("passes when a ConcurrentModificationError is thrown", () {
+ expect(() => throw new ConcurrentModificationError(''),
+ throwsConcurrentModificationError);
+ });
+
+ test("fails when a non-ConcurrentModificationError is thrown", () {
+ return runTest(() {
+ expect(() => throw new Exception(), throwsConcurrentModificationError);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ startsWith("Expected: throws ConcurrentModificationError"));
+ });
+ });
+ });
+
+ group('[throwsCyclicInitializationError]', () {
+ test("passes when a CyclicInitializationError is thrown", () {
+ expect(() => throw new CyclicInitializationError(''),
+ throwsCyclicInitializationError);
+ });
+
+ test("fails when a non-CyclicInitializationError is thrown", () {
+ return runTest(() {
+ expect(() => throw new Exception(), throwsCyclicInitializationError);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ startsWith("Expected: throws CyclicInitializationError"));
+ });
+ });
+ });
+
+ group('[throwsException]', () {
+ test("passes when a Exception is thrown", () {
+ expect(() => throw new Exception(''), throwsException);
+ });
+
+ test("fails when a non-Exception is thrown", () {
+ return runTest(() {
+ expect(() => throw 'oh no', throwsException);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ startsWith("Expected: throws Exception"));
+ });
+ });
+ });
+
+ group('[throwsFormatException]', () {
+ test("passes when a FormatException is thrown", () {
+ expect(() => throw new FormatException(''), throwsFormatException);
+ });
+
+ test("fails when a non-FormatException is thrown", () {
+ return runTest(() {
+ expect(() => throw new Exception(), throwsFormatException);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ startsWith("Expected: throws FormatException"));
+ });
+ });
+ });
+
+ group('[throwsNoSuchMethodError]', () {
+ test("passes when a NoSuchMethodError is thrown", () {
+ expect(() {
+ throw new NoSuchMethodError(null, #name, null, null);
+ }, throwsNoSuchMethodError);
+ });
+
+ test("fails when a non-NoSuchMethodError is thrown", () {
+ return runTest(() {
+ expect(() => throw new Exception(), throwsNoSuchMethodError);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ startsWith("Expected: throws NoSuchMethodError"));
+ });
+ });
+ });
+
+ group('[throwsNullThrownError]', () {
+ test("passes when a NullThrownError is thrown", () {
+ expect(() => throw null, throwsNullThrownError);
+ });
+
+ test("fails when a non-NullThrownError is thrown", () {
+ return runTest(() {
+ expect(() => throw new Exception(), throwsNullThrownError);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ startsWith("Expected: throws NullThrownError"));
+ });
+ });
+ });
+
+ group('[throwsRangeError]', () {
+ test("passes when a RangeError is thrown", () {
+ expect(() => throw new RangeError(''), throwsRangeError);
+ });
+
+ test("fails when a non-RangeError is thrown", () {
+ return runTest(() {
+ expect(() => throw new Exception(), throwsRangeError);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ startsWith("Expected: throws RangeError"));
+ });
+ });
+ });
+
+ group('[throwsStateError]', () {
+ test("passes when a StateError is thrown", () {
+ expect(() => throw new StateError(''), throwsStateError);
+ });
+
+ test("fails when a non-StateError is thrown", () {
+ return runTest(() {
+ expect(() => throw new Exception(), throwsStateError);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ startsWith("Expected: throws StateError"));
+ });
+ });
+ });
+
+ group('[throwsUnimplementedError]', () {
+ test("passes when a UnimplementedError is thrown", () {
+ expect(() => throw new UnimplementedError(''), throwsUnimplementedError);
+ });
+
+ test("fails when a non-UnimplementedError is thrown", () {
+ return runTest(() {
+ expect(() => throw new Exception(), throwsUnimplementedError);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ startsWith("Expected: throws UnimplementedError"));
+ });
+ });
+ });
+
+ group('[throwsUnsupportedError]', () {
+ test("passes when a UnsupportedError is thrown", () {
+ expect(() => throw new UnsupportedError(''), throwsUnsupportedError);
+ });
+
+ test("fails when a non-UnsupportedError is thrown", () {
+ return runTest(() {
+ expect(() => throw new Exception(), throwsUnsupportedError);
+ }).then((liveTest) {
+ expectTestFailed(liveTest,
+ startsWith("Expected: throws UnsupportedError"));
+ });
+ });
+ });
+}
« no previous file with comments | « test/matcher/throws_test.dart ('k') | test/matchers_minified_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698