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

Side by Side Diff: tests/compiler/dart2js/simple_inferrer_test.dart

Issue 22881003: Implement visitCascade/visitCascadeReceiver in inferrer_visitor.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | « sdk/lib/_internal/compiler/implementation/types/inferrer_visitor.dart ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 6 import
7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' 7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'
8 show TypeMask; 8 show TypeMask;
9 9
10 import 'compiler_helper.dart'; 10 import 'compiler_helper.dart';
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 returnInt2() => new A().myField += 4; 397 returnInt2() => new A().myField += 4;
398 returnInt3() => ++new A()[0]; 398 returnInt3() => ++new A()[0];
399 returnInt4() => new A()[0] += 42; 399 returnInt4() => new A()[0] += 42;
400 returnInt5() => ++super.myField; 400 returnInt5() => ++super.myField;
401 returnInt6() => super.myField += 4; 401 returnInt6() => super.myField += 4;
402 returnInt7() => ++super[0]; 402 returnInt7() => ++super[0];
403 returnInt8() => super[0] += 54; 403 returnInt8() => super[0] += 54;
404 returnInt9() => super.myField; 404 returnInt9() => super.myField;
405 } 405 }
406 406
407 testCascade1() {
408 return [1, 2, 3]..add(4)..add(5);
409 }
410
411 testCascade2() {
412 return new CascadeHelper()
413 ..a = "hello"
414 ..b = 42
415 ..i += 1;
416 }
417
418 class CascadeHelper {
419 var a, b;
420 var i = 0;
421 }
422
407 main() { 423 main() {
408 // Ensure a function class is being instantiated. 424 // Ensure a function class is being instantiated.
409 () => 42; 425 () => 42;
410 returnNum1(true); 426 returnNum1(true);
411 returnNum2(true); 427 returnNum2(true);
412 returnInt1(true); 428 returnInt1(true);
413 returnInt2(true); 429 returnInt2(true);
414 returnInt3(true); 430 returnInt3(true);
415 returnInt4(); 431 returnInt4();
416 returnDouble(true); 432 returnDouble(true);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 ..returnInt4() 487 ..returnInt4()
472 ..returnInt5() 488 ..returnInt5()
473 ..returnInt6() 489 ..returnInt6()
474 ..returnInt7() 490 ..returnInt7()
475 ..returnInt8() 491 ..returnInt8()
476 ..returnInt9(); 492 ..returnInt9();
477 testReturnElementOfConstList1(); 493 testReturnElementOfConstList1();
478 testReturnElementOfConstList2(); 494 testReturnElementOfConstList2();
479 testReturnItselfOrInt(topLevelGetter()); 495 testReturnItselfOrInt(topLevelGetter());
480 testReturnInvokeDynamicGetter(); 496 testReturnInvokeDynamicGetter();
497 testCascade1();
498 testCascade2();
481 } 499 }
482 """; 500 """;
483 501
484 void main() { 502 void main() {
485 Uri uri = new Uri(scheme: 'source'); 503 Uri uri = new Uri(scheme: 'source');
486 var compiler = compilerFor(TEST, uri); 504 var compiler = compilerFor(TEST, uri);
487 compiler.runCompiler(uri); 505 compiler.runCompiler(uri);
488 var typesTask = compiler.typesTask; 506 var typesTask = compiler.typesTask;
489 var typesInferrer = typesTask.typesInferrer; 507 var typesInferrer = typesTask.typesInferrer;
490 508
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 checkReturnInClass('B', 'returnInt8', typesTask.intType); 602 checkReturnInClass('B', 'returnInt8', typesTask.intType);
585 checkReturnInClass('B', 'returnInt9', typesTask.intType); 603 checkReturnInClass('B', 'returnInt9', typesTask.intType);
586 604
587 checkFactoryConstructor(String className, String factoryName) { 605 checkFactoryConstructor(String className, String factoryName) {
588 var cls = findElement(compiler, className); 606 var cls = findElement(compiler, className);
589 var element = cls.localLookup(buildSourceString(factoryName)); 607 var element = cls.localLookup(buildSourceString(factoryName));
590 Expect.equals(new TypeMask.nonNullExact(cls.rawType), 608 Expect.equals(new TypeMask.nonNullExact(cls.rawType),
591 typesInferrer.getReturnTypeOfElement(element)); 609 typesInferrer.getReturnTypeOfElement(element));
592 } 610 }
593 checkFactoryConstructor('A', ''); 611 checkFactoryConstructor('A', '');
612
613 checkReturn('testCascade1', typesTask.growableListType);
614 checkReturn('testCascade2', new TypeMask.nonNullExact(
615 typesTask.rawTypeOf(findElement(compiler, 'CascadeHelper'))));
594 } 616 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/inferrer_visitor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698