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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 1688233004: Validate that (actual) resynthesized elements have the same runtimeType as originals. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Use actual double.X values. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_ast.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/resynthesize_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_test.dart b/pkg/analyzer/test/src/summary/resynthesize_test.dart
index 702107052ea93ff18fd952ca4a44cd4a50942d53..0b5b193a3fd908992233d81ea3a96557ae1ef9af 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -373,7 +373,14 @@ class ResynthTest extends ResolverTestCase {
} else if (o is IntegerLiteral && r is IntegerLiteral) {
expect(r.value, o.value, reason: desc);
} else if (o is DoubleLiteral && r is DoubleLiteral) {
- expect(r.value, o.value, reason: desc);
+ if (r.value != null &&
+ r.value.isNaN &&
+ o.value != null &&
+ o.value.isNaN) {
+ // NaN is not comparable.
+ } else {
+ expect(r.value, o.value, reason: desc);
+ }
} else if (o is StringInterpolation && r is StringInterpolation) {
compareConstAstLists(r.elements, o.elements, desc);
} else if (o is StringLiteral && r is StringLiteral) {
@@ -502,6 +509,9 @@ class ResynthTest extends ResolverTestCase {
}
void compareElements(Element resynthesized, Element original, String desc) {
+ ElementImpl rImpl = getActualElement(resynthesized, desc);
+ ElementImpl oImpl = getActualElement(original, desc);
+ expect(rImpl.runtimeType, oImpl.runtimeType);
expect(resynthesized, isNotNull);
expect(resynthesized.kind, original.kind);
expect(resynthesized.location, original.location, reason: desc);
@@ -513,20 +523,17 @@ class ResynthTest extends ResolverTestCase {
compareMetadata(resynthesized.metadata, original.metadata, desc);
// Modifiers are a pain to test via handles. So just test them via the
// actual element.
- ElementImpl actualResynthesized = getActualElement(resynthesized, desc);
- ElementImpl actualOriginal = getActualElement(original, desc);
for (Modifier modifier in Modifier.values) {
- bool got = actualResynthesized.hasModifier(modifier);
- bool want = actualOriginal.hasModifier(modifier);
+ bool got = rImpl.hasModifier(modifier);
+ bool want = oImpl.hasModifier(modifier);
expect(got, want,
reason: 'Mismatch in $desc.$modifier: got $got, want $want');
}
// Validate members.
- if (actualOriginal is Member) {
- expect(actualResynthesized, new isInstanceOf<Member>(), reason: desc);
+ if (oImpl is Member) {
+ expect(rImpl, new isInstanceOf<Member>(), reason: desc);
} else {
- expect(actualResynthesized, isNot(new isInstanceOf<Member>()),
- reason: desc);
+ expect(rImpl, isNot(new isInstanceOf<Member>()), reason: desc);
}
}
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_ast.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698