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

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

Issue 2842573002: Allow 'extract index' in top-level inference. (Closed)
Patch Set: Created 3 years, 8 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/task/strong/checker.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) 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 test_initializer_equality() async { 121 test_initializer_equality() async {
122 var content = r''' 122 var content = r'''
123 var a = 1; 123 var a = 1;
124 var t1 = ((a = 1) == 0) == ((a = 2) == 0); 124 var t1 = ((a = 1) == 0) == ((a = 2) == 0);
125 var t2 = ((a = 1) == 0) != ((a = 2) == 0); 125 var t2 = ((a = 1) == 0) != ((a = 2) == 0);
126 '''; 126 ''';
127 await checkFile(content); 127 await checkFile(content);
128 } 128 }
129 129
130 test_initializer_extractIndex() async {
131 var content = r'''
132 var a = /*info:INFERRED_TYPE_LITERAL*/[0, 1.2];
133 var b0 = a[0];
134 var b1 = a[1];
135 ''';
136 await checkFile(content);
137 }
138
130 test_initializer_functionLiteral_blockBody() async { 139 test_initializer_functionLiteral_blockBody() async {
131 var content = r''' 140 var content = r'''
132 var t = /*error:TOP_LEVEL_FUNCTION_LITERAL_BLOCK*/ 141 var t = /*error:TOP_LEVEL_FUNCTION_LITERAL_BLOCK*/
133 /*info:INFERRED_TYPE_CLOSURE*/ 142 /*info:INFERRED_TYPE_CLOSURE*/
134 (int p) {}; 143 (int p) {};
135 '''; 144 ''';
136 await checkFile(content); 145 await checkFile(content);
137 } 146 }
138 147
139 test_initializer_functionLiteral_expressionBody() async { 148 test_initializer_functionLiteral_expressionBody() async {
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 class C { 873 class C {
865 static D get d {} 874 static D get d {}
866 } 875 }
867 class D { 876 class D {
868 int i; 877 int i;
869 } 878 }
870 dynamic x/*error: instanceGetter*/; 879 dynamic x/*error: instanceGetter*/;
871 '''); 880 ''');
872 } 881 }
873 882
883 test_initializer_extractIndex() async {
884 var library = await _encodeDecodeLibrary(r'''
885 var a = [0, 1.2];
886 var b0 = a[0];
887 var b1 = a[1];
888 ''');
889 checkElementText(
890 library,
891 r'''
892 List<num> a;
893 num b0;
894 num b1;
895 ''');
896 }
897
874 test_initializer_functionExpression() async { 898 test_initializer_functionExpression() async {
875 var library = await _encodeDecodeLibrary(r''' 899 var library = await _encodeDecodeLibrary(r'''
876 import 'dart:async'; 900 import 'dart:async';
877 var vFuture = new Future<int>(42); 901 var vFuture = new Future<int>(42);
878 var v_noParameters_inferredReturnType = () => 42; 902 var v_noParameters_inferredReturnType = () => 42;
879 var v_hasParameter_withType_inferredReturnType = (String a) => 42; 903 var v_hasParameter_withType_inferredReturnType = (String a) => 42;
880 var v_hasParameter_withType_returnParameter = (String a) => a; 904 var v_hasParameter_withType_returnParameter = (String a) => a;
881 var v_async_returnValue = () async => 42; 905 var v_async_returnValue = () async => 42;
882 var v_async_returnFuture = () async => vFuture; 906 var v_async_returnFuture = () async => vFuture;
883 '''); 907 ''');
(...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 2799
2776 Future<LibraryElement> _encodeDecodeLibrary(String text) async { 2800 Future<LibraryElement> _encodeDecodeLibrary(String text) async {
2777 String path = _p('/test.dart'); 2801 String path = _p('/test.dart');
2778 provider.newFile(path, text); 2802 provider.newFile(path, text);
2779 UnitElementResult result = await driver.getUnitElement(path); 2803 UnitElementResult result = await driver.getUnitElement(path);
2780 return result.element.library; 2804 return result.element.library;
2781 } 2805 }
2782 2806
2783 String _p(String path) => provider.convertPath(path); 2807 String _p(String path) => provider.convertPath(path);
2784 } 2808 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698