Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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() { | |
|
Brian Wilkerson
2016/04/08 19:15:31
Maybe also test it on a class member (if that's al
pquitslund
2016/04/08 20:29:42
Done.
| |
| 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 | |
|
terry
2016/04/08 19:38:57
May want to test top-level function use of @JS
@J
pquitslund
2016/04/08 20:29:42
Done.
| |
| 1244 void test_missingReturn_async() { | 1279 void test_missingReturn_async() { |
| 1245 Source source = addSource(''' | 1280 Source source = addSource(''' |
| 1246 import 'dart:async'; | 1281 import 'dart:async'; |
| 1247 Future<int> f() async {} | 1282 Future<int> f() async {} |
| 1248 '''); | 1283 '''); |
| 1249 computeLibrarySourceErrors(source); | 1284 computeLibrarySourceErrors(source); |
| 1250 assertErrors(source, [HintCode.MISSING_RETURN]); | 1285 assertErrors(source, [HintCode.MISSING_RETURN]); |
| 1251 verify([source]); | 1286 verify([source]); |
| 1252 } | 1287 } |
| 1253 | 1288 |
| (...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3099 n() { | 3134 n() { |
| 3100 var a = m(), b = m(); | 3135 var a = m(), b = m(); |
| 3101 } | 3136 } |
| 3102 }'''); | 3137 }'''); |
| 3103 computeLibrarySourceErrors(source); | 3138 computeLibrarySourceErrors(source); |
| 3104 assertErrors( | 3139 assertErrors( |
| 3105 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); | 3140 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); |
| 3106 verify([source]); | 3141 verify([source]); |
| 3107 } | 3142 } |
| 3108 } | 3143 } |
| OLD | NEW |