| OLD | NEW |
| 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/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| (...skipping 3927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3938 } | 3938 } |
| 3939 class D { | 3939 class D { |
| 3940 final x; | 3940 final x; |
| 3941 D() : x = new C(); | 3941 D() : x = new C(); |
| 3942 } | 3942 } |
| 3943 '''); | 3943 '''); |
| 3944 expect(findClass('C').executables[0].constCycleSlot, 0); | 3944 expect(findClass('C').executables[0].constCycleSlot, 0); |
| 3945 expect(findClass('D').executables[0].constCycleSlot, 0); | 3945 expect(findClass('D').executables[0].constCycleSlot, 0); |
| 3946 } | 3946 } |
| 3947 | 3947 |
| 3948 test_constructorCycle_referenceToClass() { |
| 3949 serializeLibraryText(''' |
| 3950 class C { |
| 3951 final x; |
| 3952 const C() : x = C; |
| 3953 } |
| 3954 '''); |
| 3955 checkConstCycle('C', hasCycle: false); |
| 3956 } |
| 3957 |
| 3958 test_constructorCycle_referenceToEnum() { |
| 3959 serializeLibraryText(''' |
| 3960 enum E { v } |
| 3961 class C { |
| 3962 final x; |
| 3963 const C() : x = E; |
| 3964 } |
| 3965 '''); |
| 3966 checkConstCycle('C', hasCycle: false); |
| 3967 } |
| 3968 |
| 3948 test_constructorCycle_referenceToEnumValue() { | 3969 test_constructorCycle_referenceToEnumValue() { |
| 3949 serializeLibraryText(''' | 3970 serializeLibraryText(''' |
| 3950 enum E { v } | 3971 enum E { v } |
| 3951 class C { | 3972 class C { |
| 3952 final x; | 3973 final x; |
| 3953 const C() : x = E.v; | 3974 const C() : x = E.v; |
| 3954 } | 3975 } |
| 3955 '''); | 3976 '''); |
| 3956 checkConstCycle('C', hasCycle: false); | 3977 checkConstCycle('C', hasCycle: false); |
| 3957 } | 3978 } |
| 3958 | 3979 |
| 3959 test_constructorCycle_referenceToEnumValues() { | 3980 test_constructorCycle_referenceToEnumValues() { |
| 3960 serializeLibraryText(''' | 3981 serializeLibraryText(''' |
| 3961 enum E { v } | 3982 enum E { v } |
| 3962 class C { | 3983 class C { |
| 3963 final x; | 3984 final x; |
| 3964 const C() : x = E.values; | 3985 const C() : x = E.values; |
| 3965 } | 3986 } |
| 3966 '''); | 3987 '''); |
| 3967 checkConstCycle('C', hasCycle: false); | 3988 checkConstCycle('C', hasCycle: false); |
| 3968 } | 3989 } |
| 3969 | 3990 |
| 3991 test_constructorCycle_referenceToGenericParameter() { |
| 3992 // It's not valid Dart but we need to make sure it doesn't crash |
| 3993 // summary generation. |
| 3994 serializeLibraryText( |
| 3995 ''' |
| 3996 class C<T> { |
| 3997 final x; |
| 3998 const C() : x = T; |
| 3999 } |
| 4000 ''', |
| 4001 allowErrors: true); |
| 4002 checkConstCycle('C', hasCycle: false); |
| 4003 } |
| 4004 |
| 4005 test_constructorCycle_referenceToStaticMethod_inOtherClass() { |
| 4006 serializeLibraryText(''' |
| 4007 class C { |
| 4008 final x; |
| 4009 const C() : x = D.f; |
| 4010 } |
| 4011 class D { |
| 4012 static void f() {} |
| 4013 } |
| 4014 '''); |
| 4015 checkConstCycle('C', hasCycle: false); |
| 4016 } |
| 4017 |
| 4018 test_constructorCycle_referenceToStaticMethod_inSameClass() { |
| 4019 serializeLibraryText(''' |
| 4020 class C { |
| 4021 final x; |
| 4022 static void f() {} |
| 4023 const C() : x = f; |
| 4024 } |
| 4025 '''); |
| 4026 checkConstCycle('C', hasCycle: false); |
| 4027 } |
| 4028 |
| 4029 test_constructorCycle_referenceToTopLevelFunction() { |
| 4030 serializeLibraryText(''' |
| 4031 void f() {} |
| 4032 class C { |
| 4033 final x; |
| 4034 const C() : x = f; |
| 4035 } |
| 4036 '''); |
| 4037 checkConstCycle('C', hasCycle: false); |
| 4038 } |
| 4039 |
| 4040 test_constructorCycle_referenceToTypedef() { |
| 4041 serializeLibraryText(''' |
| 4042 typedef F(); |
| 4043 class C { |
| 4044 final x; |
| 4045 const C() : x = F; |
| 4046 } |
| 4047 '''); |
| 4048 checkConstCycle('C', hasCycle: false); |
| 4049 } |
| 4050 |
| 4051 test_constructorCycle_referenceToUndefinedName() { |
| 4052 // It's not valid Dart but we need to make sure it doesn't crash |
| 4053 // summary generation. |
| 4054 serializeLibraryText( |
| 4055 ''' |
| 4056 class C { |
| 4057 final x; |
| 4058 const C() : x = foo; |
| 4059 } |
| 4060 ''', |
| 4061 allowErrors: true); |
| 4062 checkConstCycle('C', hasCycle: false); |
| 4063 } |
| 4064 |
| 4065 test_constructorCycle_referenceToUndefinedName_viaPrefix() { |
| 4066 // It's not valid Dart but we need to make sure it doesn't crash |
| 4067 // summary generation. |
| 4068 addNamedSource('/a.dart', ''); |
| 4069 serializeLibraryText( |
| 4070 ''' |
| 4071 import 'a.dart' as a; |
| 4072 class C { |
| 4073 final x; |
| 4074 const C() : x = a.foo; |
| 4075 } |
| 4076 ''', |
| 4077 allowErrors: true); |
| 4078 } |
| 4079 |
| 4080 test_constructorCycle_referenceToUndefinedName_viaPrefix_nonExistentFile() { |
| 4081 // It's not valid Dart but we need to make sure it doesn't crash |
| 4082 // summary generation. |
| 4083 allowMissingFiles = true; |
| 4084 serializeLibraryText( |
| 4085 ''' |
| 4086 import 'a.dart' as a; |
| 4087 class C { |
| 4088 final x; |
| 4089 const C() : x = a.foo; |
| 4090 } |
| 4091 ''', |
| 4092 allowErrors: true); |
| 4093 } |
| 4094 |
| 3970 test_constructorCycle_viaFinalField() { | 4095 test_constructorCycle_viaFinalField() { |
| 3971 serializeLibraryText( | 4096 serializeLibraryText( |
| 3972 ''' | 4097 ''' |
| 3973 class C { | 4098 class C { |
| 3974 final x = const C(); | 4099 final x = const C(); |
| 3975 const C(); | 4100 const C(); |
| 3976 } | 4101 } |
| 3977 ''', | 4102 ''', |
| 3978 allowErrors: true); | 4103 allowErrors: true); |
| 3979 checkConstCycle('C'); | 4104 checkConstCycle('C'); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4120 class C { | 4245 class C { |
| 4121 final x; | 4246 final x; |
| 4122 const C() : x = y; | 4247 const C() : x = y; |
| 4123 } | 4248 } |
| 4124 const y = const C(); | 4249 const y = const C(); |
| 4125 ''', | 4250 ''', |
| 4126 allowErrors: true); | 4251 allowErrors: true); |
| 4127 checkConstCycle('C'); | 4252 checkConstCycle('C'); |
| 4128 } | 4253 } |
| 4129 | 4254 |
| 4255 test_constructorCycle_viaTopLevelVariable_imported() { |
| 4256 addNamedSource( |
| 4257 '/a.dart', |
| 4258 ''' |
| 4259 import 'test.dart'; |
| 4260 const y = const C(); |
| 4261 '''); |
| 4262 serializeLibraryText( |
| 4263 ''' |
| 4264 import 'a.dart'; |
| 4265 class C { |
| 4266 final x; |
| 4267 const C() : x = y; |
| 4268 } |
| 4269 ''', |
| 4270 allowErrors: true); |
| 4271 checkConstCycle('C'); |
| 4272 } |
| 4273 |
| 4274 test_constructorCycle_viaTopLevelVariable_importedViaPrefix() { |
| 4275 addNamedSource( |
| 4276 '/a.dart', |
| 4277 ''' |
| 4278 import 'test.dart'; |
| 4279 const y = const C(); |
| 4280 '''); |
| 4281 serializeLibraryText( |
| 4282 ''' |
| 4283 import 'a.dart' as a; |
| 4284 class C { |
| 4285 final x; |
| 4286 const C() : x = a.y; |
| 4287 } |
| 4288 ''', |
| 4289 allowErrors: true); |
| 4290 checkConstCycle('C'); |
| 4291 } |
| 4292 |
| 4130 test_dependencies_export_to_export_unused() { | 4293 test_dependencies_export_to_export_unused() { |
| 4131 addNamedSource('/a.dart', 'export "b.dart";'); | 4294 addNamedSource('/a.dart', 'export "b.dart";'); |
| 4132 addNamedSource('/b.dart', ''); | 4295 addNamedSource('/b.dart', ''); |
| 4133 serializeLibraryText('export "a.dart";'); | 4296 serializeLibraryText('export "a.dart";'); |
| 4134 // The main test library depends on b.dart, even though it doesn't | 4297 // The main test library depends on b.dart, even though it doesn't |
| 4135 // re-export any names defined in b.dart, because a change to b.dart might | 4298 // re-export any names defined in b.dart, because a change to b.dart might |
| 4136 // cause it to start exporting a name that the main test library *does* | 4299 // cause it to start exporting a name that the main test library *does* |
| 4137 // use. | 4300 // use. |
| 4138 checkHasDependency(absUri('/b.dart'), 'b.dart'); | 4301 checkHasDependency(absUri('/b.dart'), 'b.dart'); |
| 4139 } | 4302 } |
| (...skipping 3697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7837 class _PrefixExpectation { | 8000 class _PrefixExpectation { |
| 7838 final ReferenceKind kind; | 8001 final ReferenceKind kind; |
| 7839 final String name; | 8002 final String name; |
| 7840 final String absoluteUri; | 8003 final String absoluteUri; |
| 7841 final String relativeUri; | 8004 final String relativeUri; |
| 7842 final int numTypeParameters; | 8005 final int numTypeParameters; |
| 7843 | 8006 |
| 7844 _PrefixExpectation(this.kind, this.name, | 8007 _PrefixExpectation(this.kind, this.name, |
| 7845 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 8008 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 7846 } | 8009 } |
| OLD | NEW |