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

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

Issue 17759007: First pass at asynchronous input loading in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 7 years, 3 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
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 "package:async_helper/async_helper.dart";
6 import 7 import
7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' 8 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'
8 show TypeMask; 9 show TypeMask;
9 10
10 import 'compiler_helper.dart'; 11 import 'compiler_helper.dart';
11 import 'parser_helper.dart'; 12 import 'parser_helper.dart';
12 13
13 const String TEST = """ 14 const String TEST = """
14 returnNum1(a) { 15 returnNum1(a) {
15 if (a) return 1; 16 if (a) return 1;
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 testCascade2(); 591 testCascade2();
591 testSpecialization1(); 592 testSpecialization1();
592 testSpecialization2(); 593 testSpecialization2();
593 testSpecialization3(); 594 testSpecialization3();
594 } 595 }
595 """; 596 """;
596 597
597 void main() { 598 void main() {
598 Uri uri = new Uri(scheme: 'source'); 599 Uri uri = new Uri(scheme: 'source');
599 var compiler = compilerFor(TEST, uri); 600 var compiler = compilerFor(TEST, uri);
600 compiler.runCompiler(uri); 601 asyncTest(() => compiler.runCompiler(uri).then((_) {
601 var typesTask = compiler.typesTask; 602 var typesTask = compiler.typesTask;
602 var typesInferrer = typesTask.typesInferrer; 603 var typesInferrer = typesTask.typesInferrer;
603 604
604 checkReturn(String name, type) { 605 checkReturn(String name, type) {
605 var element = findElement(compiler, name); 606 var element = findElement(compiler, name);
606 Expect.equals( 607 Expect.equals(
607 type, 608 type,
608 typesInferrer.getReturnTypeOfElement(element).simplify(compiler), 609 typesInferrer.getReturnTypeOfElement(element).simplify(compiler),
609 name); 610 name);
610 } 611 }
611 var interceptorType = 612 var interceptorType =
612 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); 613 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass');
613 614
614 checkReturn('returnNum1', typesTask.numType); 615 checkReturn('returnNum1', typesTask.numType);
615 checkReturn('returnNum2', typesTask.numType); 616 checkReturn('returnNum2', typesTask.numType);
616 checkReturn('returnInt1', typesTask.intType); 617 checkReturn('returnInt1', typesTask.intType);
617 checkReturn('returnInt2', typesTask.intType); 618 checkReturn('returnInt2', typesTask.intType);
618 checkReturn('returnDouble', typesTask.doubleType); 619 checkReturn('returnDouble', typesTask.doubleType);
619 checkReturn('returnGiveUp', interceptorType); 620 checkReturn('returnGiveUp', interceptorType);
620 checkReturn('returnInt5', typesTask.intType); 621 checkReturn('returnInt5', typesTask.intType);
621 checkReturn('returnInt6', typesTask.intType); 622 checkReturn('returnInt6', typesTask.intType);
622 checkReturn('returnIntOrNull', typesTask.intType.nullable()); 623 checkReturn('returnIntOrNull', typesTask.intType.nullable());
623 checkReturn('returnInt3', typesTask.intType); 624 checkReturn('returnInt3', typesTask.intType);
624 checkReturn('returnDynamic', typesTask.dynamicType); 625 checkReturn('returnDynamic', typesTask.dynamicType);
625 checkReturn('returnInt4', typesTask.intType); 626 checkReturn('returnInt4', typesTask.intType);
626 checkReturn('returnInt7', typesTask.intType); 627 checkReturn('returnInt7', typesTask.intType);
627 checkReturn('returnInt8', typesTask.intType); 628 checkReturn('returnInt8', typesTask.intType);
628 checkReturn('returnDynamic1', typesTask.dynamicType); 629 checkReturn('returnDynamic1', typesTask.dynamicType);
629 checkReturn('returnDynamic2', typesTask.dynamicType); 630 checkReturn('returnDynamic2', typesTask.dynamicType);
630 TypeMask intType = new TypeMask.nonNullSubtype(compiler.intClass.rawType); 631 TypeMask intType = new TypeMask.nonNullSubtype(compiler.intClass.rawType);
631 checkReturn('testIsCheck1', intType); 632 checkReturn('testIsCheck1', intType);
632 checkReturn('testIsCheck2', intType); 633 checkReturn('testIsCheck2', intType);
633 checkReturn('testIsCheck3', intType.nullable()); 634 checkReturn('testIsCheck3', intType.nullable());
634 checkReturn('testIsCheck4', intType); 635 checkReturn('testIsCheck4', intType);
635 checkReturn('testIsCheck5', intType); 636 checkReturn('testIsCheck5', intType);
636 checkReturn('testIsCheck6', typesTask.dynamicType); 637 checkReturn('testIsCheck6', typesTask.dynamicType);
637 checkReturn('testIsCheck7', intType); 638 checkReturn('testIsCheck7', intType);
638 checkReturn('testIsCheck8', typesTask.dynamicType); 639 checkReturn('testIsCheck8', typesTask.dynamicType);
639 checkReturn('testIsCheck9', intType); 640 checkReturn('testIsCheck9', intType);
640 checkReturn('testIsCheck10', typesTask.dynamicType); 641 checkReturn('testIsCheck10', typesTask.dynamicType);
641 checkReturn('testIsCheck11', intType); 642 checkReturn('testIsCheck11', intType);
642 checkReturn('testIsCheck12', typesTask.dynamicType); 643 checkReturn('testIsCheck12', typesTask.dynamicType);
643 checkReturn('testIsCheck13', intType); 644 checkReturn('testIsCheck13', intType);
644 checkReturn('testIsCheck14', typesTask.dynamicType); 645 checkReturn('testIsCheck14', typesTask.dynamicType);
645 checkReturn('testIsCheck15', intType); 646 checkReturn('testIsCheck15', intType);
646 checkReturn('testIsCheck16', typesTask.dynamicType); 647 checkReturn('testIsCheck16', typesTask.dynamicType);
647 checkReturn('testIsCheck17', intType); 648 checkReturn('testIsCheck17', intType);
648 checkReturn('testIsCheck18', typesTask.dynamicType); 649 checkReturn('testIsCheck18', typesTask.dynamicType);
649 checkReturn('testIsCheck19', typesTask.dynamicType); 650 checkReturn('testIsCheck19', typesTask.dynamicType);
650 checkReturn('testIsCheck20', typesTask.dynamicType.nonNullable()); 651 checkReturn('testIsCheck20', typesTask.dynamicType.nonNullable());
651 checkReturn('testIf1', typesTask.intType.nullable()); 652 checkReturn('testIf1', typesTask.intType.nullable());
652 checkReturn('testIf2', typesTask.intType.nullable()); 653 checkReturn('testIf2', typesTask.intType.nullable());
653 checkReturn('returnAsString', 654 checkReturn('returnAsString',
654 new TypeMask.subtype(compiler.stringClass.computeType(compiler))); 655 new TypeMask.subtype(compiler.stringClass.computeType(compiler)));
655 checkReturn('returnIntAsNum', typesTask.intType); 656 checkReturn('returnIntAsNum', typesTask.intType);
656 checkReturn('returnAsTypedef', typesTask.functionType.nullable()); 657 checkReturn('returnAsTypedef', typesTask.functionType.nullable());
657 checkReturn('returnTopLevelGetter', typesTask.intType); 658 checkReturn('returnTopLevelGetter', typesTask.intType);
658 checkReturn('testDeadCode', typesTask.intType); 659 checkReturn('testDeadCode', typesTask.intType);
659 checkReturn('testLabeledIf', typesTask.intType.nullable()); 660 checkReturn('testLabeledIf', typesTask.intType.nullable());
660 checkReturn('testSwitch1', typesTask.intType 661 checkReturn('testSwitch1', typesTask.intType
661 .union(typesTask.doubleType, compiler).nullable().simplify(compiler)); 662 .union(typesTask.doubleType, compiler)
662 checkReturn('testSwitch2', typesTask.intType); 663 .nullable().simplify(compiler));
663 checkReturn('testSwitch3', interceptorType.nullable()); 664 checkReturn('testSwitch2', typesTask.intType);
664 checkReturn('testSwitch4', typesTask.intType); 665 checkReturn('testSwitch3', interceptorType.nullable());
665 checkReturn('testSwitch5', typesTask.intType); 666 checkReturn('testSwitch4', typesTask.intType);
666 checkReturn('testContinue1', interceptorType.nullable()); 667 checkReturn('testSwitch5', typesTask.intType);
667 checkReturn('testBreak1', interceptorType.nullable()); 668 checkReturn('testContinue1', interceptorType.nullable());
668 checkReturn('testContinue2', interceptorType.nullable()); 669 checkReturn('testBreak1', interceptorType.nullable());
669 checkReturn('testBreak2', typesTask.intType.nullable()); 670 checkReturn('testContinue2', interceptorType.nullable());
670 checkReturn('testReturnElementOfConstList1', typesTask.intType); 671 checkReturn('testBreak2', typesTask.intType.nullable());
671 checkReturn('testReturnElementOfConstList2', typesTask.intType); 672 checkReturn('testReturnElementOfConstList1', typesTask.intType);
672 checkReturn('testReturnItselfOrInt', typesTask.intType); 673 checkReturn('testReturnElementOfConstList2', typesTask.intType);
673 checkReturn('testReturnInvokeDynamicGetter', typesTask.dynamicType); 674 checkReturn('testReturnItselfOrInt', typesTask.intType);
675 checkReturn('testReturnInvokeDynamicGetter', typesTask.dynamicType);
674 676
675 checkReturn('testDoWhile1', typesTask.stringType); 677 checkReturn('testDoWhile1', typesTask.stringType);
676 checkReturn('testDoWhile2', typesTask.nullType); 678 checkReturn('testDoWhile2', typesTask.nullType);
677 checkReturn('testDoWhile3', interceptorType); 679 checkReturn('testDoWhile3', interceptorType);
678 checkReturn('testDoWhile4', typesTask.numType); 680 checkReturn('testDoWhile4', typesTask.numType);
679 681
680 checkReturnInClass(String className, String methodName, type) { 682 checkReturnInClass(String className, String methodName, type) {
681 var cls = findElement(compiler, className); 683 var cls = findElement(compiler, className);
682 var element = cls.lookupLocalMember(buildSourceString(methodName)); 684 var element = cls.lookupLocalMember(buildSourceString(methodName));
683 Expect.equals(type, 685 Expect.equals(type,
684 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); 686 typesInferrer.getReturnTypeOfElement(element).simplify(compiler));
685 } 687 }
686 688
687 checkReturnInClass('A', 'returnInt1', typesTask.intType); 689 checkReturnInClass('A', 'returnInt1', typesTask.intType);
688 checkReturnInClass('A', 'returnInt2', typesTask.intType); 690 checkReturnInClass('A', 'returnInt2', typesTask.intType);
689 checkReturnInClass('A', 'returnInt3', typesTask.intType); 691 checkReturnInClass('A', 'returnInt3', typesTask.intType);
690 checkReturnInClass('A', 'returnInt4', typesTask.intType); 692 checkReturnInClass('A', 'returnInt4', typesTask.intType);
691 checkReturnInClass('A', 'returnInt5', typesTask.intType); 693 checkReturnInClass('A', 'returnInt5', typesTask.intType);
692 checkReturnInClass('A', 'returnInt6', typesTask.intType); 694 checkReturnInClass('A', 'returnInt6', typesTask.intType);
693 checkReturnInClass('A', '==', interceptorType); 695 checkReturnInClass('A', '==', interceptorType);
694 696
695 checkReturnInClass('B', 'returnInt1', typesTask.intType); 697 checkReturnInClass('B', 'returnInt1', typesTask.intType);
696 checkReturnInClass('B', 'returnInt2', typesTask.intType); 698 checkReturnInClass('B', 'returnInt2', typesTask.intType);
697 checkReturnInClass('B', 'returnInt3', typesTask.intType); 699 checkReturnInClass('B', 'returnInt3', typesTask.intType);
698 checkReturnInClass('B', 'returnInt4', typesTask.intType); 700 checkReturnInClass('B', 'returnInt4', typesTask.intType);
699 checkReturnInClass('B', 'returnInt5', typesTask.intType); 701 checkReturnInClass('B', 'returnInt5', typesTask.intType);
700 checkReturnInClass('B', 'returnInt6', typesTask.intType); 702 checkReturnInClass('B', 'returnInt6', typesTask.intType);
701 checkReturnInClass('B', 'returnInt7', typesTask.intType); 703 checkReturnInClass('B', 'returnInt7', typesTask.intType);
702 checkReturnInClass('B', 'returnInt8', typesTask.intType); 704 checkReturnInClass('B', 'returnInt8', typesTask.intType);
703 checkReturnInClass('B', 'returnInt9', typesTask.intType); 705 checkReturnInClass('B', 'returnInt9', typesTask.intType);
704 706
705 checkFactoryConstructor(String className, String factoryName) { 707 checkFactoryConstructor(String className, String factoryName) {
706 var cls = findElement(compiler, className); 708 var cls = findElement(compiler, className);
707 var element = cls.localLookup(buildSourceString(factoryName)); 709 var element = cls.localLookup(buildSourceString(factoryName));
708 Expect.equals(new TypeMask.nonNullExact(cls.rawType), 710 Expect.equals(new TypeMask.nonNullExact(cls.rawType),
709 typesInferrer.getReturnTypeOfElement(element)); 711 typesInferrer.getReturnTypeOfElement(element));
710 } 712 }
711 checkFactoryConstructor('A', ''); 713 checkFactoryConstructor('A', '');
712 714
713 checkReturn('testCascade1', typesTask.growableListType); 715 checkReturn('testCascade1', typesTask.growableListType);
714 checkReturn('testCascade2', new TypeMask.nonNullExact( 716 checkReturn('testCascade2', new TypeMask.nonNullExact(
715 typesTask.rawTypeOf(findElement(compiler, 'CascadeHelper')))); 717 typesTask.rawTypeOf(findElement(compiler, 'CascadeHelper'))));
716 checkReturn('testSpecialization1', typesTask.numType); 718 checkReturn('testSpecialization1', typesTask.numType);
717 checkReturn('testSpecialization2', typesTask.dynamicType); 719 checkReturn('testSpecialization2', typesTask.dynamicType);
718 checkReturn('testSpecialization3', typesTask.intType.nullable()); 720 checkReturn('testSpecialization3', typesTask.intType.nullable());
721 }));
719 } 722 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/simple_inferrer_relations_test.dart ('k') | tests/compiler/dart2js/simple_inferrer_try_catch_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698