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

Side by Side Diff: pkg/unittest/test/matchers_minified_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: 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
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 normally fail when run in minified dart2js, since the names will
7 // be mangled. This version of the file is modified to expect minified names.
8
9 import 'package:unittest/unittest.dart';
10
11 import 'test_utils.dart';
12
13 // A regexp fragment matching a minified name.
14 final _minifiedName = r"[A-Za-z0-9]{1,3}";
15
16 void main() {
17 initUtils();
18
19 group('Core matchers', () {
20 test('throwsFormatException', () {
21 shouldPass(() { throw new FormatException(''); },
22 throwsFormatException);
23 shouldFail(() { throw new Exception(); },
24 throwsFormatException,
25 matches(
26 r"Expected: throws an exception which matches FormatException +"
27 r"But: exception " + _minifiedName + r":<Exception> "
28 r"does not match FormatException\."
29 r"Actual: <Closure>"));
30 });
31
32 test('throwsArgumentError', () {
33 shouldPass(() { throw new ArgumentError(''); },
34 throwsArgumentError);
35 shouldFail(() { throw new Exception(); },
36 throwsArgumentError,
37 matches(
38 r"Expected: throws an exception which matches ArgumentError +"
39 r"But: exception " + _minifiedName + r":<Exception> "
40 r"does not match ArgumentError\."
41 r"Actual: <Closure>"));
42 });
43
44 test('throwsRangeError', () {
45 shouldPass(() { throw new RangeError(0); },
46 throwsRangeError);
47 shouldFail(() { throw new Exception(); },
48 throwsRangeError,
49 matches(
50 r"Expected: throws an exception which matches RangeError +"
51 r"But: exception " + _minifiedName + r":<Exception> "
52 r"does not match RangeError\."
53 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
54 });
55
56 test('throwsNoSuchMethodError', () {
57 shouldPass(() { throw new NoSuchMethodError(null, '', null, null); },
58 throwsNoSuchMethodError);
59 shouldFail(() { throw new Exception(); },
60 throwsNoSuchMethodError,
61 matches(
62 r"Expected: throws an exception which matches NoSuchMethodError +"
63 r"But: exception " + _minifiedName + r":<Exception> "
64 r"does not match NoSuchMethodError\."
65 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
66 });
67
68 test('throwsUnimplementedError', () {
69 shouldPass(() { throw new UnimplementedError(''); },
70 throwsUnimplementedError);
71 shouldFail(() { throw new Exception(); },
72 throwsUnimplementedError,
73 matches(
74 r"Expected: throws an exception which matches "
75 r"UnimplementedError +"
76 r"But: exception " + _minifiedName + r":<Exception> "
77 r"does not match UnimplementedError\."
78 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
79 });
80
81 test('throwsUnsupportedError', () {
82 shouldPass(() { throw new UnsupportedError(''); },
83 throwsUnsupportedError);
84 shouldFail(() { throw new Exception(); },
85 throwsUnsupportedError,
86 matches(
87 r"Expected: throws an exception which matches UnsupportedError +"
88 r"But: exception " + _minifiedName + r":<Exception> "
89 r"does not match UnsupportedError\."
90 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
91 });
92
93 test('throwsStateError', () {
94 shouldPass(() { throw new StateError(''); },
95 throwsStateError);
96 shouldFail(() { throw new Exception(); },
97 throwsStateError,
98 matches(
99 r"Expected: throws an exception which matches StateError +"
100 r"But: exception " + _minifiedName + r":<Exception> "
101 r"does not match StateError\."
102 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
103 });
104 });
105
106 group('Iterable Matchers', () {
107 test('isEmpty', () {
108 var d = new SimpleIterable(0);
109 var e = new SimpleIterable(1);
110 shouldPass(d, isEmpty);
111 shouldFail(e, isEmpty,
112 matches(r"Expected: empty +But: was " + _minifiedName + r":\[1\]\."));
113 });
114
115 test('contains', () {
116 var d = new SimpleIterable(3);
117 shouldPass(d, contains(2));
118 shouldFail(d, contains(5),
119 matches(
120 r"Expected: contains <5> +"
121 r"But: was " + _minifiedName + r":\[3, 2, 1\]\."));
122 });
123 });
124
125 group('Feature Matchers', () {
126 test("Feature Matcher", () {
127 var w = new Widget();
128 w.price = 10;
129 shouldPass(w, new HasPrice(10));
130 shouldPass(w, new HasPrice(greaterThan(0)));
131 shouldFail(w, new HasPrice(greaterThan(10)),
132 matches(
133 r"Expected: Widget with a price that is a value greater than "
134 r"<10> +"
135 r"But: price was <10>\."
136 r"Actual: <Instance of '" + _minifiedName + r"'>"));
137 });
138 });
139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698