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

Side by Side Diff: test/throws_matchers_test.dart

Issue 1135653004: pkg/(unit)test: include a copy of old matcher (Closed) Base URL: https://github.com/dart-lang/test.git@stable
Patch Set: another nit Created 5 years, 7 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 unittest.matcher.core_matchers_test;
6
7 import 'package:unittest/unittest.dart';
8
9 import 'test_utils.dart';
10
11 void main() {
12 initUtils();
13
14 test('throws', () {
15 shouldFail(doesNotThrow, throws, matches(r"Expected: throws"
16 r" Actual: <Closure(: \(\) => dynamic "
17 r"from Function 'doesNotThrow': static\.)?>"
18 r" Which: did not throw"));
19 shouldPass(doesThrow, throws);
20 shouldFail(true, throws, "Expected: throws"
21 " Actual: <true>"
22 " Which: is not a Function or Future");
23 });
24
25 test('throwsA', () {
26 shouldPass(doesThrow, throwsA(equals('X')));
27 shouldFail(doesThrow, throwsA(equals('Y')), matches(r"Expected: throws 'Y'"
28 r" Actual: <Closure(: \(\) => dynamic "
29 r"from Function 'doesThrow': static\.)?>"
30 r" Which: threw 'X'"));
31 });
32
33 test('throwsA', () {
34 shouldPass(doesThrow, throwsA(equals('X')));
35 shouldFail(doesThrow, throwsA(equals('Y')), matches("Expected: throws 'Y'.*"
36 "Actual: <Closure.*"
37 "Which: threw 'X'"));
38 });
39
40 group('exception/error matchers', () {
41 test('throwsCyclicInitializationError', () {
42 expect(() => _Bicycle.foo, throwsCyclicInitializationError);
43 });
44
45 test('throwsConcurrentModificationError', () {
46 expect(() {
47 var a = {'foo': 'bar'};
48 for (var k in a.keys) {
49 a.remove(k);
50 }
51 }, throwsConcurrentModificationError);
52 });
53
54 test('throwsNullThrownError', () {
55 expect(() => throw null, throwsNullThrownError);
56 });
57 });
58 }
59
60 class _Bicycle {
61 static final foo = bar();
62
63 static bar() {
64 return foo + 1;
65 }
66 }
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