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