| 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 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 | 9 |
| 10 class StringBaseTest { | 10 class StringBaseTest { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 static testCreation() { | 28 static testCreation() { |
| 29 String s = "Hello"; | 29 String s = "Hello"; |
| 30 List<int> a = new List(s.length); | 30 List<int> a = new List(s.length); |
| 31 List<int> ga = new List(); | 31 List<int> ga = new List(); |
| 32 bool exception_caught = false; | 32 bool exception_caught = false; |
| 33 for (int i = 0; i < a.length; i++) { | 33 for (int i = 0; i < a.length; i++) { |
| 34 a[i] = s.codeUnitAt(i); | 34 a[i] = s.codeUnitAt(i); |
| 35 ga.add(s.codeUnitAt(i)); | 35 ga.add(s.codeUnitAt(i)); |
| 36 } | 36 } |
| 37 try { | 37 try { |
| 38 String s4 = new String.fromCharCodes([0.0]); | |
| 39 } on ArgumentError catch (ex) { | |
| 40 exception_caught = true; | |
| 41 } on TypeError catch (ex) { | |
| 42 exception_caught = true; | |
| 43 } | |
| 44 Expect.equals(true, exception_caught); | |
| 45 exception_caught = false; | |
| 46 try { | |
| 47 String s4 = new String.fromCharCodes([-1]); | 38 String s4 = new String.fromCharCodes([-1]); |
| 48 } on ArgumentError catch (ex) { | 39 } on ArgumentError catch (ex) { |
| 49 exception_caught = true; | 40 exception_caught = true; |
| 50 } | 41 } |
| 51 Expect.equals(true, exception_caught); | 42 Expect.equals(true, exception_caught); |
| 52 } | 43 } |
| 53 | 44 |
| 54 static testSubstring() { | 45 static testSubstring() { |
| 55 String s = "Hello World"; | 46 String s = "Hello World"; |
| 56 Expect.equals("World", s.substring(6, s.length)); | 47 Expect.equals("World", s.substring(6, s.length)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 74 static void testMain() { | 65 static void testMain() { |
| 75 testInterpolation(); | 66 testInterpolation(); |
| 76 testCreation(); | 67 testCreation(); |
| 77 testSubstring(); | 68 testSubstring(); |
| 78 } | 69 } |
| 79 } | 70 } |
| 80 | 71 |
| 81 main() { | 72 main() { |
| 82 StringBaseTest.testMain(); | 73 StringBaseTest.testMain(); |
| 83 } | 74 } |
| OLD | NEW |