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

Side by Side Diff: lib/unittest/expectation.dart

Issue 10037027: unittest step2: bye bye to multiple entrypoints for unittest (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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
« no previous file with comments | « lib/unittest/dom_config.dart ('k') | lib/unittest/html_config.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /** This file is sourced by unittest.dart. It defines [Expectation]. */
6
7 /**
8 * Wraps an value and provides methods that can be used to verify that the value
9 * matches a given expectation.
10 */
11 class Expectation {
12 final _value;
13
14 Expectation(this._value);
15
16 /** Asserts that the value is equivalent to [expected]. */
17 void equals(expected) {
18 // Use the type-specialized versions when appropriate to give better
19 // error messages.
20 if (_value is String && expected is String) {
21 Expect.stringEquals(expected, _value);
22 } else if (_value is Map && expected is Map) {
23 Expect.mapEquals(expected, _value);
24 } else if (_value is Set && expected is Set) {
25 Expect.setEquals(expected, _value);
26 } else {
27 Expect.equals(expected, _value);
28 }
29 }
30
31 /**
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
34 * significant digits smaller than the expected value.
35 */
36 void approxEquals(num expected,
37 [num tolerance = null, String reason = null]) {
38 Expect.approxEquals(expected, _value, tolerance: tolerance, reason: reason);
39 }
40
41 /** Asserts that the value is [null]. */
42 void isNull() {
43 Expect.equals(null, _value);
44 }
45
46 /** Asserts that the value is not [null]. */
47 void isNotNull() {
48 Expect.notEquals(null, _value);
49 }
50
51 /** Asserts that the value is [true]. */
52 void isTrue() {
53 Expect.equals(true, _value);
54 }
55
56 /** Asserts that the value is [false]. */
57 void isFalse() {
58 Expect.equals(false, _value);
59 }
60
61 /** Asserts that the value has the same elements as [expected]. */
62 void equalsCollection(Collection expected) {
63 Expect.listEquals(expected, _value);
64 }
65
66 /**
67 * Checks that every element of [expected] is also in [actual], and that
68 * every element of [actual] is also in [expected].
69 */
70 void equalsSet(Iterable expected) {
71 Expect.setEquals(expected, _value);
72 }
73 }
OLDNEW
« no previous file with comments | « lib/unittest/dom_config.dart ('k') | lib/unittest/html_config.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698