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

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

Issue 1431513010: Revert "Normalize type masks to use the least upper instantiated subclass/type." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « tests/compiler/dart2js/patch_test.dart ('k') | tests/compiler/dart2js/type_mask2_test.dart » ('j') | 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) 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:async_helper/async_helper.dart'; 5 import 'package:async_helper/async_helper.dart';
6 import 'package:expect/expect.dart'; 6 import 'package:expect/expect.dart';
7 import 'package:compiler/src/js_backend/backend_helpers.dart'; 7 import 'package:compiler/src/js_backend/backend_helpers.dart';
8 import 'package:compiler/src/js_backend/js_backend.dart'; 8 import 'package:compiler/src/js_backend/js_backend.dart';
9 import 'package:compiler/src/types/types.dart'; 9 import 'package:compiler/src/types/types.dart';
10 import 'package:compiler/src/world.dart'; 10 import 'package:compiler/src/world.dart';
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 typesSeen..add(type1)..add(type2); 69 typesSeen..add(type1)..add(type2);
70 var pair1 = new Pair(type1, type2); 70 var pair1 = new Pair(type1, type2);
71 var pair2 = new Pair(type2, type1); 71 var pair2 = new Pair(type2, type1);
72 if (pairsSeen.contains(pair1)) { 72 if (pairsSeen.contains(pair1)) {
73 Expect.isFalse(true, 'Redundant rule ($type1, $type2, ...)'); 73 Expect.isFalse(true, 'Redundant rule ($type1, $type2, ...)');
74 } 74 }
75 pairsSeen..add(pair1)..add(pair2); 75 pairsSeen..add(pair1)..add(pair2);
76 76
77 var r1 = operate(type1, type2); 77 var r1 = operate(type1, type2);
78 var r2 = operate(type2, type1); 78 var r2 = operate(type2, type1);
79 Expect.equals(result, r1, 79 Expect.equals(result, r1);
80 "Unexpected result of $name($type1,$type2)"); 80 Expect.equals(r1, r2, 'symmetry violation');
81 Expect.equals(r1, r2, 'Symmetry violation of $name($type1,$type2)');
82 } 81 }
83 82
84 void check(type1, type2, predicate) { 83 void check(type1, type2, predicate) {
85 typesSeen..add(type1)..add(type2); 84 typesSeen..add(type1)..add(type2);
86 var pair = new Pair(type1, type2); 85 var pair = new Pair(type1, type2);
87 pairsSeen..add(pair); 86 pairsSeen..add(pair);
88 var result = operate(type1, type2); 87 var result = operate(type1, type2);
89 Expect.isTrue(predicate(result)); 88 Expect.isTrue(predicate(result));
90 } 89 }
91 90
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 724
726 void testRegressions(MockCompiler compiler) { 725 void testRegressions(MockCompiler compiler) {
727 TypeMask nonNullPotentialString = new TypeMask.nonNullSubtype( 726 TypeMask nonNullPotentialString = new TypeMask.nonNullSubtype(
728 patternClass, compiler.world); 727 patternClass, compiler.world);
729 Expect.equals( 728 Expect.equals(
730 potentialString, jsStringOrNull.union( 729 potentialString, jsStringOrNull.union(
731 nonNullPotentialString, compiler.world)); 730 nonNullPotentialString, compiler.world));
732 } 731 }
733 732
734 void main() { 733 void main() {
735 asyncTest(() async { 734 asyncTest(() => MockCompiler.create((MockCompiler compiler) {
736 MockCompiler compiler = new MockCompiler.internal();
737 await compiler.init("""
738 class PatternImpl implements Pattern {}
739 """);
740 JavaScriptBackend backend = compiler.backend; 735 JavaScriptBackend backend = compiler.backend;
741 BackendHelpers helpers = backend.helpers; 736 BackendHelpers helpers = backend.helpers;
742 World world = compiler.world; 737 World world = compiler.world;
743 helpers.interceptorsLibrary.forEachLocalMember((element) { 738 helpers.interceptorsLibrary.forEachLocalMember((element) {
744 if (element.isClass) { 739 if (element.isClass) {
745 element.ensureResolved(compiler.resolution); 740 element.ensureResolved(compiler.resolution);
746 backend.registerInstantiatedType( 741 backend.registerInstantiatedType(
747 element.rawType, 742 element.rawType,
748 compiler.enqueuer.resolution, 743 compiler.enqueuer.resolution,
749 compiler.globalDependencies); 744 compiler.globalDependencies);
750 } 745 }
751 }); 746 });
752 ClassElement patternImplClass = compiler.mainApp.find('PatternImpl');
753 patternImplClass.ensureResolved(compiler.resolution);
754
755 backend.registerInstantiatedType( 747 backend.registerInstantiatedType(
756 compiler.coreTypes.mapType(), 748 compiler.coreTypes.mapType(),
757 compiler.enqueuer.resolution, 749 compiler.enqueuer.resolution,
758 compiler.globalDependencies); 750 compiler.globalDependencies);
759 backend.registerInstantiatedType( 751 backend.registerInstantiatedType(
760 compiler.coreTypes.functionType, 752 compiler.coreTypes.functionType,
761 compiler.enqueuer.resolution, 753 compiler.enqueuer.resolution,
762 compiler.globalDependencies); 754 compiler.globalDependencies);
763 backend.registerInstantiatedType(
764 patternImplClass.rawType,
765 compiler.enqueuer.resolution,
766 compiler.globalDependencies);
767 compiler.world.populate(); 755 compiler.world.populate();
768 756
769 // Grab hold of a supertype for String so we can produce potential 757 // Grab hold of a supertype for String so we can produce potential
770 // string types. 758 // string types.
771 patternClass = compiler.coreLibrary.find('Pattern'); 759 patternClass = compiler.coreLibrary.find('Pattern');
772 760
773 nonPrimitive1 = new TypeMask.nonNullSubtype( 761 nonPrimitive1 = new TypeMask.nonNullSubtype(
774 compiler.coreClasses.mapClass, world); 762 compiler.coreClasses.mapClass, world);
775 nonPrimitive2 = new TypeMask.nonNullSubtype( 763 nonPrimitive2 = new TypeMask.nonNullSubtype(
776 compiler.coreClasses.functionClass, world); 764 compiler.coreClasses.functionClass, world);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 jsNumberOrNull = new TypeMask.subclass(helpers.jsNumberClass, world); 798 jsNumberOrNull = new TypeMask.subclass(helpers.jsNumberClass, world);
811 jsIntegerOrNull = new TypeMask.exact(helpers.jsIntClass, world); 799 jsIntegerOrNull = new TypeMask.exact(helpers.jsIntClass, world);
812 jsDoubleOrNull = new TypeMask.exact(helpers.jsDoubleClass, world); 800 jsDoubleOrNull = new TypeMask.exact(helpers.jsDoubleClass, world);
813 nullType = const TypeMask.empty(); 801 nullType = const TypeMask.empty();
814 objectType = new TypeMask.nonNullSubclass( 802 objectType = new TypeMask.nonNullSubclass(
815 compiler.coreClasses.objectClass, world); 803 compiler.coreClasses.objectClass, world);
816 emptyType = const TypeMask.nonNullEmpty(); 804 emptyType = const TypeMask.nonNullEmpty();
817 dynamicType = new TypeMask.subclass( 805 dynamicType = new TypeMask.subclass(
818 compiler.coreClasses.objectClass, world); 806 compiler.coreClasses.objectClass, world);
819 807
820 Expect.notEquals(emptyType, nonPrimitive1,
821 "nonPrimitive1 expected to be non-empty.");
822 Expect.notEquals(jsStringOrNull, potentialString,
823 "potentialString expected not to be exact JSString");
824 Expect.notEquals(jsArrayOrNull, potentialArray,
825 "potentialArray expected not to be JSArray subclass");
826
827 testUnion(compiler); 808 testUnion(compiler);
828 testIntersection(compiler); 809 testIntersection(compiler);
829 testRegressions(compiler); 810 testRegressions(compiler);
830 }); 811 }));
831 } 812 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/patch_test.dart ('k') | tests/compiler/dart2js/type_mask2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698