| 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 // VMOptions=--enable_asserts |   4 // VMOptions=--enable_asserts | 
|   5 // |   5 // | 
|   6 // Dart test program testing assert statements. |   6 // Dart test program testing assert statements. | 
|   7  |   7  | 
|   8 class AssertTest { |   8 class AssertTest { | 
|   9   static test() { |   9   static test() { | 
|  10     int i = 0; |  | 
|  11     try { |  10     try { | 
|  12       assert(false); |  11       assert(false); | 
 |  12       Expect.fail("Assertion 'false' didn't fail."); | 
|  13     } on AssertionError catch (error) { |  13     } on AssertionError catch (error) { | 
|  14       i = 1; |  | 
|  15       Expect.equals("false", error.failedAssertion); |  14       Expect.equals("false", error.failedAssertion); | 
|  16       int pos = error.url.lastIndexOf("/", error.url.length); |  15       int pos = error.url.lastIndexOf("/", error.url.length); | 
|  17       if (pos == -1) { |  16       if (pos == -1) { | 
|  18         pos = error.url.lastIndexOf("\\", error.url.length); |  17         pos = error.url.lastIndexOf("\\", error.url.length); | 
|  19       } |  18       } | 
|  20       String subs = error.url.substring(pos + 1, error.url.length); |  19       String subs = error.url.substring(pos + 1, error.url.length); | 
|  21       Expect.equals("assert_test.dart", subs); |  20       Expect.equals("assert_test.dart", subs); | 
|  22       Expect.equals(12, error.line); |  21       Expect.equals(11, error.line); | 
|  23       Expect.equals(14, error.column); |  22       Expect.equals(14, error.column); | 
|  24     } |  23     } | 
|  25     return i; |  | 
|  26   } |  24   } | 
|  27   static testClosure() { |  25   static testClosure() { | 
|  28     int i = 0; |  | 
|  29     try { |  26     try { | 
|  30       assert(() => false); |  27       assert(() => false); | 
 |  28       Expect.fail("Assertion '() => false' didn't fail."); | 
|  31     } on AssertionError catch (error) { |  29     } on AssertionError catch (error) { | 
|  32       i = 1; |  | 
|  33       Expect.equals("() => false", error.failedAssertion); |  30       Expect.equals("() => false", error.failedAssertion); | 
|  34       int pos = error.url.lastIndexOf("/", error.url.length); |  31       int pos = error.url.lastIndexOf("/", error.url.length); | 
|  35       if (pos == -1) { |  32       if (pos == -1) { | 
|  36         pos = error.url.lastIndexOf("\\", error.url.length); |  33         pos = error.url.lastIndexOf("\\", error.url.length); | 
|  37       } |  34       } | 
|  38       String subs = error.url.substring(pos + 1, error.url.length); |  35       String subs = error.url.substring(pos + 1, error.url.length); | 
|  39       Expect.equals("assert_test.dart", subs); |  36       Expect.equals("assert_test.dart", subs); | 
|  40       Expect.equals(30, error.line); |  37       Expect.equals(27, error.line); | 
|  41       Expect.equals(14, error.column); |  38       Expect.equals(14, error.column); | 
|  42     } |  39     } | 
|  43     return i; |  | 
|  44   } |  40   } | 
|  45  |  41  | 
|  46   static testMain() { |  42   static testMain() { | 
|  47     Expect.equals(1, test()); |  43     test(); | 
|  48     Expect.equals(1, testClosure()); |  44     testClosure(); | 
|  49   } |  45   } | 
|  50 } |  46 } | 
|  51  |  47  | 
|  52 main() { |  48 main() { | 
|  53   AssertTest.testMain(); |  49   AssertTest.testMain(); | 
|  54 } |  50 } | 
| OLD | NEW |