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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/hint_code_test.dart
diff --git a/pkg/analyzer/test/generated/hint_code_test.dart b/pkg/analyzer/test/generated/hint_code_test.dart
index 242da2f162d814b55c325632c65dae4da1acbe20..168c471b77b27e84b097f4c42aa36ab252430c12 100644
--- a/pkg/analyzer/test/generated/hint_code_test.dart
+++ b/pkg/analyzer/test/generated/hint_code_test.dart
@@ -132,6 +132,12 @@ class _Required {
final String reason;
const _Required([this.reason]));
}
+''',
+ 'package:js/js.dart': r'''
+library js;
+class JS {
+ const JS([String js]) { }
+}
'''
});
}
@@ -1241,6 +1247,65 @@ main() {
verify([source]);
}
+ void test_js_lib_OK() {
+ Source source = addSource(r'''
+@JS()
+library foo;
+
+import 'package:js/js.dart';
+
+@JS()
+class A { }
+''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
+ void test_missing_js_lib_on_class_decl() {
+ Source source = addSource(r'''
+library foo;
+
+import 'package:js/js.dart';
+
+@JS()
+class A { }
+''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [HintCode.MISSING_JS_LIB_ANNOTATION]);
+ verify([source]);
+ }
+
+ void test_missing_js_lib_on_function() {
+ Source source = addSource(r'''
+library foo;
+
+import 'package:js/js.dart';
+
+@JS('acxZIndex')
+set _currentZIndex(int value) { }
+''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [HintCode.MISSING_JS_LIB_ANNOTATION]);
+ verify([source]);
+ }
+
+ void test_missing_js_lib_on_member() {
+ Source source = addSource(r'''
+library foo;
+
+import 'package:js/js.dart';
+
+class A {
+ @JS()
+ void a() { }
+}
+''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [HintCode.MISSING_JS_LIB_ANNOTATION]);
+ verify([source]);
+ }
+
void test_missingReturn_async() {
Source source = addSource('''
import 'dart:async';
« 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