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

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

Issue 2320583002: Introduce OpenWorld. (Closed)
Patch Set: Created 4 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
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 '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 'package:compiler/src/compiler.dart'; 8 import 'package:compiler/src/compiler.dart';
9 import 'package:compiler/src/diagnostics/messages.dart' show 9 import 'package:compiler/src/diagnostics/messages.dart' show
10 MessageKind; 10 MessageKind;
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 @patch void clear() {} 937 @patch void clear() {}
938 } 938 }
939 """, 939 """,
940 main: """ 940 main: """
941 main () { 941 main () {
942 new A(); // ensure A and B are instantiated 942 new A(); // ensure A and B are instantiated
943 new B(); 943 new B();
944 } 944 }
945 """, 945 """,
946 runCompiler: true, analyzeOnly: true); 946 runCompiler: true, analyzeOnly: true);
947 World world = compiler.openWorld; 947 ClosedWorld world = compiler.openWorld.populate();
948 world.populate();
949 948
950 ClassElement cls = ensure(compiler, "A", 949 ClassElement cls = ensure(compiler, "A",
951 compiler.commonElements.coreLibrary.find, expectIsPatched: true); 950 compiler.commonElements.coreLibrary.find, expectIsPatched: true);
952 cls.ensureResolved(compiler.resolution); 951 cls.ensureResolved(compiler.resolution);
953 952
954 ensure(compiler, "method", cls.patch.lookupLocalMember, 953 ensure(compiler, "method", cls.patch.lookupLocalMember,
955 checkHasBody: true, expectIsRegular: true); 954 checkHasBody: true, expectIsRegular: true);
956 955
957 ensure(compiler, "clear", cls.lookupLocalMember, 956 ensure(compiler, "clear", cls.lookupLocalMember,
958 checkHasBody: true, expectIsPatched: true); 957 checkHasBody: true, expectIsPatched: true);
959 958
960 compiler.phase = Compiler.PHASE_DONE_RESOLVING; 959 compiler.phase = Compiler.PHASE_DONE_RESOLVING;
961 960
962 // Check that a method just in the patch class is a target for a 961 // Check that a method just in the patch class is a target for a
963 // typed selector. 962 // typed selector.
964 Selector selector = 963 Selector selector =
965 new Selector.call(const PublicName('method'), CallStructure.NO_ARGS); 964 new Selector.call(const PublicName('method'), CallStructure.NO_ARGS);
966 TypeMask typeMask = new TypeMask.exact(cls, world); 965 TypeMask typeMask = new TypeMask.exact(cls, world);
967 FunctionElement method = cls.implementation.lookupLocalMember('method'); 966 FunctionElement method = cls.implementation.lookupLocalMember('method');
968 method.computeType(compiler.resolution); 967 method.computeType(compiler.resolution);
969 Expect.isTrue(selector.applies(method, world)); 968 Expect.isTrue(selector.applies(method, world.backend));
970 Expect.isTrue(typeMask.canHit(method, selector, world)); 969 Expect.isTrue(typeMask.canHit(method, selector, world));
971 970
972 // Check that the declaration method in the declaration class is a target 971 // Check that the declaration method in the declaration class is a target
973 // for a typed selector. 972 // for a typed selector.
974 selector = 973 selector =
975 new Selector.call(const PublicName('clear'), CallStructure.NO_ARGS); 974 new Selector.call(const PublicName('clear'), CallStructure.NO_ARGS);
976 typeMask = new TypeMask.exact(cls, world); 975 typeMask = new TypeMask.exact(cls, world);
977 method = cls.lookupLocalMember('clear'); 976 method = cls.lookupLocalMember('clear');
978 method.computeType(compiler.resolution); 977 method.computeType(compiler.resolution);
979 Expect.isTrue(selector.applies(method, world)); 978 Expect.isTrue(selector.applies(method, world.backend));
980 Expect.isTrue(typeMask.canHit(method, selector, world)); 979 Expect.isTrue(typeMask.canHit(method, selector, world));
981 980
982 // Check that the declaration method in the declaration class is a target 981 // Check that the declaration method in the declaration class is a target
983 // for a typed selector on a subclass. 982 // for a typed selector on a subclass.
984 cls = ensure(compiler, "B", compiler.commonElements.coreLibrary.find); 983 cls = ensure(compiler, "B", compiler.commonElements.coreLibrary.find);
985 cls.ensureResolved(compiler.resolution); 984 cls.ensureResolved(compiler.resolution);
986 typeMask = new TypeMask.exact(cls, world); 985 typeMask = new TypeMask.exact(cls, world);
987 Expect.isTrue(selector.applies(method, world)); 986 Expect.isTrue(selector.applies(method, world.backend));
988 Expect.isTrue(typeMask.canHit(method, selector, world)); 987 Expect.isTrue(typeMask.canHit(method, selector, world));
989 } 988 }
990 989
991 Future testAnalyzeAllInjectedMembers() async { 990 Future testAnalyzeAllInjectedMembers() async {
992 Future expect(String patchText, [expectedWarnings]) async { 991 Future expect(String patchText, [expectedWarnings]) async {
993 if (expectedWarnings == null) expectedWarnings = []; 992 if (expectedWarnings == null) expectedWarnings = [];
994 if (expectedWarnings is! List) { 993 if (expectedWarnings is! List) {
995 expectedWarnings = <MessageKind>[expectedWarnings]; 994 expectedWarnings = <MessageKind>[expectedWarnings];
996 } 995 }
997 996
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 await testPatchNonFunction(); 1137 await testPatchNonFunction();
1139 1138
1140 await testPatchAndSelector(); 1139 await testPatchAndSelector();
1141 1140
1142 await testEffectiveTarget(); 1141 await testEffectiveTarget();
1143 1142
1144 await testAnalyzeAllInjectedMembers(); 1143 await testAnalyzeAllInjectedMembers();
1145 await testTypecheckPatchedMembers(); 1144 await testTypecheckPatchedMembers();
1146 }); 1145 });
1147 } 1146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698