OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:matcher/matcher.dart'; | 5 import 'package:matcher/matcher.dart'; |
6 import 'package:test/test.dart' show test, expect; | 6 import 'package:test/test.dart' show test, expect; |
7 | 7 |
8 import 'test_utils.dart'; | 8 import 'test_utils.dart'; |
9 | 9 |
10 void main() { | 10 void main() { |
11 test('Reports mismatches in whitespace and escape sequences', () { | 11 test('Reports mismatches in whitespace and escape sequences', () { |
12 shouldFail('before\nafter', equals('before\\nafter'), | 12 shouldFail('before\nafter', equals('before\\nafter'), |
13 contains('Differ at offset 7')); | 13 contains('Differ at offset 7')); |
14 }); | 14 }); |
15 | 15 |
| 16 test("Retains outer matcher mismatch text", () { |
| 17 shouldFail( |
| 18 {'word': 'thing'}, |
| 19 containsPair('word', equals('notthing')), |
| 20 allOf([ |
| 21 contains("contains key 'word' but with value is different"), |
| 22 contains("Differ at offset 0") |
| 23 ])); |
| 24 }); |
| 25 |
16 test('collapseWhitespace', () { | 26 test('collapseWhitespace', () { |
17 var source = '\t\r\n hello\t\r\n world\r\t \n'; | 27 var source = '\t\r\n hello\t\r\n world\r\t \n'; |
18 expect(collapseWhitespace(source), 'hello world'); | 28 expect(collapseWhitespace(source), 'hello world'); |
19 }); | 29 }); |
20 | 30 |
21 test('isEmpty', () { | 31 test('isEmpty', () { |
22 shouldPass('', isEmpty); | 32 shouldPass('', isEmpty); |
23 shouldFail(null, isEmpty, startsWith("Expected: empty Actual: <null>")); | 33 shouldFail(null, isEmpty, startsWith("Expected: empty Actual: <null>")); |
24 shouldFail(0, isEmpty, startsWith("Expected: empty Actual: <0>")); | 34 shouldFail(0, isEmpty, startsWith("Expected: empty Actual: <0>")); |
25 shouldFail('a', isEmpty, startsWith("Expected: empty Actual: 'a'")); | 35 shouldFail('a', isEmpty, startsWith("Expected: empty Actual: 'a'")); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 "Actual: 'goodbye cruel world'"); | 119 "Actual: 'goodbye cruel world'"); |
110 }); | 120 }); |
111 | 121 |
112 test('matches', () { | 122 test('matches', () { |
113 shouldPass('c0d', matches('[a-z][0-9][a-z]')); | 123 shouldPass('c0d', matches('[a-z][0-9][a-z]')); |
114 shouldPass('c0d', matches(new RegExp('[a-z][0-9][a-z]'))); | 124 shouldPass('c0d', matches(new RegExp('[a-z][0-9][a-z]'))); |
115 shouldFail('cOd', matches('[a-z][0-9][a-z]'), | 125 shouldFail('cOd', matches('[a-z][0-9][a-z]'), |
116 "Expected: match '[a-z][0-9][a-z]' Actual: 'cOd'"); | 126 "Expected: match '[a-z][0-9][a-z]' Actual: 'cOd'"); |
117 }); | 127 }); |
118 } | 128 } |
OLD | NEW |