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

Unified Diff: tests/compiler/dart2js/patch_test.dart

Issue 1421723002: Require that injected members are private. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 | « sdk/lib/_internal/js_runtime/lib/collection_patch.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/patch_test.dart
diff --git a/tests/compiler/dart2js/patch_test.dart b/tests/compiler/dart2js/patch_test.dart
index d44f23e5525b6c5306bb98b3ef1f7277ddb19aeb..28bae9e995ee0bc6707147fb4038bede67d59823 100644
--- a/tests/compiler/dart2js/patch_test.dart
+++ b/tests/compiler/dart2js/patch_test.dart
@@ -148,8 +148,8 @@ Future testPatchFunctionMetadata() async {
@a external test();
""",
"""
- const b = 1;
- @patch @b test() {}
+ const _b = 1;
+ @patch @_b test() {}
""");
Element origin = ensure(compiler, "test", compiler.coreLibrary.find,
expectIsPatched: true, checkHasBody: true);
@@ -408,7 +408,7 @@ Future testRegularMember() async {
"Unexpected errors: ${compiler.errors}");
}
-Future testGhostMember() async {
+Future testInjectedMember() async {
var compiler = await applyPatch(
"""
class Class {
@@ -416,7 +416,7 @@ Future testGhostMember() async {
""",
"""
@patch class Class {
- void ghost() {}
+ void _injected() {}
}
""");
var container = ensure(compiler, "Class", compiler.coreLibrary.find,
@@ -425,9 +425,9 @@ Future testGhostMember() async {
ensure(compiler, "Class", compiler.coreLibrary.patch.find,
expectIsPatch: true);
- ensure(compiler, "ghost", container.lookupLocalMember,
+ ensure(compiler, "_injected", container.lookupLocalMember,
expectIsFound: false);
- ensure(compiler, "ghost", container.patch.lookupLocalMember,
+ ensure(compiler, "_injected", container.patch.lookupLocalMember,
checkHasBody: true, expectIsRegular: true);
Expect.isTrue(compiler.warnings.isEmpty,
@@ -436,7 +436,37 @@ Future testGhostMember() async {
"Unexpected errors: ${compiler.errors}");
}
-Future testInjectFunction() async {
+Future testInjectedPublicMember() async {
+ var compiler = await applyPatch(
+ """
+ class Class {
+ }
+ """,
+ """
+ @patch class Class {
+ void injected() {}
+ }
+ """);
+ var container = ensure(compiler, "Class", compiler.coreLibrary.find,
+ expectIsPatched: true);
+ container.parseNode(compiler.parsing);
+ ensure(compiler, "Class", compiler.coreLibrary.patch.find,
+ expectIsPatch: true);
+
+ ensure(compiler, "injected", container.lookupLocalMember,
+ expectIsFound: false);
+ ensure(compiler, "injected", container.patch.lookupLocalMember,
+ checkHasBody: true, expectIsRegular: true);
+
+ Expect.isTrue(compiler.warnings.isEmpty,
+ "Unexpected warnings: ${compiler.warnings}");
+ Expect.equals(1, compiler.errors.length,
+ "Unexpected errors: ${compiler.errors}");
+ Expect.isTrue(
+ compiler.errors[0].message.kind == MessageKind.INJECTED_PUBLIC_MEMBER);
+}
+
+Future testInjectedFunction() async {
var compiler = await applyPatch(
"",
"int _function() => 5;");
@@ -455,6 +485,27 @@ Future testInjectFunction() async {
"Unexpected errors: ${compiler.errors}");
}
+Future testInjectedPublicFunction() async {
+ var compiler = await applyPatch(
+ "",
+ "int function() => 5;");
+ ensure(compiler,
+ "function",
+ compiler.coreLibrary.find,
+ expectIsFound: false);
+ ensure(compiler,
+ "function",
+ compiler.coreLibrary.patch.find,
+ checkHasBody: true, expectIsRegular: true);
+
+ Expect.isTrue(compiler.warnings.isEmpty,
+ "Unexpected warnings: ${compiler.warnings}");
+ Expect.equals(1, compiler.errors.length,
+ "Unexpected errors: ${compiler.errors}");
+ Expect.isTrue(
+ compiler.errors[0].message.kind == MessageKind.INJECTED_PUBLIC_MEMBER);
+}
+
Future testPatchSignatureCheck() async {
var compiler = await applyPatch(
"""
@@ -1001,8 +1052,10 @@ main() {
await testPatchMember();
await testPatchGetter();
await testRegularMember();
- await testGhostMember();
- await testInjectFunction();
+ await testInjectedMember();
+ await testInjectedPublicMember();
+ await testInjectedFunction();
+ await testInjectedPublicFunction();
await testPatchSignatureCheck();
await testPatchVersioned();
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/collection_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698