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 | 4 |
5 /** | 5 /** |
6 * A test of simple runtime behavior on numbers, strings and arrays with | 6 * A test of simple runtime behavior on numbers, strings and arrays with |
7 * a focus on both correct behavior and runtime errors. | 7 * a focus on both correct behavior and runtime errors. |
8 * | 8 * |
9 * This file is written to use minimal type declarations to match a | 9 * This file is written to use minimal type declarations to match a |
10 * typical dynamic language coding style. | 10 * typical dynamic language coding style. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 assertEquals(y.isEven, false); | 140 assertEquals(y.isEven, false); |
141 assertEquals(y.isOdd, true); | 141 assertEquals(y.isOdd, true); |
142 assertEquals(y.toRadixString(2), '1001'); | 142 assertEquals(y.toRadixString(2), '1001'); |
143 assertEquals(y.toRadixString(3), '100'); | 143 assertEquals(y.toRadixString(3), '100'); |
144 assertEquals(y.toRadixString(16), '9'); | 144 assertEquals(y.toRadixString(16), '9'); |
145 } | 145 } |
146 | 146 |
147 static testStringOperators() { | 147 static testStringOperators() { |
148 var s = "abcdef"; | 148 var s = "abcdef"; |
149 assertEquals(s, "abcdef"); | 149 assertEquals(s, "abcdef"); |
150 assertEquals(s.charCodeAt(0), 97); | 150 assertEquals(s.codeUnitAt(0), 97); |
151 assertEquals(s[0], 'a'); | 151 assertEquals(s[0], 'a'); |
152 assertEquals(s.length, 6); | 152 assertEquals(s.length, 6); |
153 assertTypeError(function() { s[null]; }); | 153 assertTypeError(function() { s[null]; }); |
154 assertTypeError(function() { s['hello']; }); | 154 assertTypeError(function() { s['hello']; }); |
155 assertTypeError(function() { s[0] = 'x'; }); | 155 assertTypeError(function() { s[0] = 'x'; }); |
156 } | 156 } |
157 | 157 |
158 // TODO(jimhug): Fill out full set of string methods. | 158 // TODO(jimhug): Fill out full set of string methods. |
159 static testStringMethods() { | 159 static testStringMethods() { |
160 var s = "abcdef"; | 160 var s = "abcdef"; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 .5.toString(); | 266 .5.toString(); |
267 1.toString(); | 267 1.toString(); |
268 if (false) { | 268 if (false) { |
269 null.toString(); | 269 null.toString(); |
270 } | 270 } |
271 '${1}'.toString(); | 271 '${1}'.toString(); |
272 ''.toString(); | 272 ''.toString(); |
273 ''.endsWith(''); | 273 ''.endsWith(''); |
274 } | 274 } |
275 } | 275 } |
OLD | NEW |