| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Dart test program for testing class 'StringBase' (currently VM specific). | 4 // Dart test program for testing class 'StringBase' (currently VM specific). |
| 5 | 5 |
| 6 #library("StringBaseTest.dart"); | 6 #library("StringBaseTest.dart"); |
| 7 | 7 |
| 8 class StringBaseTest { | 8 class StringBaseTest { |
| 9 | 9 |
| 10 StringBaseTest() {} | 10 StringBaseTest() {} |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 Expect.equals(true, exception_caught); | 48 Expect.equals(true, exception_caught); |
| 49 } | 49 } |
| 50 | 50 |
| 51 static testSubstring() { | 51 static testSubstring() { |
| 52 String s = "Hello World"; | 52 String s = "Hello World"; |
| 53 Expect.equals("World", s.substring(6, s.length)); | 53 Expect.equals("World", s.substring(6, s.length)); |
| 54 Expect.equals("", s.substring(8, 8)); | 54 Expect.equals("", s.substring(8, 8)); |
| 55 bool exception_caught = false; | 55 bool exception_caught = false; |
| 56 try { | 56 try { |
| 57 s.substring(5, 12); | 57 s.substring(5, 12); |
| 58 } on IndexOutOfRangeException catch (ex) { | 58 } on RangeError catch (ex) { |
| 59 exception_caught = true; | 59 exception_caught = true; |
| 60 } | 60 } |
| 61 Expect.equals(true, exception_caught); | 61 Expect.equals(true, exception_caught); |
| 62 exception_caught = false; | 62 exception_caught = false; |
| 63 try { | 63 try { |
| 64 s.substring(5, 4); | 64 s.substring(5, 4); |
| 65 } on IndexOutOfRangeException catch (ex) { | 65 } on RangeError catch (ex) { |
| 66 exception_caught = true; | 66 exception_caught = true; |
| 67 } | 67 } |
| 68 Expect.equals(true, exception_caught); | 68 Expect.equals(true, exception_caught); |
| 69 } | 69 } |
| 70 | 70 |
| 71 static void testMain() { | 71 static void testMain() { |
| 72 testInterpolation(); | 72 testInterpolation(); |
| 73 testCreation(); | 73 testCreation(); |
| 74 testSubstring(); | 74 testSubstring(); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 main() { | 78 main() { |
| 79 StringBaseTest.testMain(); | 79 StringBaseTest.testMain(); |
| 80 } | 80 } |
| OLD | NEW |