@@ -382,7 +382,15 @@ void checkNativeBasicData(NativeBasicDataImpl data1, NativeBasicDataImpl data2,
382
382
data2.nativeClassTagInfo,
383
383
strategy.elementEquivalence,
384
384
(a, b) => a == b);
385
- // TODO(johnniwinther): Check the remaining properties.
385
+ checkSetEquivalence (
386
+ data1,
387
+ data2,
388
+ 'jsInteropLibraries' ,
389
+ data1.jsInteropLibraries,
390
+ data2.jsInteropLibraries,
391
+ strategy.elementEquivalence);
392
+ checkSetEquivalence (data1, data2, 'jsInteropClasses' , data1.jsInteropClasses,
393
+ data2.jsInteropClasses, strategy.elementEquivalence);
386
394
}
387
395
388
396
void checkBackendUsage (
@@ -442,7 +450,8 @@ void checkBackendUsage(
442
450
}
443
451
444
452
checkElementEnvironment (
445
- ElementEnvironment env1, ElementEnvironment env2, TestStrategy strategy) {
453
+ ElementEnvironment env1, ElementEnvironment env2, TestStrategy strategy,
454
+ {bool checkConstructorBodies: false }) {
446
455
strategy.testElements (
447
456
env1, env2, 'mainLibrary' , env1.mainLibrary, env2.mainLibrary);
448
457
strategy.testElements (
@@ -459,6 +468,14 @@ checkElementEnvironment(
459
468
env1.getMemberMetadata (member1),
460
469
env2.getMemberMetadata (member2),
461
470
strategy.testConstantValues);
471
+
472
+ // TODO(johnniwinther): Check function type. Currently hitting problems with
473
+ // return types of generative constructors, function types referring to
474
+ // typedefs and forwarding constructors.
475
+ /*if (member1 is FunctionEntity && member2 is FunctionEntity) {
476
+ check(member1, member2, 'getFunctionType', env1.getFunctionType(member1),
477
+ env2.getFunctionType(member2), strategy.typeEquivalence);
478
+ }*/
462
479
}
463
480
464
481
checkSetEquivalence (env1, env2, 'libraries' , env1.libraries, env2.libraries,
@@ -467,6 +484,8 @@ checkElementEnvironment(
467
484
Expect .identical (lib1, env1.lookupLibrary (lib1.canonicalUri));
468
485
Expect .identical (lib2, env2.lookupLibrary (lib2.canonicalUri));
469
486
487
+ // TODO(johnniwinther): Check libraryName.
488
+
470
489
List <ClassEntity > classes2 = < ClassEntity > [];
471
490
env1.forEachClass (lib1, (ClassEntity cls1) {
472
491
Expect .identical (cls1, env1.lookupClass (lib1, cls1.name));
@@ -496,19 +515,53 @@ checkElementEnvironment(
496
515
env2.getSuperClass (cls2, skipUnnamedMixinApplications: true ),
497
516
strategy.elementEquivalence);
498
517
518
+ InterfaceType thisType1 = env1.getThisType (cls1);
519
+ InterfaceType thisType2 = env2.getThisType (cls2);
520
+ check (cls1, cls2, 'thisType' , thisType1, thisType2,
521
+ strategy.typeEquivalence);
522
+ check (cls1, cls2, 'rawType' , env1.getRawType (cls1), env2.getRawType (cls2),
523
+ strategy.typeEquivalence);
524
+ check (
525
+ cls1,
526
+ cls2,
527
+ 'createInterfaceType' ,
528
+ env1.createInterfaceType (cls1, thisType1.typeArguments),
529
+ env2.createInterfaceType (cls2, thisType2.typeArguments),
530
+ strategy.typeEquivalence);
531
+
532
+ check (cls1, cls2, 'isGenericClass' , env1.isGenericClass (cls1),
533
+ env2.isGenericClass (cls2));
534
+ check (cls1, cls2, 'isMixinApplication' , env1.isMixinApplication (cls1),
535
+ env2.isMixinApplication (cls2));
536
+ check (
537
+ cls1,
538
+ cls2,
539
+ 'isUnnamedMixinApplication' ,
540
+ env1.isUnnamedMixinApplication (cls1),
541
+ env2.isUnnamedMixinApplication (cls2));
542
+ check (
543
+ cls1,
544
+ cls2,
545
+ 'getEffectiveMixinClass' ,
546
+ env1.getEffectiveMixinClass (cls1),
547
+ env2.getEffectiveMixinClass (cls2),
548
+ strategy.elementEquivalence);
549
+
550
+ // TODO(johnniwinther): Check type variable bounds.
551
+
499
552
List <InterfaceType > supertypes1 = < InterfaceType > [];
500
553
env1.forEachSupertype (cls1, supertypes1.add);
501
554
List <InterfaceType > supertypes2 = < InterfaceType > [];
502
- env2.forEachSupertype (cls2, supertypes1 .add);
503
- strategy. testTypeLists (
504
- cls1, cls2, 'supertypes' , supertypes1, supertypes2 );
555
+ env2.forEachSupertype (cls2, supertypes2 .add);
556
+ checkLists (supertypes1, supertypes2, 'supertypes on $ cls1 , $ cls2 ' ,
557
+ strategy.typeEquivalence );
505
558
506
559
List <ClassEntity > mixins1 = < ClassEntity > [];
507
560
env1.forEachMixin (cls1, mixins1.add);
508
561
List <ClassEntity > mixins2 = < ClassEntity > [];
509
562
env2.forEachMixin (cls2, mixins2.add);
510
- strategy. testLists (
511
- cls1, cls2, 'mixins' , mixins1, mixins2, strategy.elementEquivalence);
563
+ checkLists (mixins1, mixins2, 'mixins on $ cls1 , $ cls2 ' ,
564
+ strategy.elementEquivalence);
512
565
513
566
Map <MemberEntity , ClassEntity > members1 = < MemberEntity , ClassEntity > {};
514
567
Map <MemberEntity , ClassEntity > members2 = < MemberEntity , ClassEntity > {};
@@ -563,6 +616,29 @@ checkElementEnvironment(
563
616
"Extra constructor $constructor2 in $cls2 " );
564
617
});
565
618
619
+ if (checkConstructorBodies) {
620
+ Set <ConstructorBodyEntity > constructorBodies1 =
621
+ new Set <ConstructorBodyEntity >();
622
+ Set <ConstructorBodyEntity > constructorBodies2 =
623
+ new Set <ConstructorBodyEntity >();
624
+ env1.forEachConstructorBody (cls1,
625
+ (ConstructorBodyEntity constructorBody1) {
626
+ constructorBodies1.add (constructorBody1);
627
+ });
628
+ env2.forEachConstructorBody (cls2,
629
+ (ConstructorBodyEntity constructorBody2) {
630
+ constructorBodies2.add (constructorBody2);
631
+ });
632
+ checkSetEquivalence (cls1, cls2, 'constructor-bodies' ,
633
+ constructorBodies1, constructorBodies2, strategy.elementEquivalence,
634
+ onSameElement: (ConstructorBodyEntity constructorBody1,
635
+ ConstructorBodyEntity constructorBody2) {
636
+ check (constructorBody1, constructorBody2, 'name' ,
637
+ constructorBody1.name, constructorBody2.name);
638
+
639
+ checkMembers (constructorBody1, constructorBody2);
640
+ });
641
+ }
566
642
classes2.add (cls2);
567
643
});
568
644
env2.forEachClass (lib2, (ClassEntity cls2) {
@@ -597,7 +673,7 @@ checkElementEnvironment(
597
673
members2.contains (member2), "Extra member $member2 in $lib2 " );
598
674
});
599
675
});
600
- // TODO(johnniwinther): Test the remaining properties of [ElementEnvironment].
676
+ // TODO(johnniwinther): Check getLocalFunctionType and getUnaliasedType ?
601
677
}
602
678
603
679
bool areInstantiationInfosEquivalent (
@@ -894,6 +970,8 @@ void checkEmitterFragments(
894
970
if (fragment1 is MainFragment && fragment2 is MainFragment ) {
895
971
check (fragment1, fragment2, 'invokeMain' , fragment1.invokeMain,
896
972
fragment2.invokeMain, areJsNodesEquivalent);
973
+ } else if (fragment1 is DeferredFragment && fragment2 is DeferredFragment ) {
974
+ check (fragment1, fragment2, 'name' , fragment1.name, fragment2.name);
897
975
}
898
976
}
899
977
@@ -909,7 +987,7 @@ void checkEmitterLibraries(
909
987
checkLists (
910
988
library1.staticFieldsForReflection,
911
989
library2.staticFieldsForReflection,
912
- 'staticFieldsForReflection' ,
990
+ 'staticFieldsForReflection on $ library1 /$ library2 ' ,
913
991
(a, b) => a.name.key == b.name.key,
914
992
onSameElement: checkEmitterFields);
915
993
}
@@ -933,8 +1011,11 @@ void checkEmitterClasses(Class class1, Class class2, TestStrategy strategy) {
933
1011
checkLists (class1.noSuchMethodStubs, class2.noSuchMethodStubs,
934
1012
'noSuchMethodStubs' , (a, b) => a.name.key == b.name.key,
935
1013
onSameElement: (a, b) => checkEmitterMethods (a, b, strategy));
936
- checkLists (class1.staticFieldsForReflection, class2.staticFieldsForReflection,
937
- 'staticFieldsForReflection' , (a, b) => a.name.key == b.name.key,
1014
+ checkLists (
1015
+ class1.staticFieldsForReflection,
1016
+ class2.staticFieldsForReflection,
1017
+ 'staticFieldsForReflection on $class1 /$class2 ' ,
1018
+ (a, b) => a.name.key == b.name.key,
938
1019
onSameElement: checkEmitterFields);
939
1020
940
1021
check (class1, class2, 'superclassName' , class1.superclassName? .key,
0 commit comments