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

Side by Side Diff: pkg/analyzer/test/generated/hint_code_test.dart

Issue 1871103002: Support for @JS() validation (#26225). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: test fixes Created 4 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/generated/error_verifier.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 library analyzer.test.generated.hint_code_test; 5 library analyzer.test.generated.hint_code_test;
6 6
7 import 'package:analyzer/src/generated/engine.dart'; 7 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/error.dart'; 8 import 'package:analyzer/src/generated/error.dart';
9 import 'package:analyzer/src/generated/source_io.dart'; 9 import 'package:analyzer/src/generated/source_io.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 class _Override { 125 class _Override {
126 const _Override(); 126 const _Override();
127 } 127 }
128 class _Protected { 128 class _Protected {
129 const _Protected(); 129 const _Protected();
130 } 130 }
131 class _Required { 131 class _Required {
132 final String reason; 132 final String reason;
133 const _Required([this.reason])); 133 const _Required([this.reason]));
134 } 134 }
135 ''',
136 'package:js/js.dart': r'''
137 library js;
138 class JS {
139 const JS([String js]) { }
140 }
135 ''' 141 '''
136 }); 142 });
137 } 143 }
138 144
139 void test_argumentTypeNotAssignable_functionType() { 145 void test_argumentTypeNotAssignable_functionType() {
140 Source source = addSource(r''' 146 Source source = addSource(r'''
141 m() { 147 m() {
142 var a = new A(); 148 var a = new A();
143 a.n(() => 0); 149 a.n(() => 0);
144 } 150 }
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 void test_isNotDouble() { 1240 void test_isNotDouble() {
1235 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 1241 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
1236 options.dart2jsHint = true; 1242 options.dart2jsHint = true;
1237 resetWithOptions(options); 1243 resetWithOptions(options);
1238 Source source = addSource("var v = 1 is! double;"); 1244 Source source = addSource("var v = 1 is! double;");
1239 computeLibrarySourceErrors(source); 1245 computeLibrarySourceErrors(source);
1240 assertErrors(source, [HintCode.IS_NOT_DOUBLE]); 1246 assertErrors(source, [HintCode.IS_NOT_DOUBLE]);
1241 verify([source]); 1247 verify([source]);
1242 } 1248 }
1243 1249
1250 void test_js_lib_OK() {
1251 Source source = addSource(r'''
1252 @JS()
1253 library foo;
1254
1255 import 'package:js/js.dart';
1256
1257 @JS()
1258 class A { }
1259 ''');
1260 computeLibrarySourceErrors(source);
1261 assertNoErrors(source);
1262 verify([source]);
1263 }
1264
1265 void test_missing_js_lib_on_class_decl() {
1266 Source source = addSource(r'''
1267 library foo;
1268
1269 import 'package:js/js.dart';
1270
1271 @JS()
1272 class A { }
1273 ''');
1274 computeLibrarySourceErrors(source);
1275 assertErrors(source, [HintCode.MISSING_JS_LIB_ANNOTATION]);
1276 verify([source]);
1277 }
1278
1279 void test_missing_js_lib_on_function() {
1280 Source source = addSource(r'''
1281 library foo;
1282
1283 import 'package:js/js.dart';
1284
1285 @JS('acxZIndex')
1286 set _currentZIndex(int value) { }
1287 ''');
1288 computeLibrarySourceErrors(source);
1289 assertErrors(source, [HintCode.MISSING_JS_LIB_ANNOTATION]);
1290 verify([source]);
1291 }
1292
1293 void test_missing_js_lib_on_member() {
1294 Source source = addSource(r'''
1295 library foo;
1296
1297 import 'package:js/js.dart';
1298
1299 class A {
1300 @JS()
1301 void a() { }
1302 }
1303 ''');
1304 computeLibrarySourceErrors(source);
1305 assertErrors(source, [HintCode.MISSING_JS_LIB_ANNOTATION]);
1306 verify([source]);
1307 }
1308
1244 void test_missingReturn_async() { 1309 void test_missingReturn_async() {
1245 Source source = addSource(''' 1310 Source source = addSource('''
1246 import 'dart:async'; 1311 import 'dart:async';
1247 Future<int> f() async {} 1312 Future<int> f() async {}
1248 '''); 1313 ''');
1249 computeLibrarySourceErrors(source); 1314 computeLibrarySourceErrors(source);
1250 assertErrors(source, [HintCode.MISSING_RETURN]); 1315 assertErrors(source, [HintCode.MISSING_RETURN]);
1251 verify([source]); 1316 verify([source]);
1252 } 1317 }
1253 1318
(...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after
3175 n() { 3240 n() {
3176 var a = m(), b = m(); 3241 var a = m(), b = m();
3177 } 3242 }
3178 }'''); 3243 }''');
3179 computeLibrarySourceErrors(source); 3244 computeLibrarySourceErrors(source);
3180 assertErrors( 3245 assertErrors(
3181 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 3246 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
3182 verify([source]); 3247 verify([source]);
3183 } 3248 }
3184 } 3249 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698