| 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 // 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 #import("dart:coreimpl"); | 7 #import("dart:coreimpl"); |
| 8 | 8 |
| 9 | 9 |
| 10 class StringBaseTest { | 10 class StringBaseTest { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 for (int i = 0; i < a.length; i++) { | 41 for (int i = 0; i < a.length; i++) { |
| 42 a[i] = s.charCodeAt(i); | 42 a[i] = s.charCodeAt(i); |
| 43 ga.add(s.charCodeAt(i)); | 43 ga.add(s.charCodeAt(i)); |
| 44 } | 44 } |
| 45 String s2 = StringBase.createFromCharCodes(a); | 45 String s2 = StringBase.createFromCharCodes(a); |
| 46 Expect.equals(s, s2); | 46 Expect.equals(s, s2); |
| 47 String s3 = StringBase.createFromCharCodes(ga); | 47 String s3 = StringBase.createFromCharCodes(ga); |
| 48 Expect.equals(s, s3); | 48 Expect.equals(s, s3); |
| 49 try { | 49 try { |
| 50 String s4 = new String.fromCharCodes([0.0]); | 50 String s4 = new String.fromCharCodes([0.0]); |
| 51 } on IllegalArgumentException catch (ex) { | 51 } on ArgumentError catch (ex) { |
| 52 exception_caught = true; | 52 exception_caught = true; |
| 53 } | 53 } |
| 54 Expect.equals(true, exception_caught); | 54 Expect.equals(true, exception_caught); |
| 55 exception_caught = false; | 55 exception_caught = false; |
| 56 try { | 56 try { |
| 57 String s4 = new String.fromCharCodes([-1]); | 57 String s4 = new String.fromCharCodes([-1]); |
| 58 } on IllegalArgumentException catch (ex) { | 58 } on ArgumentError 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 } | 62 } |
| 63 | 63 |
| 64 static testSubstring() { | 64 static testSubstring() { |
| 65 String s = "Hello World"; | 65 String s = "Hello World"; |
| 66 Expect.equals("World", s.substring(6, s.length)); | 66 Expect.equals("World", s.substring(6, s.length)); |
| 67 Expect.equals("", s.substring(8, 8)); | 67 Expect.equals("", s.substring(8, 8)); |
| 68 bool exception_caught = false; | 68 bool exception_caught = false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 85 testSubstringMatches(); | 85 testSubstringMatches(); |
| 86 testInterpolation(); | 86 testInterpolation(); |
| 87 testCreation(); | 87 testCreation(); |
| 88 testSubstring(); | 88 testSubstring(); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 main() { | 92 main() { |
| 93 StringBaseTest.testMain(); | 93 StringBaseTest.testMain(); |
| 94 } | 94 } |
| OLD | NEW |