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

Side by Side Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1674073002: Add UnlinkedConst.isValid and set it during summarizing. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Generate the 'isInvalid' property. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 analyzer.test.src.summary.summary_common; 5 library analyzer.test.src.summary.summary_common;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 4018 matching lines...) Expand 10 before | Expand all | Expand 10 after
4029 } 4029 }
4030 4030
4031 test_field_final() { 4031 test_field_final() {
4032 UnlinkedVariable variable = 4032 UnlinkedVariable variable =
4033 serializeClassText('class C { final int i = 0; }').fields[0]; 4033 serializeClassText('class C { final int i = 0; }').fields[0];
4034 expect(variable.isFinal, isTrue); 4034 expect(variable.isFinal, isTrue);
4035 _assertUnlinkedConst(variable.constExpr, 4035 _assertUnlinkedConst(variable.constExpr,
4036 operators: [UnlinkedConstOperation.pushInt], ints: [0]); 4036 operators: [UnlinkedConstOperation.pushInt], ints: [0]);
4037 } 4037 }
4038 4038
4039 test_field_final_invalidConstExpr() {
4040 UnlinkedVariable variable = serializeClassText(r'''
4041 class C {
4042 final int f = 1 + m();
4043 static int m() => 42;
4044 }''').fields[0];
4045 expect(variable.isFinal, isTrue);
4046 _assertUnlinkedConst(variable.constExpr, isInvalid: true);
4047 }
4048
4039 test_field_formal_param_inferred_type_explicit() { 4049 test_field_formal_param_inferred_type_explicit() {
4040 UnlinkedClass cls = serializeClassText( 4050 UnlinkedClass cls = serializeClassText(
4041 'class C extends D { var v; C(int this.v); }' 4051 'class C extends D { var v; C(int this.v); }'
4042 ' abstract class D { num get v; }', 4052 ' abstract class D { num get v; }',
4043 className: 'C'); 4053 className: 'C');
4044 checkInferredTypeSlot( 4054 checkInferredTypeSlot(
4045 cls.fields[0].inferredTypeSlot, 'dart:core', 'dart:core', 'num'); 4055 cls.fields[0].inferredTypeSlot, 'dart:core', 'dart:core', 'num');
4046 expect(cls.executables[0].kind, UnlinkedExecutableKind.constructor); 4056 expect(cls.executables[0].kind, UnlinkedExecutableKind.constructor);
4047 expect(cls.executables[0].parameters[0].inferredTypeSlot, 0); 4057 expect(cls.executables[0].parameters[0].inferredTypeSlot, 0);
4048 } 4058 }
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after
5859 // This reference should have a dependency of 0, since it refers to 5869 // This reference should have a dependency of 0, since it refers to
5860 // an element that is contained within some other element. 5870 // an element that is contained within some other element.
5861 expect(reference.dependency, 0, 5871 expect(reference.dependency, 0,
5862 reason: 'Nonzero dependency for ${reference.kind}'); 5872 reason: 'Nonzero dependency for ${reference.kind}');
5863 } 5873 }
5864 } 5874 }
5865 } 5875 }
5866 } 5876 }
5867 5877
5868 void _assertUnlinkedConst(UnlinkedConst constExpr, 5878 void _assertUnlinkedConst(UnlinkedConst constExpr,
5869 {List<UnlinkedConstOperation> operators, 5879 {bool isInvalid: false,
5880 List<UnlinkedConstOperation> operators: const <UnlinkedConstOperation>[],
5870 List<int> ints: const <int>[], 5881 List<int> ints: const <int>[],
5871 List<double> doubles: const <double>[], 5882 List<double> doubles: const <double>[],
5872 List<String> strings: const <String>[], 5883 List<String> strings: const <String>[],
5873 List<_EntityRefValidator> referenceValidators: 5884 List<_EntityRefValidator> referenceValidators:
5874 const <_EntityRefValidator>[]}) { 5885 const <_EntityRefValidator>[]}) {
5875 expect(constExpr, isNotNull); 5886 expect(constExpr, isNotNull);
5887 expect(constExpr.isInvalid, isInvalid);
5876 expect(constExpr.operations, operators); 5888 expect(constExpr.operations, operators);
5877 expect(constExpr.ints, ints); 5889 expect(constExpr.ints, ints);
5878 expect(constExpr.doubles, doubles); 5890 expect(constExpr.doubles, doubles);
5879 expect(constExpr.strings, strings); 5891 expect(constExpr.strings, strings);
5880 expect(constExpr.references, hasLength(referenceValidators.length)); 5892 expect(constExpr.references, hasLength(referenceValidators.length));
5881 for (int i = 0; i < referenceValidators.length; i++) { 5893 for (int i = 0; i < referenceValidators.length; i++) {
5882 referenceValidators[i](constExpr.references[i]); 5894 referenceValidators[i](constExpr.references[i]);
5883 } 5895 }
5884 } 5896 }
5885 } 5897 }
5886 5898
5887 /** 5899 /**
5888 * Description of expectations for a prelinked prefix reference. 5900 * Description of expectations for a prelinked prefix reference.
5889 */ 5901 */
5890 class _PrefixExpectation { 5902 class _PrefixExpectation {
5891 final ReferenceKind kind; 5903 final ReferenceKind kind;
5892 final String name; 5904 final String name;
5893 final bool inLibraryDefiningUnit; 5905 final bool inLibraryDefiningUnit;
5894 final String absoluteUri; 5906 final String absoluteUri;
5895 final String relativeUri; 5907 final String relativeUri;
5896 final int numTypeParameters; 5908 final int numTypeParameters;
5897 5909
5898 _PrefixExpectation(this.kind, this.name, 5910 _PrefixExpectation(this.kind, this.name,
5899 {this.inLibraryDefiningUnit: false, 5911 {this.inLibraryDefiningUnit: false,
5900 this.absoluteUri, 5912 this.absoluteUri,
5901 this.relativeUri, 5913 this.relativeUri,
5902 this.numTypeParameters: 0}); 5914 this.numTypeParameters: 0});
5903 } 5915 }
OLDNEW
« pkg/analyzer/lib/src/summary/idl.dart ('K') | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698