| 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 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
| 7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import 'compiler_helper.dart'; | 8 import 'compiler_helper.dart'; |
| 9 | 9 |
| 10 const int REMOVED = 0; | 10 const int REMOVED = 0; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 254 } |
| 255 return sum; | 255 return sum; |
| 256 } | 256 } |
| 257 """, | 257 """, |
| 258 BELOW_ZERO_CHECK, | 258 BELOW_ZERO_CHECK, |
| 259 ]; | 259 ]; |
| 260 | 260 |
| 261 // TODO(ahe): It would probably be better if this test used the real | 261 // TODO(ahe): It would probably be better if this test used the real |
| 262 // core library sources, as its purpose is to detect failure to | 262 // core library sources, as its purpose is to detect failure to |
| 263 // optimize fixed-sized arrays. | 263 // optimize fixed-sized arrays. |
| 264 const String DEFAULT_CORELIB_WITH_LIST_INTERFACE = r''' | |
| 265 print(var obj) {} | |
| 266 abstract class num {} | |
| 267 abstract class int extends num { } | |
| 268 abstract class double extends num { } | |
| 269 class bool {} | |
| 270 class String {} | |
| 271 class Object { | |
| 272 Object(); | |
| 273 } | |
| 274 class Type {} | |
| 275 class Function {} | |
| 276 class List { | |
| 277 List([int length]); | |
| 278 } | |
| 279 abstract class Map {} | |
| 280 class Closure {} | |
| 281 class Null {} | |
| 282 class Dynamic_ {} | |
| 283 class StackTrace {} | |
| 284 bool identical(Object a, Object b) {} | |
| 285 const proxy = 0;'''; | |
| 286 | |
| 287 const String INTERCEPTORSLIB_WITH_MEMBERS = r''' | |
| 288 class Interceptor { | |
| 289 toString() {} | |
| 290 bool operator==(other) => identical(this, other); | |
| 291 noSuchMethod(im) { throw im; } | |
| 292 } | |
| 293 abstract class JSIndexable { | |
| 294 get length; | |
| 295 } | |
| 296 abstract class JSMutableIndexable extends JSIndexable {} | |
| 297 class JSArray implements JSIndexable { | |
| 298 JSArray() {} | |
| 299 JSArray.typed(a) => a; | |
| 300 var length; | |
| 301 var removeLast; | |
| 302 operator[] (_) {} | |
| 303 } | |
| 304 class JSMutableArray extends JSArray implements JSMutableIndexable {} | |
| 305 class JSFixedArray extends JSMutableArray {} | |
| 306 class JSExtendableArray extends JSMutableArray {} | |
| 307 class JSString implements JSIndexable { | |
| 308 var length; | |
| 309 } | |
| 310 class JSNumber { | |
| 311 operator +(other) {} | |
| 312 operator -(other) {} | |
| 313 operator ~/(other) {} | |
| 314 operator /(other) {} | |
| 315 operator *(other) {} | |
| 316 operator <<(other) {} | |
| 317 operator >>(other) {} | |
| 318 operator |(other) {} | |
| 319 operator &(other) {} | |
| 320 operator ^(other) {} | |
| 321 operator <(other) {} | |
| 322 operator >(other) {} | |
| 323 operator <=(other) {} | |
| 324 operator >=(other) {} | |
| 325 operator ==(other) {} | |
| 326 } | |
| 327 class JSInt extends JSNumber { | |
| 328 operator~() => this; | |
| 329 } | |
| 330 class JSDouble extends JSNumber { | |
| 331 } | |
| 332 class JSNull { | |
| 333 bool operator==(other) => identical(null, other); | |
| 334 get hashCode => throw "JSNull.hashCode not implemented."; | |
| 335 String toString() => 'Null'; | |
| 336 Type get runtimeType => Null; | |
| 337 noSuchMethod(x) => super.noSuchMethod(x); | |
| 338 } | |
| 339 class JSBool { | |
| 340 } | |
| 341 class JSFunction { | |
| 342 } | |
| 343 class ObjectInterceptor { | |
| 344 } | |
| 345 class JSPositiveInt extends JSInt {} | |
| 346 class JSUInt32 extends JSPositiveInt {} | |
| 347 class JSUInt31 extends JSUInt32 {} | |
| 348 getInterceptor(x) {}'''; | |
| 349 | |
| 350 Future expect(String code, int kind) { | 264 Future expect(String code, int kind) { |
| 351 return compile( | 265 return compile( |
| 352 code, | 266 code, |
| 353 coreSource: DEFAULT_CORELIB_WITH_LIST_INTERFACE, | |
| 354 interceptorsSource: INTERCEPTORSLIB_WITH_MEMBERS, | |
| 355 check: (String generated) { | 267 check: (String generated) { |
| 356 switch (kind) { | 268 switch (kind) { |
| 357 case REMOVED: | 269 case REMOVED: |
| 358 Expect.isTrue(!generated.contains('ioore')); | 270 Expect.isTrue(!generated.contains('ioore')); |
| 359 break; | 271 break; |
| 360 | 272 |
| 361 case ABOVE_ZERO: | 273 case ABOVE_ZERO: |
| 362 Expect.isTrue(!generated.contains('< 0')); | 274 Expect.isTrue(!generated.contains('< 0')); |
| 363 Expect.isTrue(generated.contains('ioore')); | 275 Expect.isTrue(generated.contains('ioore')); |
| 364 break; | 276 break; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 int i = 0; | 310 int i = 0; |
| 399 Future testNext() { | 311 Future testNext() { |
| 400 return expect(TESTS[i], TESTS[i + 1]).then((_) { | 312 return expect(TESTS[i], TESTS[i + 1]).then((_) { |
| 401 i += 2; | 313 i += 2; |
| 402 if (i < TESTS.length) return testNext(); | 314 if (i < TESTS.length) return testNext(); |
| 403 }); | 315 }); |
| 404 } | 316 } |
| 405 | 317 |
| 406 asyncTest(() => testNext()); | 318 asyncTest(() => testNext()); |
| 407 } | 319 } |
| OLD | NEW |