| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A test of simple runtime behavior on numbers, strings and lists with | 8 * A test of simple runtime behavior on numbers, strings and lists with |
| 9 * a focus on both correct behavior and runtime errors. | 9 * a focus on both correct behavior and runtime errors. |
| 10 * | 10 * |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 assertEquals(x | y, 19); | 76 assertEquals(x | y, 19); |
| 77 assertEquals(x & y, 16); | 77 assertEquals(x & y, 16); |
| 78 assertEquals(x ^ y, 3); | 78 assertEquals(x ^ y, 3); |
| 79 assertEquals(2 >> 1, 1); | 79 assertEquals(2 >> 1, 1); |
| 80 assertEquals(1 << 1, 2); | 80 assertEquals(1 << 1, 2); |
| 81 } | 81 } |
| 82 | 82 |
| 83 static testOperatorErrors() { | 83 static testOperatorErrors() { |
| 84 var objs = [1, '2', [3], null, true, new Map()]; | 84 var objs = [1, '2', [3], null, true, new Map()]; |
| 85 for (var i=0; i < objs.length; i++) { | 85 for (var i=0; i < objs.length; i++) { |
| 86 for (var j=i+1; j < objs.length; j++) { | 86 for (var j= i + 1; j < objs.length; j++) { |
| 87 testBinaryOperatorErrors(objs[i], objs[j]); | 87 testBinaryOperatorErrors(objs[i], objs[j]); |
| 88 testBinaryOperatorErrors(objs[j], objs[i]); | 88 // Allow "String * int". |
| 89 if (j > 2) testBinaryOperatorErrors(objs[j], objs[i]); |
| 89 } | 90 } |
| 90 if (objs[i] != 1) { | 91 if (objs[i] != 1) { |
| 91 testUnaryOperatorErrors(objs[i]); | 92 testUnaryOperatorErrors(objs[i]); |
| 92 } | 93 } |
| 93 } | 94 } |
| 94 } | 95 } |
| 95 | 96 |
| 96 static testBinaryOperatorErrors(x, y) { | 97 static testBinaryOperatorErrors(x, y) { |
| 97 assertTypeError(() { x - y;}); | 98 assertTypeError(() { x - y;}); |
| 98 assertTypeError(() { x * y;}); | 99 assertTypeError(() { x * y;}); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 '${true}'.toString(); | 278 '${true}'.toString(); |
| 278 '${false}'.toString(); | 279 '${false}'.toString(); |
| 279 ''.toString(); | 280 ''.toString(); |
| 280 ''.endsWith(''); | 281 ''.endsWith(''); |
| 281 } | 282 } |
| 282 } | 283 } |
| 283 | 284 |
| 284 main() { | 285 main() { |
| 285 CoreRuntimeTypesTest.testMain(); | 286 CoreRuntimeTypesTest.testMain(); |
| 286 } | 287 } |
| OLD | NEW |