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

Side by Side Diff: tests/compiler/dart2js/serialization/test_helper.dart

Issue 2874973003: Add more equivalence tests for ElementEnvironment (Closed)
Patch Set: Created 3 years, 7 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library dart2js.serialization_test_helper; 5 library dart2js.serialization_test_helper;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'package:compiler/src/common/resolution.dart'; 8 import 'package:compiler/src/common/resolution.dart';
9 import 'package:compiler/src/constants/expressions.dart'; 9 import 'package:compiler/src/constants/expressions.dart';
10 import 'package:compiler/src/constants/values.dart'; 10 import 'package:compiler/src/constants/values.dart';
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 /// We need co-inductive reasoning because mixin applications are compared 643 /// We need co-inductive reasoning because mixin applications are compared
644 /// structurally and therefore, in the case of generic mixin applications, 644 /// structurally and therefore, in the case of generic mixin applications,
645 /// meet themselves through the equivalence check of their type variables. 645 /// meet themselves through the equivalence check of their type variables.
646 Set<Pair<ClassEntity, ClassEntity>> assumedMixinApplications = 646 Set<Pair<ClassEntity, ClassEntity>> assumedMixinApplications =
647 new Set<Pair<ClassEntity, ClassEntity>>(); 647 new Set<Pair<ClassEntity, ClassEntity>>();
648 648
649 KernelEquivalence(KernelToElementMapImpl builder) 649 KernelEquivalence(KernelToElementMapImpl builder)
650 : testing = new WorldDeconstructionForTesting(builder); 650 : testing = new WorldDeconstructionForTesting(builder);
651 651
652 TestStrategy get defaultStrategy => new TestStrategy( 652 TestStrategy get defaultStrategy => new TestStrategy(
653 elementEquivalence: entityEquivalence, typeEquivalence: typeEquivalence); 653 elementEquivalence: entityEquivalence,
654 typeEquivalence: typeEquivalence,
655 constantEquivalence: constantEquivalence,
656 constantValueEquivalence: constantValueEquivalence);
654 657
655 bool entityEquivalence(Element a, Entity b, {TestStrategy strategy}) { 658 bool entityEquivalence(Element a, Entity b, {TestStrategy strategy}) {
656 if (identical(a, b)) return true; 659 if (identical(a, b)) return true;
657 if (a == null || b == null) return false; 660 if (a == null || b == null) return false;
658 strategy ??= defaultStrategy; 661 strategy ??= defaultStrategy;
659 switch (a.kind) { 662 switch (a.kind) {
660 case ElementKind.GENERATIVE_CONSTRUCTOR: 663 case ElementKind.GENERATIVE_CONSTRUCTOR:
661 if (b is KGenerativeConstructor) { 664 if (b is KGenerativeConstructor) {
662 return strategy.test(a, b, 'name', a.name, b.name) && 665 return strategy.test(a, b, 'name', a.name, b.name) &&
663 strategy.testElements( 666 strategy.testElements(
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 b.namedParameters) && 812 b.namedParameters) &&
810 strategy.testTypeLists(a, b, 'namedParameterTypes', 813 strategy.testTypeLists(a, b, 'namedParameterTypes',
811 aType.namedParameterTypes, b.namedParameterTypes); 814 aType.namedParameterTypes, b.namedParameterTypes);
812 } 815 }
813 return false; 816 return false;
814 default: 817 default:
815 throw new UnsupportedError('Unsupported equivalence: ' 818 throw new UnsupportedError('Unsupported equivalence: '
816 '$a (${a.runtimeType}) vs $b (${b.runtimeType})'); 819 '$a (${a.runtimeType}) vs $b (${b.runtimeType})');
817 } 820 }
818 } 821 }
822
823 bool constantEquivalence(ConstantExpression exp1, ConstantExpression exp2,
824 {TestStrategy strategy}) {
825 strategy ??= defaultStrategy;
826 return areConstantsEquivalent(exp1, exp2, strategy: strategy);
827 }
828
829 bool constantValueEquivalence(ConstantValue value1, ConstantValue value2,
830 {TestStrategy strategy}) {
831 strategy ??= defaultStrategy;
832 return areConstantValuesEquivalent(value1, value2, strategy: strategy);
833 }
819 } 834 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698