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

Side by Side Diff: pkg/unittest/test/matchers_unminified_test.dart

Issue 15492003: Split out unittest tests whose behavior differs in minified mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « pkg/unittest/test/matchers_test.dart ('k') | pkg/unittest/test/pretty_print_minified_test.dart » ('j') | 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 // This file is for matcher tests that rely on the names of various Dart types.
6 // These tests will fail when run in minified dart2js, since the names will be
7 // mangled. A version of this file that works in minified dart2js is in
8 // matchers_minified_test.dart.
9
10 import 'package:unittest/unittest.dart';
11
12 import 'test_common.dart';
13 import 'test_utils.dart';
14
15 void main() {
16 initUtils();
17
18 group('Core matchers', () {
19 test('throwsFormatException', () {
20 shouldPass(() { throw new FormatException(''); },
21 throwsFormatException);
22 shouldFail(() { throw new Exception(); },
23 throwsFormatException,
24 matches(
25 r"Expected: throws an exception which matches FormatException +"
26 r"But: exception \?:<Exception> does not match FormatException\."
27 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
28 });
29
30 test('throwsArgumentError', () {
31 shouldPass(() { throw new ArgumentError(''); },
32 throwsArgumentError);
33 shouldFail(() { throw new Exception(); },
34 throwsArgumentError,
35 matches(
36 r"Expected: throws an exception which matches ArgumentError +"
37 r"But: exception \?:<Exception> does not match "
38 r"ArgumentError\."
39 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
40 });
41
42 test('throwsRangeError', () {
43 shouldPass(() { throw new RangeError(0); },
44 throwsRangeError);
45 shouldFail(() { throw new Exception(); },
46 throwsRangeError,
47 matches(
48 r"Expected: throws an exception which matches RangeError +"
49 r"But: exception \?:<Exception> does not match RangeError\."
50 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
51 });
52
53 test('throwsNoSuchMethodError', () {
54 shouldPass(() { throw new NoSuchMethodError(null, '', null, null); },
55 throwsNoSuchMethodError);
56 shouldFail(() { throw new Exception(); },
57 throwsNoSuchMethodError,
58 matches(
59 r"Expected: throws an exception which matches NoSuchMethodError +"
60 r"But: exception \?:<Exception> does not match "
61 r"NoSuchMethodError\."
62 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
63 });
64
65 test('throwsUnimplementedError', () {
66 shouldPass(() { throw new UnimplementedError(''); },
67 throwsUnimplementedError);
68 shouldFail(() { throw new Exception(); },
69 throwsUnimplementedError,
70 matches(
71 r"Expected: throws an exception which matches "
72 r"UnimplementedError +"
73 r"But: exception \?:<Exception> does not match "
74 r"UnimplementedError\."
75 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
76 });
77
78 test('throwsUnsupportedError', () {
79 shouldPass(() { throw new UnsupportedError(''); },
80 throwsUnsupportedError);
81 shouldFail(() { throw new Exception(); },
82 throwsUnsupportedError,
83 matches(
84 r"Expected: throws an exception which matches UnsupportedError +"
85 r"But: exception \?:<Exception> does not match "
86 r"UnsupportedError\."
87 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
88 });
89
90 test('throwsStateError', () {
91 shouldPass(() { throw new StateError(''); },
92 throwsStateError);
93 shouldFail(() { throw new Exception(); },
94 throwsStateError,
95 matches(
96 r"Expected: throws an exception which matches StateError +"
97 r"But: exception \?:<Exception> does not match "
98 r"StateError\."
99 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
100 });
101 });
102
103 group('Iterable Matchers', () {
104 test('isEmpty', () {
105 var d = new SimpleIterable(0);
106 var e = new SimpleIterable(1);
107 shouldPass(d, isEmpty);
108 shouldFail(e, isEmpty, "Expected: empty But: was SimpleIterable:[1].");
109 });
110
111 test('contains', () {
112 var d = new SimpleIterable(3);
113 shouldPass(d, contains(2));
114 shouldFail(d, contains(5),
115 "Expected: contains <5> "
116 "But: was SimpleIterable:[3, 2, 1].");
117 });
118 });
119
120 group('Feature Matchers', () {
121 test("Feature Matcher", () {
122 var w = new Widget();
123 w.price = 10;
124 shouldPass(w, new HasPrice(10));
125 shouldPass(w, new HasPrice(greaterThan(0)));
126 shouldFail(w, new HasPrice(greaterThan(10)),
127 "Expected: Widget with a price that is a value greater than <10> "
128 "But: price was <10>. "
129 "Actual: <Instance of 'Widget'>");
130 });
131 });
132 }
OLDNEW
« no previous file with comments | « pkg/unittest/test/matchers_test.dart ('k') | pkg/unittest/test/pretty_print_minified_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698