OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
8 import 'package:analyzer/src/dart/analysis/driver.dart'; | 8 import 'package:analyzer/src/dart/analysis/driver.dart'; |
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 test_initializer_cascade() async { | 70 test_initializer_cascade() async { |
71 var content = r''' | 71 var content = r''' |
72 var a = 0; | 72 var a = 0; |
73 var t = (/*error:TOP_LEVEL_UNSUPPORTED*/a = 1)..isEven; | 73 var t = (/*error:TOP_LEVEL_UNSUPPORTED*/a = 1)..isEven; |
74 '''; | 74 '''; |
75 await checkFile(content); | 75 await checkFile(content); |
76 } | 76 } |
77 | 77 |
78 test_initializer_classField_assign() async { | 78 test_initializer_classField_instance_instanceCreation() async { |
79 var content = r''' | 79 var content = r''' |
80 class A { | 80 class A<T> {} |
81 static var a = 1; | 81 class B { |
82 static var t = /*error:TOP_LEVEL_UNSUPPORTED*/a += 1; | 82 var t1 = new A<int>(); |
| 83 var t2 = /*info:INFERRED_TYPE_ALLOCATION*/new |
| 84 /*error:TOP_LEVEL_TYPE_ARGUMENTS*/A(); |
83 } | 85 } |
84 '''; | 86 '''; |
85 await checkFile(content); | 87 await checkFile(content); |
| 88 } |
| 89 |
| 90 test_initializer_classField_static_instanceCreation() async { |
| 91 var content = r''' |
| 92 class A<T> {} |
| 93 class B { |
| 94 static var t1 = 1; |
| 95 static var t2 = /*info:INFERRED_TYPE_ALLOCATION*/new |
| 96 /*error:TOP_LEVEL_TYPE_ARGUMENTS*/A(); |
| 97 } |
| 98 '''; |
| 99 await checkFile(content); |
86 } | 100 } |
87 | 101 |
88 test_initializer_conditional() async { | 102 test_initializer_conditional() async { |
89 var content = r''' | 103 var content = r''' |
90 var a = 1; | 104 var a = 1; |
91 var b = true; | 105 var b = true; |
92 var t = b ? | 106 var t = b ? |
93 (/*error:TOP_LEVEL_UNSUPPORTED*/a = 1) : | 107 (/*error:TOP_LEVEL_UNSUPPORTED*/a = 1) : |
94 (/*error:TOP_LEVEL_UNSUPPORTED*/a = 2); | 108 (/*error:TOP_LEVEL_UNSUPPORTED*/a = 2); |
95 '''; | 109 '''; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 var content = r''' | 205 var content = r''' |
192 class A {} | 206 class A {} |
193 var t = new A(); | 207 var t = new A(); |
194 '''; | 208 '''; |
195 await checkFile(content); | 209 await checkFile(content); |
196 } | 210 } |
197 | 211 |
198 test_initializer_instanceCreation_withTypeParameters() async { | 212 test_initializer_instanceCreation_withTypeParameters() async { |
199 var content = r''' | 213 var content = r''' |
200 class A<T> {} | 214 class A<T> {} |
201 var t1 = new /*error:TOP_LEVEL_TYPE_ARGUMENTS*/A(); | 215 var t1 = new A<int>(); |
202 var t2 = new A<int>(); | 216 var t2 = /*info:INFERRED_TYPE_ALLOCATION*/new |
| 217 /*error:TOP_LEVEL_TYPE_ARGUMENTS*/A(); |
203 '''; | 218 '''; |
204 await checkFile(content); | 219 await checkFile(content); |
205 } | 220 } |
206 | 221 |
207 test_initializer_instanceGetter() async { | 222 test_initializer_instanceGetter() async { |
208 var content = r''' | 223 var content = r''' |
209 class A { | 224 class A { |
210 int f = 1; | 225 int f = 1; |
211 } | 226 } |
212 var a = new A()./*error:TOP_LEVEL_INSTANCE_GETTER*/f; | 227 var a = new A()./*error:TOP_LEVEL_INSTANCE_GETTER*/f; |
(...skipping 2472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2685 | 2700 |
2686 Future<LibraryElement> _encodeDecodeLibrary(String text) async { | 2701 Future<LibraryElement> _encodeDecodeLibrary(String text) async { |
2687 String path = _p('/test.dart'); | 2702 String path = _p('/test.dart'); |
2688 provider.newFile(path, text); | 2703 provider.newFile(path, text); |
2689 UnitElementResult result = await driver.getUnitElement(path); | 2704 UnitElementResult result = await driver.getUnitElement(path); |
2690 return result.element.library; | 2705 return result.element.library; |
2691 } | 2706 } |
2692 | 2707 |
2693 String _p(String path) => provider.convertPath(path); | 2708 String _p(String path) => provider.convertPath(path); |
2694 } | 2709 } |
OLD | NEW |