Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: tests/corelib/string_base_vm_test.dart

Issue 11035057: Hide internal details of VM string implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, 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 #import("dart:coreimpl");
8
9 7
10 class StringBaseTest { 8 class StringBaseTest {
11 9
12 StringBaseTest() {} 10 StringBaseTest() {}
13 11
14 toString() { 12 toString() {
15 return "StringBase Tester"; 13 return "StringBase Tester";
16 } 14 }
17 static testSubstringMatches() {
18 Expect.equals(true, "Hello".substringMatches(0, "Hello"));
19 Expect.equals(true, "Hello World".substringMatches(0, "Hello"));
20 Expect.equals(false, "My Hello World".substringMatches(0, "Hello"));
21 Expect.equals(true, "My Hello World".substringMatches(6, "lo W"));
22 Expect.equals(false, "Hello".substringMatches(0, "low"));
23 }
24 15
25 static testInterpolation() { 16 static testInterpolation() {
26 var answer = 40 + 2; 17 var answer = 40 + 2;
27 var s = "The answer is $answer."; 18 var s = "The answer is $answer.";
28 Expect.equals("The answer is 42.", s); 19 Expect.equals("The answer is 42.", s);
29 20
30 int numBottles = 33; 21 int numBottles = 33;
31 String wall = "wall"; 22 String wall = "wall";
32 s = "${numBottles*3} bottles of beer on the $wall."; 23 s = "${numBottles*3} bottles of beer on the $wall.";
33 Expect.equals("99 bottles of beer on the wall.", s); 24 Expect.equals("99 bottles of beer on the wall.", s);
34 } 25 }
35 26
36 static testCreation() { 27 static testCreation() {
37 String s = "Hello"; 28 String s = "Hello";
38 List<int> a = new List(s.length); 29 List<int> a = new List(s.length);
39 List<int> ga = new List(); 30 List<int> ga = new List();
40 bool exception_caught = false; 31 bool exception_caught = false;
41 for (int i = 0; i < a.length; i++) { 32 for (int i = 0; i < a.length; i++) {
42 a[i] = s.charCodeAt(i); 33 a[i] = s.charCodeAt(i);
43 ga.add(s.charCodeAt(i)); 34 ga.add(s.charCodeAt(i));
44 } 35 }
45 String s2 = StringBase.createFromCharCodes(a);
46 Expect.equals(s, s2);
47 String s3 = StringBase.createFromCharCodes(ga);
48 Expect.equals(s, s3);
49 try { 36 try {
50 String s4 = new String.fromCharCodes([0.0]); 37 String s4 = new String.fromCharCodes([0.0]);
51 } on ArgumentError catch (ex) { 38 } on ArgumentError catch (ex) {
52 exception_caught = true; 39 exception_caught = true;
53 } 40 }
54 Expect.equals(true, exception_caught); 41 Expect.equals(true, exception_caught);
55 exception_caught = false; 42 exception_caught = false;
56 try { 43 try {
57 String s4 = new String.fromCharCodes([-1]); 44 String s4 = new String.fromCharCodes([-1]);
58 } on ArgumentError catch (ex) { 45 } on ArgumentError catch (ex) {
(...skipping 16 matching lines...) Expand all
75 exception_caught = false; 62 exception_caught = false;
76 try { 63 try {
77 s.substring(5, 4); 64 s.substring(5, 4);
78 } on IndexOutOfRangeException catch (ex) { 65 } on IndexOutOfRangeException catch (ex) {
79 exception_caught = true; 66 exception_caught = true;
80 } 67 }
81 Expect.equals(true, exception_caught); 68 Expect.equals(true, exception_caught);
82 } 69 }
83 70
84 static void testMain() { 71 static void testMain() {
85 testSubstringMatches();
86 testInterpolation(); 72 testInterpolation();
87 testCreation(); 73 testCreation();
88 testSubstring(); 74 testSubstring();
89 } 75 }
90 } 76 }
91 77
92 main() { 78 main() {
93 StringBaseTest.testMain(); 79 StringBaseTest.testMain();
94 } 80 }
OLDNEW
« no previous file with comments | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698