OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, 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 library test_base; |
| 6 |
| 7 expectIs(expected, actual, [String note]) { |
| 8 if (expected != actual) { |
| 9 if (note != null) { |
| 10 throw "Expected: '$expected': $note, actual: '$actual'"; |
| 11 } |
| 12 throw "Expected: '$expected', actual: '$actual'"; |
| 13 } |
| 14 } |
| 15 |
| 16 expectTrue(actual) => expectIs(true, actual); |
| 17 |
| 18 expectFalse(actual) => expectIs(false, actual); |
| 19 |
| 20 expectThrows(f(), test(e)) { |
| 21 var exception = false; |
| 22 String note = null; |
| 23 try { |
| 24 f(); |
| 25 } catch (e) { |
| 26 exception = test(e); |
| 27 if (!exception) { |
| 28 note = "$e [${e.runtimeType}]"; |
| 29 } |
| 30 } |
| 31 expectIs(true, exception, note); |
| 32 } |
| 33 |
| 34 expectOutput(String expected) => expectIs(expected, output); |
| 35 |
| 36 String output; |
| 37 |
| 38 write(o) { |
| 39 output = output == null ? "$o" : "$output\n$o"; |
| 40 } |
OLD | NEW |