OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, 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:matcher/matcher.dart'; | |
11 import 'package:unittest/unittest.dart'; | |
12 | |
13 import 'test_utils.dart'; | |
14 | |
15 // A regexp fragment matching a minified name. | |
16 const _MINIFIED_NAME = r"[A-Za-z0-9]{1,3}"; | |
17 | |
18 void main() { | |
19 group('Iterable Matchers', () { | |
20 test('isEmpty', () { | |
21 var d = new SimpleIterable(0); | |
22 var e = new SimpleIterable(1); | |
23 shouldPass(d, isEmpty); | |
24 shouldFail(e, isEmpty, | |
25 matches(r"Expected: empty +Actual: " + _MINIFIED_NAME + r":\[1\]")); | |
26 }); | |
27 | |
28 test('isNotEmpty', () { | |
29 var d = new SimpleIterable(0); | |
30 var e = new SimpleIterable(1); | |
31 shouldPass(e, isNotEmpty); | |
32 shouldFail(d, isNotEmpty, matches( | |
33 r"Expected: non-empty +Actual: " + _MINIFIED_NAME + r":\[\]")); | |
34 }); | |
35 | |
36 test('contains', () { | |
37 var d = new SimpleIterable(3); | |
38 shouldPass(d, contains(2)); | |
39 shouldFail(d, contains(5), matches(r"Expected: contains <5> +" | |
40 r"Actual: " + _MINIFIED_NAME + r":\[3, 2, 1\]")); | |
41 }); | |
42 }); | |
43 | |
44 group('Feature Matchers', () { | |
45 test("Feature Matcher", () { | |
46 var w = new Widget(); | |
47 w.price = 10; | |
48 shouldPass(w, new HasPrice(10)); | |
49 shouldPass(w, new HasPrice(greaterThan(0))); | |
50 shouldFail(w, new HasPrice(greaterThan(10)), matches( | |
51 r"Expected: Widget with a price that is a value greater than " | |
52 r"<10> +" | |
53 r"Actual: <Instance of '" + _MINIFIED_NAME + r"'> +" | |
54 r"Which: has price with value <10> which is not " | |
55 r"a value greater than <10>")); | |
56 }); | |
57 }); | |
58 } | |
OLD | NEW |