| OLD | NEW |
| (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 // Testing the Expect class. | |
| 5 | |
| 6 class ExpectTest { | |
| 7 | |
| 8 static testEquals(a) { | |
| 9 try { | |
| 10 Expect.equals("AB", a, "within testEquals"); | |
| 11 } catch (Exception msg) { | |
| 12 print(msg); | |
| 13 return; | |
| 14 } | |
| 15 Expect.equals("AB", "${a}B"); | |
| 16 throw "Expect.equals did not fail"; | |
| 17 } | |
| 18 | |
| 19 static testIsTrue(f) { | |
| 20 try { | |
| 21 Expect.isTrue(f); | |
| 22 } catch (Exception msg) { | |
| 23 print(msg); | |
| 24 return; | |
| 25 } | |
| 26 Expect.isFalse(f); | |
| 27 throw "Expect.isTrue did not fail"; | |
| 28 } | |
| 29 | |
| 30 static testIsFalse(t) { | |
| 31 try { | |
| 32 Expect.isFalse(t); | |
| 33 } catch (Exception msg) { | |
| 34 print(msg); | |
| 35 return; | |
| 36 } | |
| 37 Expect.isTrue(t); | |
| 38 throw "Expect.isFalse did not fail"; | |
| 39 } | |
| 40 | |
| 41 static testIdentical(a) { | |
| 42 var ab = "${a}B"; | |
| 43 try { | |
| 44 Expect.identical("AB", ab); | |
| 45 } catch (Exception msg) { | |
| 46 print(msg); | |
| 47 return; | |
| 48 } | |
| 49 Expect.equals("AB", ab); | |
| 50 throw "Expect.identical did not fail"; | |
| 51 } | |
| 52 | |
| 53 static testFail() { | |
| 54 try { | |
| 55 Expect.fail("fail now"); | |
| 56 } catch (Exception msg) { | |
| 57 print(msg); | |
| 58 return; | |
| 59 } | |
| 60 throw "Expect.fail did not fail"; | |
| 61 } | |
| 62 | |
| 63 static void testMain() { | |
| 64 testEquals("A"); | |
| 65 testIsTrue(false); | |
| 66 testIsTrue(1); | |
| 67 testIsFalse(true); | |
| 68 testIsFalse(0); | |
| 69 testIdentical("A"); | |
| 70 testFail(); | |
| 71 } | |
| 72 | |
| 73 } | |
| 74 | |
| 75 main() { | |
| 76 ExpectTest.testMain(); | |
| 77 } | |
| OLD | NEW |