| 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 // VMOptions=--enable_type_checks | |
| 5 // | |
| 6 // Dart test program testing assert statements. | |
| 7 | |
| 8 class AssertionTest { | |
| 9 static testTrue() { | |
| 10 int i = 0; | |
| 11 try { | |
| 12 assert(true); | |
| 13 } catch (AssertionError error) { | |
| 14 i = 1; | |
| 15 } | |
| 16 return i; | |
| 17 } | |
| 18 | |
| 19 static testFalse() { | |
| 20 int i = 0; | |
| 21 try { | |
| 22 assert(false); | |
| 23 } catch (AssertionError error) { | |
| 24 i = 1; | |
| 25 } | |
| 26 return i; | |
| 27 } | |
| 28 | |
| 29 static unknown(var a) { | |
| 30 return (a) ? true : false; | |
| 31 } | |
| 32 | |
| 33 static testUnknown() { | |
| 34 var x = unknown(false); | |
| 35 int i = 0; | |
| 36 try { | |
| 37 assert(x); | |
| 38 } catch (AssertionError error) { | |
| 39 i = 1; | |
| 40 } | |
| 41 return i; | |
| 42 } | |
| 43 | |
| 44 static testClosure() { | |
| 45 int i = 0; | |
| 46 try { | |
| 47 assert(() => false); | |
| 48 } catch (AssertionError error) { | |
| 49 i = 1; | |
| 50 } | |
| 51 return i; | |
| 52 } | |
| 53 | |
| 54 static testClosure2() { | |
| 55 int i = 0; | |
| 56 try { | |
| 57 var x = () => false; | |
| 58 assert(x); | |
| 59 } catch (AssertionError error) { | |
| 60 i = 1; | |
| 61 } | |
| 62 return i; | |
| 63 } | |
| 64 | |
| 65 static testMain() { | |
| 66 Expect.equals(0, testTrue()); | |
| 67 Expect.equals(1, testFalse()); | |
| 68 Expect.equals(1, testClosure()); | |
| 69 Expect.equals(1, testClosure2()); | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 main() { | |
| 74 AssertionTest.testMain(); | |
| 75 } | |
| OLD | NEW |