| 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 string_base_test; | 6 library string_base_test; |
| 7 | 7 |
| 8 class StringBaseTest { | 8 class StringBaseTest { |
| 9 | 9 |
| 10 StringBaseTest() {} | 10 StringBaseTest() {} |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 s = "${numBottles*3} bottles of beer on the $wall."; | 23 s = "${numBottles*3} bottles of beer on the $wall."; |
| 24 Expect.equals("99 bottles of beer on the wall.", s); | 24 Expect.equals("99 bottles of beer on the wall.", s); |
| 25 } | 25 } |
| 26 | 26 |
| 27 static testCreation() { | 27 static testCreation() { |
| 28 String s = "Hello"; | 28 String s = "Hello"; |
| 29 List<int> a = new List.fixedLength(s.length); | 29 List<int> a = new List.fixedLength(s.length); |
| 30 List<int> ga = new List(); | 30 List<int> ga = new List(); |
| 31 bool exception_caught = false; | 31 bool exception_caught = false; |
| 32 for (int i = 0; i < a.length; i++) { | 32 for (int i = 0; i < a.length; i++) { |
| 33 a[i] = s.charCodeAt(i); | 33 a[i] = s.codeUnitAt(i); |
| 34 ga.add(s.charCodeAt(i)); | 34 ga.add(s.codeUnitAt(i)); |
| 35 } | 35 } |
| 36 try { | 36 try { |
| 37 String s4 = new String.fromCharCodes([0.0]); | 37 String s4 = new String.fromCharCodes([0.0]); |
| 38 } on ArgumentError catch (ex) { | 38 } on ArgumentError catch (ex) { |
| 39 exception_caught = true; | 39 exception_caught = true; |
| 40 } | 40 } |
| 41 Expect.equals(true, exception_caught); | 41 Expect.equals(true, exception_caught); |
| 42 exception_caught = false; | 42 exception_caught = false; |
| 43 try { | 43 try { |
| 44 String s4 = new String.fromCharCodes([-1]); | 44 String s4 = new String.fromCharCodes([-1]); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 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 |