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

Side by Side Diff: test/throws_matchers_test.dart

Issue 867133002: pkg/matcher: refactor with unittest v0.12 work (Closed) Base URL: https://github.com/dart-lang/matcher.git@master
Patch Set: cl nits 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 unified diff | Download patch
« no previous file with comments | « test/test_utils.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library matcher.core_matchers_test;
6
7 import 'package:matcher/matcher.dart';
8 import 'package:unittest/unittest.dart' show test, group;
9
10 import 'test_utils.dart';
11
12 void main() {
13 initUtils();
14
15 test('throws', () {
16 shouldFail(doesNotThrow, throws, matches(r"Expected: throws"
17 r" Actual: <Closure(: \(\) => dynamic "
18 r"from Function 'doesNotThrow': static\.)?>"
19 r" Which: did not throw"));
20 shouldPass(doesThrow, throws);
21 shouldFail(true, throws, "Expected: throws"
22 " Actual: <true>"
23 " Which: is not a Function or Future");
24 });
25
26 test('throwsA', () {
27 shouldPass(doesThrow, throwsA(equals('X')));
28 shouldFail(doesThrow, throwsA(equals('Y')), matches(r"Expected: throws 'Y'"
29 r" Actual: <Closure(: \(\) => dynamic "
30 r"from Function 'doesThrow': static\.)?>"
31 r" Which: threw 'X'"));
32 });
33
34 test('throwsA', () {
35 shouldPass(doesThrow, throwsA(equals('X')));
36 shouldFail(doesThrow, throwsA(equals('Y')), matches("Expected: throws 'Y'.*"
37 "Actual: <Closure.*"
38 "Which: threw 'X'"));
39 });
40
41 group('exception/error matchers', () {
42 test('throwsCyclicInitializationError', () {
43 expect(() => _Bicycle.foo, throwsCyclicInitializationError);
44 });
45
46 test('throwsConcurrentModificationError', () {
47 expect(() {
48 var a = {'foo': 'bar'};
49 for (var k in a.keys) {
50 a.remove(k);
51 }
52 }, throwsConcurrentModificationError);
53 });
54
55 test('throwsNullThrownError', () {
56 expect(() => throw null, throwsNullThrownError);
57 });
58 });
59 }
60
61 class _Bicycle {
62 static final foo = bar();
63
64 static bar() {
65 return foo + 1;
66 }
67 }
OLDNEW
« no previous file with comments | « test/test_utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698