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

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

Issue 1791493003: Fix for indexing synthetic enum fields. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'dart:convert'; 5 import 'dart:convert';
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/src/summary/format.dart'; 9 import 'package:analyzer/src/summary/format.dart';
10 import 'package:analyzer/src/summary/idl.dart'; 10 import 'package:analyzer/src/summary/idl.dart';
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 { 728 {
729 FieldElement field = findElement('bbb'); 729 FieldElement field = findElement('bbb');
730 PropertyAccessorElement getter = field.getter; 730 PropertyAccessorElement getter = field.getter;
731 PropertyAccessorElement setter = field.setter; 731 PropertyAccessorElement setter = field.setter;
732 assertThat(field)..isWrittenAt('bbb) {}', true); 732 assertThat(field)..isWrittenAt('bbb) {}', true);
733 assertThat(getter)..isReferencedAt('bbb);', false); 733 assertThat(getter)..isReferencedAt('bbb);', false);
734 assertThat(setter)..isReferencedAt('bbb = 2;', false); 734 assertThat(setter)..isReferencedAt('bbb = 2;', false);
735 } 735 }
736 } 736 }
737 737
738 void test_isReferencedBy_FieldElement_ofEnum() {
739 verifyNoTestUnitErrors = false;
740 _indexTestUnit('''
741 enum MyEnum {
742 A, B, C
743 }
744 main() {
745 print(MyEnum.values);
746 print(MyEnum.A.index);
747 print(MyEnum.A);
748 print(MyEnum.B);
749 }
750 ''');
751 ClassElement enumElement = findElement('MyEnum');
752 assertThat(enumElement.getGetter('values'))
753 ..isReferencedAt('values);', true);
754 assertThat(enumElement.getGetter('index'))..isReferencedAt('index);', true);
755 assertThat(enumElement.getGetter('A'))..isReferencedAt('A);', true);
756 assertThat(enumElement.getGetter('B'))..isReferencedAt('B);', true);
757 }
758
738 void test_isReferencedBy_FunctionElement() { 759 void test_isReferencedBy_FunctionElement() {
739 _indexTestUnit(''' 760 _indexTestUnit('''
740 foo() {} 761 foo() {}
741 main() { 762 main() {
742 print(foo); 763 print(foo);
743 print(foo()); 764 print(foo());
744 } 765 }
745 '''); 766 ''');
746 FunctionElement element = findElement('foo'); 767 FunctionElement element = findElement('foo');
747 assertThat(element) 768 assertThat(element)
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 final bool isQualified; 1191 final bool isQualified;
1171 1192
1172 _Relation(this.kind, this.offset, this.length, this.isQualified); 1193 _Relation(this.kind, this.offset, this.length, this.isQualified);
1173 1194
1174 @override 1195 @override
1175 String toString() { 1196 String toString() {
1176 return '_Relation{kind: $kind, offset: $offset, length: $length, ' 1197 return '_Relation{kind: $kind, offset: $offset, length: $length, '
1177 'isQualified: $isQualified}'; 1198 'isQualified: $isQualified}';
1178 } 1199 }
1179 } 1200 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698