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

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

Issue 52263003: Implement least upper bound. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years 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) 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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:async'; 6 import 'dart:async';
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart"; 10 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart";
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 Expect.equals(expectedElementCount, map(visitor).length); 639 Expect.equals(expectedElementCount, map(visitor).length);
640 640
641 compareWarningKinds(script, expectedWarnings, compiler.warnings); 641 compareWarningKinds(script, expectedWarnings, compiler.warnings);
642 compareWarningKinds(script, expectedErrors, compiler.errors); 642 compareWarningKinds(script, expectedErrors, compiler.errors);
643 compareWarningKinds(script, expectedInfos, compiler.infos); 643 compareWarningKinds(script, expectedInfos, compiler.infos);
644 } 644 }
645 645
646 testClassHierarchy() { 646 testClassHierarchy() {
647 final MAIN = "main"; 647 final MAIN = "main";
648 MockCompiler compiler = new MockCompiler(); 648 MockCompiler compiler = new MockCompiler();
649 compiler.parseScript("""class A extends B {} 649 compiler.parseScript("""class A extends A {}
650 class B extends A {}
651 main() { return new A(); }"""); 650 main() { return new A(); }""");
652 FunctionElement mainElement = compiler.mainApp.find(MAIN); 651 FunctionElement mainElement = compiler.mainApp.find(MAIN);
653 compiler.resolver.resolve(mainElement); 652 compiler.resolver.resolve(mainElement);
654 Expect.equals(0, compiler.warnings.length); 653 Expect.equals(0, compiler.warnings.length);
654 Expect.equals(1, compiler.errors.length);
655 Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY,
656 compiler.errors[0].message.kind);
657
658 compiler = new MockCompiler();
659 compiler.parseScript("""class A extends B {}
660 class B extends A {}
661 main() { return new A(); }""");
662 mainElement = compiler.mainApp.find(MAIN);
663 compiler.resolver.resolve(mainElement);
664 Expect.equals(0, compiler.warnings.length);
655 Expect.equals(2, compiler.errors.length); 665 Expect.equals(2, compiler.errors.length);
656 Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY, 666 Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY,
657 compiler.errors[0].message.kind); 667 compiler.errors[0].message.kind);
658 Expect.equals(MessageKind.CANNOT_FIND_CONSTRUCTOR.error, 668 Expect.equals(MessageKind.CANNOT_FIND_CONSTRUCTOR.error,
659 compiler.errors[1].message.kind); 669 compiler.errors[1].message.kind);
660 670
661 compiler = new MockCompiler(); 671 compiler = new MockCompiler();
662 compiler.parseScript("""abstract class A extends B {} 672 compiler.parseScript("""abstract class A extends B {}
663 abstract class B extends A {} 673 abstract class B extends A {}
664 class C implements A {} 674 class C implements A {}
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 class E extends D {} 717 class E extends D {}
708 main() { return new E(); }"""); 718 main() { return new E(); }""");
709 mainElement = compiler.mainApp.find(MAIN); 719 mainElement = compiler.mainApp.find(MAIN);
710 compiler.resolver.resolve(mainElement); 720 compiler.resolver.resolve(mainElement);
711 Expect.equals(0, compiler.warnings.length); 721 Expect.equals(0, compiler.warnings.length);
712 Expect.equals(0, compiler.errors.length); 722 Expect.equals(0, compiler.errors.length);
713 aElement = compiler.mainApp.find("E"); 723 aElement = compiler.mainApp.find("E");
714 supertypes = aElement.allSupertypes; 724 supertypes = aElement.allSupertypes;
715 Expect.equals(<String>['A<E>', 'D', 'Object'].toString(), 725 Expect.equals(<String>['A<E>', 'D', 'Object'].toString(),
716 asSortedStrings(supertypes).toString()); 726 asSortedStrings(supertypes).toString());
727
728 compiler = new MockCompiler();
729 compiler.parseScript("""class A<T> {}
730 class D extends A<int> implements A<double> {}
731 main() { return new D(); }""");
732 mainElement = compiler.mainApp.find(MAIN);
733 compiler.resolver.resolve(mainElement);
734 Expect.equals(0, compiler.warnings.length);
735 Expect.equals(1, compiler.errors.length);
736 Expect.equals(MessageKind.MULTI_INHERITANCE,
737 compiler.errors[0].message.kind);
717 } 738 }
718 739
719 testInitializers() { 740 testInitializers() {
720 String script; 741 String script;
721 script = """class A { 742 script = """class A {
722 int foo; int bar; 743 int foo; int bar;
723 A() : this.foo = 1, bar = 2; 744 A() : this.foo = 1, bar = 2;
724 }"""; 745 }""";
725 resolveConstructor(script, "A a = new A();", "A", "", 2); 746 resolveConstructor(script, "A a = new A();", "A", "", 2);
726 747
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 }"""; 986 }""";
966 asyncTest(() => compileScript(script2).then((compiler) { 987 asyncTest(() => compileScript(script2).then((compiler) {
967 expect(compiler, 988 expect(compiler,
968 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], 989 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS],
969 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, 990 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
970 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, 991 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
971 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, 992 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD,
972 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); 993 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]);
973 })); 994 }));
974 } 995 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/least_upper_bound_test.dart ('k') | tests/compiler/dart2js/type_promotion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698