OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** This file is sourced by unittest.dart. It defines [Expectation]. */ | 5 /** This file is sourced by unittest.dart. It defines [Expectation]. */ |
6 | 6 |
7 /** | 7 /** |
8 * Wraps an value and provides methods that can be used to verify that the value | 8 * Wraps an value and provides methods that can be used to verify that the value |
9 * matches a given expectation. | 9 * matches a given expectation. |
10 */ | 10 */ |
(...skipping 20 matching lines...) Expand all Loading... |
31 /** | 31 /** |
32 * Asserts that the difference between [expected] and the value is within | 32 * Asserts that the difference between [expected] and the value is within |
33 * [tolerance]. If no tolerance is given, it is assumed to be the value 4 | 33 * [tolerance]. If no tolerance is given, it is assumed to be the value 4 |
34 * significant digits smaller than the expected value. | 34 * significant digits smaller than the expected value. |
35 */ | 35 */ |
36 void approxEquals(num expected, | 36 void approxEquals(num expected, |
37 [num tolerance = null, String reason = null]) { | 37 [num tolerance = null, String reason = null]) { |
38 Expect.approxEquals(expected, _value, tolerance: tolerance, reason: reason); | 38 Expect.approxEquals(expected, _value, tolerance: tolerance, reason: reason); |
39 } | 39 } |
40 | 40 |
| 41 /** |
| 42 * Asserts that two objects are same (using [:===:]). |
| 43 */ |
| 44 void same(expected) { |
| 45 Expect.identical(_value, expected); |
| 46 } |
| 47 |
41 /** Asserts that the value is [null]. */ | 48 /** Asserts that the value is [null]. */ |
42 void isNull() { | 49 void isNull() { |
43 Expect.equals(null, _value); | 50 Expect.equals(null, _value); |
44 } | 51 } |
45 | 52 |
46 /** Asserts that the value is not [null]. */ | 53 /** Asserts that the value is not [null]. */ |
47 void isNotNull() { | 54 void isNotNull() { |
48 Expect.notEquals(null, _value); | 55 Expect.notEquals(null, _value); |
49 } | 56 } |
50 | 57 |
(...skipping 13 matching lines...) Expand all Loading... |
64 } | 71 } |
65 | 72 |
66 /** | 73 /** |
67 * Checks that every element of [expected] is also in [actual], and that | 74 * Checks that every element of [expected] is also in [actual], and that |
68 * every element of [actual] is also in [expected]. | 75 * every element of [actual] is also in [expected]. |
69 */ | 76 */ |
70 void equalsSet(Iterable expected) { | 77 void equalsSet(Iterable expected) { |
71 Expect.setEquals(expected, _value); | 78 Expect.setEquals(expected, _value); |
72 } | 79 } |
73 } | 80 } |
OLD | NEW |