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

Side by Side Diff: test/throws_matchers_test.dart

Issue 840133003: matcher: fixed status file, formatting, tweaks to readme (Closed) Base URL: https://github.com/dart-lang/matcher.git@master
Patch Set: nits Created 5 years, 11 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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library matcher.core_matchers_test; 5 library matcher.core_matchers_test;
6 6
7 import 'package:matcher/matcher.dart'; 7 import 'package:matcher/matcher.dart';
8 import 'package:unittest/unittest.dart' show test, group; 8 import 'package:unittest/unittest.dart' show test, group;
9 9
10 import 'test_utils.dart'; 10 import 'test_utils.dart';
11 11
12 void main() { 12 void main() {
13 initUtils(); 13 initUtils();
14 14
15
16 test('throws', () { 15 test('throws', () {
17 shouldFail(doesNotThrow, throws, 16 shouldFail(doesNotThrow, throws, matches(r"Expected: throws"
18 matches( 17 r" Actual: <Closure(: \(\) => dynamic "
19 r"Expected: throws" 18 r"from Function 'doesNotThrow': static\.)?>"
20 r" Actual: <Closure(: \(\) => dynamic " 19 r" Which: did not throw"));
21 r"from Function 'doesNotThrow': static\.)?>"
22 r" Which: did not throw"));
23 shouldPass(doesThrow, throws); 20 shouldPass(doesThrow, throws);
24 shouldFail(true, throws, 21 shouldFail(true, throws, "Expected: throws"
25 "Expected: throws"
26 " Actual: <true>" 22 " Actual: <true>"
27 " Which: is not a Function or Future"); 23 " Which: is not a Function or Future");
28 }); 24 });
29 25
30 test('throwsA', () { 26 test('throwsA', () {
31 shouldPass(doesThrow, throwsA(equals('X'))); 27 shouldPass(doesThrow, throwsA(equals('X')));
32 shouldFail(doesThrow, throwsA(equals('Y')), 28 shouldFail(doesThrow, throwsA(equals('Y')), matches(r"Expected: throws 'Y'"
33 matches( 29 r" Actual: <Closure(: \(\) => dynamic "
34 r"Expected: throws 'Y'" 30 r"from Function 'doesThrow': static\.)?>"
35 r" Actual: <Closure(: \(\) => dynamic " 31 r" Which: threw 'X'"));
36 r"from Function 'doesThrow': static\.)?>"
37 r" Which: threw 'X'"));
38 }); 32 });
39 33
40 test('throwsA', () { 34 test('throwsA', () {
41 shouldPass(doesThrow, throwsA(equals('X'))); 35 shouldPass(doesThrow, throwsA(equals('X')));
42 shouldFail(doesThrow, throwsA(equals('Y')), 36 shouldFail(doesThrow, throwsA(equals('Y')), matches("Expected: throws 'Y'.*"
43 matches("Expected: throws 'Y'.*"
44 "Actual: <Closure.*" 37 "Actual: <Closure.*"
45 "Which: threw 'X'")); 38 "Which: threw 'X'"));
46 }); 39 });
47 40
48
49 group('exception/error matchers', () { 41 group('exception/error matchers', () {
50 test('throwsCyclicInitializationError', () { 42 test('throwsCyclicInitializationError', () {
51 expect(() => _Bicycle.foo, throwsCyclicInitializationError); 43 expect(() => _Bicycle.foo, throwsCyclicInitializationError);
52 }); 44 });
53 45
54 test('throwsConcurrentModificationError', () { 46 test('throwsConcurrentModificationError', () {
55 expect(() { 47 expect(() {
56 var a = { 'foo': 'bar' }; 48 var a = {'foo': 'bar'};
57 for (var k in a.keys) { 49 for (var k in a.keys) {
58 a.remove(k); 50 a.remove(k);
59 } 51 }
60 }, throwsConcurrentModificationError); 52 }, throwsConcurrentModificationError);
61 }); 53 });
62 54
63 test('throwsNullThrownError', () { 55 test('throwsNullThrownError', () {
64 expect(() => throw null, throwsNullThrownError); 56 expect(() => throw null, throwsNullThrownError);
65 }); 57 });
66 }); 58 });
67 } 59 }
68 60
69 class _Bicycle { 61 class _Bicycle {
70 static final foo = bar(); 62 static final foo = bar();
71 63
72 static bar() { 64 static bar() {
73 return foo + 1; 65 return foo + 1;
74 } 66 }
75 } 67 }
76
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