Chromium Code Reviews| 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 // Testing the Expect class. | 4 // Testing the Expect class. |
| 5 | 5 |
| 6 class ExpectTest { | 6 class ExpectTest { |
| 7 | 7 |
| 8 static testEquals(a) { | 8 static testEquals(a) { |
| 9 try { | 9 try { |
| 10 Expect.equals("AB", a, "within testEquals"); | 10 Expect.equals("AB", a, "within testEquals"); |
| 11 } catch (Exception msg) { | 11 } catch (Exception msg) { |
| 12 print(msg); | 12 print(msg); |
| 13 return; | 13 return; |
| 14 } | 14 } |
| 15 Expect.equals("AB", a + "B"); | 15 Expect.equals("AB", a.concat("B")); |
|
kasperl
2012/03/12 06:55:42
String interpolation?
Ivan Posva
2012/04/11 14:26:00
Done.
| |
| 16 throw "Expect.equals did not fail"; | 16 throw "Expect.equals did not fail"; |
| 17 } | 17 } |
| 18 | 18 |
| 19 static testIsTrue(f) { | 19 static testIsTrue(f) { |
| 20 try { | 20 try { |
| 21 Expect.isTrue(f); | 21 Expect.isTrue(f); |
| 22 } catch (Exception msg) { | 22 } catch (Exception msg) { |
| 23 print(msg); | 23 print(msg); |
| 24 return; | 24 return; |
| 25 } | 25 } |
| 26 Expect.isFalse(f); | 26 Expect.isFalse(f); |
| 27 throw "Expect.isTrue did not fail"; | 27 throw "Expect.isTrue did not fail"; |
| 28 } | 28 } |
| 29 | 29 |
| 30 static testIsFalse(t) { | 30 static testIsFalse(t) { |
| 31 try { | 31 try { |
| 32 Expect.isFalse(t); | 32 Expect.isFalse(t); |
| 33 } catch (Exception msg) { | 33 } catch (Exception msg) { |
| 34 print(msg); | 34 print(msg); |
| 35 return; | 35 return; |
| 36 } | 36 } |
| 37 Expect.isTrue(t); | 37 Expect.isTrue(t); |
| 38 throw "Expect.isFalse did not fail"; | 38 throw "Expect.isFalse did not fail"; |
| 39 } | 39 } |
| 40 | 40 |
| 41 static testIdentical(a) { | 41 static testIdentical(a) { |
| 42 var ab = a + "B"; | 42 var ab = a.concat("B"); |
|
kasperl
2012/03/12 06:55:42
String interpolation?
Ivan Posva
2012/04/11 14:26:00
Done.
| |
| 43 try { | 43 try { |
| 44 Expect.identical("AB", ab); | 44 Expect.identical("AB", ab); |
| 45 } catch (Exception msg) { | 45 } catch (Exception msg) { |
| 46 print(msg); | 46 print(msg); |
| 47 return; | 47 return; |
| 48 } | 48 } |
| 49 Expect.equals("AB", ab); | 49 Expect.equals("AB", ab); |
| 50 throw "Expect.identical did not fail"; | 50 throw "Expect.identical did not fail"; |
| 51 } | 51 } |
| 52 | 52 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 68 testIsFalse(0); | 68 testIsFalse(0); |
| 69 testIdentical("A"); | 69 testIdentical("A"); |
| 70 testFail(); | 70 testFail(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 } | 73 } |
| 74 | 74 |
| 75 main() { | 75 main() { |
| 76 ExpectTest.testMain(); | 76 ExpectTest.testMain(); |
| 77 } | 77 } |
| OLD | NEW |