| 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 /** | 5 /** |
| 6 * Description text of the current test group. If multiple groups are nested, | 6 * Description text of the current test group. If multiple groups are nested, |
| 7 * this will contain all of their text concatenated. | 7 * this will contain all of their text concatenated. |
| 8 */ | 8 */ |
| 9 String _currentGroup = ''; | 9 String _currentGroup = ''; |
| 10 | 10 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 * Wraps an value and provides an "==" operator that can be used to verify that | 256 * Wraps an value and provides an "==" operator that can be used to verify that |
| 257 * the value matches a given expectation. | 257 * the value matches a given expectation. |
| 258 */ | 258 */ |
| 259 class Expectation { | 259 class Expectation { |
| 260 final _value; | 260 final _value; |
| 261 | 261 |
| 262 Expectation(this._value); | 262 Expectation(this._value); |
| 263 | 263 |
| 264 /** Asserts that the value is equivalent to [expected]. */ | 264 /** Asserts that the value is equivalent to [expected]. */ |
| 265 void equals(expected) { | 265 void equals(expected) { |
| 266 Expect.equals(expected, _value); | 266 if (_value is String && expected is String) { |
| 267 Expect.stringEquals(expected, _value); |
| 268 } else { |
| 269 Expect.equals(expected, _value); |
| 270 } |
| 267 } | 271 } |
| 268 | 272 |
| 269 /** | 273 /** |
| 270 * Asserts that the difference between [expected] and the value is within | 274 * Asserts that the difference between [expected] and the value is within |
| 271 * [tolerance]. If no tolerance is given, it is assumed to be the value 4 | 275 * [tolerance]. If no tolerance is given, it is assumed to be the value 4 |
| 272 * significant digits smaller than the expected value. | 276 * significant digits smaller than the expected value. |
| 273 */ | 277 */ |
| 274 void approxEquals(num expected, | 278 void approxEquals(num expected, |
| 275 [num tolerance = null, String reason = null]) { | 279 [num tolerance = null, String reason = null]) { |
| 276 Expect.approxEquals(expected, _value, tolerance: tolerance, reason: reason); | 280 Expect.approxEquals(expected, _value, tolerance: tolerance, reason: reason); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 358 } |
| 355 | 359 |
| 356 void error(String message_, String stackTrace_) { | 360 void error(String message_, String stackTrace_) { |
| 357 result = _ERROR; | 361 result = _ERROR; |
| 358 this.message = message_; | 362 this.message = message_; |
| 359 this.stackTrace = stackTrace_; | 363 this.stackTrace = stackTrace_; |
| 360 } | 364 } |
| 361 } | 365 } |
| 362 | 366 |
| 363 typedef void TestFunction(); | 367 typedef void TestFunction(); |
| OLD | NEW |