@@ -31,10 +31,6 @@ void expectInstances(dynamic value, dynamic expected, Compiler compiler) {
31
31
32
32
final Equality <Object ?> equality;
33
33
if (compiler == Compiler .dart2js) {
34
- // Ignore comparing nonConstantLocations in web dills because it will have
35
- // extra fields.
36
- (value as Map <String , Object ?>).remove ('nonConstantLocations' );
37
- (expected as Map <String , Object ?>).remove ('nonConstantLocations' );
38
34
equality = const Dart2JSDeepCollectionEquality ();
39
35
} else {
40
36
equality = const DeepCollectionEquality ();
@@ -69,9 +65,7 @@ void _checkConsts(String dillPath, Compiler compiler) {
69
65
classLibraryUri: 'package:const_finder_fixtures/target.dart' ,
70
66
className: 'Target' ,
71
67
);
72
- expectInstances (
73
- finder.findInstances (),
74
- < String , dynamic > {
68
+ final Map <String , Object ?> expectation = < String , dynamic > {
75
69
'constantInstances' : < Map <String , dynamic >> [
76
70
< String , dynamic > {'stringValue' : '100' , 'intValue' : 100 , 'targetValue' : null },
77
71
< String , dynamic > {'stringValue' : '102' , 'intValue' : 102 , 'targetValue' : null },
@@ -95,7 +89,27 @@ void _checkConsts(String dillPath, Compiler compiler) {
95
89
< String , dynamic > {'stringValue' : 'package' , 'intValue' : - 1 , 'targetValue' : null },
96
90
],
97
91
'nonConstantLocations' : < dynamic > [],
98
- },
92
+ };
93
+ if (compiler == Compiler .aot) {
94
+ expectation['nonConstantLocations' ] = < Object ? > [];
95
+ } else {
96
+ // Without true tree-shaking, there is a non-const reference in a
97
+ // never-invoked function that will be present in the dill.
98
+ final String fixturesUrl = Platform .isWindows
99
+ ? '/$fixtures ' .replaceAll (Platform .pathSeparator, '/' )
100
+ : fixtures;
101
+
102
+ expectation['nonConstantLocations' ] = < Object ? > [
103
+ < String , dynamic > {
104
+ 'file' : 'file://$fixturesUrl /pkg/package.dart' ,
105
+ 'line' : 14 ,
106
+ 'column' : 25 ,
107
+ },
108
+ ];
109
+ }
110
+ expectInstances (
111
+ finder.findInstances (),
112
+ expectation,
99
113
compiler,
100
114
);
101
115
@@ -212,6 +226,9 @@ void _checkNonConstsWeb(String dillPath, Compiler compiler) {
212
226
className: 'Target' ,
213
227
);
214
228
229
+ final String fixturesUrl = Platform .isWindows
230
+ ? '/$fixtures ' .replaceAll (Platform .pathSeparator, '/' )
231
+ : fixtures;
215
232
expectInstances (
216
233
finder.findInstances (),
217
234
< String , dynamic > {
@@ -225,7 +242,33 @@ void _checkNonConstsWeb(String dillPath, Compiler compiler) {
225
242
< String , dynamic > {'stringValue' : '7' , 'intValue' : 7 , 'targetValue' : null },
226
243
< String , dynamic > {'stringValue' : 'package' , 'intValue' : - 1 , 'targetValue' : null },
227
244
],
228
- 'nonConstantLocations' : < dynamic > []
245
+ 'nonConstantLocations' : < dynamic > [
246
+ < String , dynamic > {
247
+ 'file' : 'file://$fixturesUrl /lib/consts_and_non.dart' ,
248
+ 'line' : 14 ,
249
+ 'column' : 26 ,
250
+ },
251
+ < String , dynamic > {
252
+ 'file' : 'file://$fixturesUrl /lib/consts_and_non.dart' ,
253
+ 'line' : 16 ,
254
+ 'column' : 26 ,
255
+ },
256
+ < String , dynamic > {
257
+ 'file' : 'file://$fixturesUrl /lib/consts_and_non.dart' ,
258
+ 'line' : 16 ,
259
+ 'column' : 41 ,
260
+ },
261
+ < String , dynamic > {
262
+ 'file' : 'file://$fixturesUrl /lib/consts_and_non.dart' ,
263
+ 'line' : 17 ,
264
+ 'column' : 26 ,
265
+ },
266
+ < String , dynamic > {
267
+ 'file' : 'file://$fixturesUrl /pkg/package.dart' ,
268
+ 'line' : 14 ,
269
+ 'column' : 25 ,
270
+ }
271
+ ],
229
272
},
230
273
compiler,
231
274
);
0 commit comments