Index: tests/compiler/dart2js/private_test.dart |
diff --git a/tests/compiler/dart2js/private_test.dart b/tests/compiler/dart2js/private_test.dart |
index fbfba80483d8827808e3839197f7d535f5cce023..4c5f6337377e9a57b3bde57e97c76d9b659db604 100644 |
--- a/tests/compiler/dart2js/private_test.dart |
+++ b/tests/compiler/dart2js/private_test.dart |
@@ -41,11 +41,10 @@ class PublicClass extends _PrivateClass { |
} |
'''; |
- |
analyze(String text, [expectedWarnings]) { |
return () { |
if (expectedWarnings == null) expectedWarnings = []; |
- if (expectedWarnings is !List) expectedWarnings = [expectedWarnings]; |
+ if (expectedWarnings is! List) expectedWarnings = [expectedWarnings]; |
MockCompiler compiler = new MockCompiler.internal(analyzeOnly: true); |
compiler.registerSource(Uri.parse(PRIVATE_SOURCE_URI), PRIVATE_SOURCE); |
@@ -80,95 +79,91 @@ analyze(String text, [expectedWarnings]) { |
void main() { |
asyncTest(() => Future.forEach([ |
- // Read from private variable. |
- analyze('var value = _privateVariable;', MessageKind.CANNOT_RESOLVE), |
- // Write to private variable. |
- analyze('_privateVariable = 0;', MessageKind.CANNOT_RESOLVE), |
- // Access private function. |
- analyze('var value = _privateFunction;', MessageKind.CANNOT_RESOLVE), |
- // Call private function. |
- analyze('_privateFunction();', MessageKind.CANNOT_RESOLVE), |
- |
- // Call unnamed (public) constructor on private class. |
- analyze('new _PrivateClass();', MessageKind.CANNOT_RESOLVE), |
- // Call public constructor on private class. |
- analyze('new _PrivateClass.publicConstructor();', |
+ // Read from private variable. |
+ analyze('var value = _privateVariable;', MessageKind.CANNOT_RESOLVE), |
+ // Write to private variable. |
+ analyze('_privateVariable = 0;', MessageKind.CANNOT_RESOLVE), |
+ // Access private function. |
+ analyze('var value = _privateFunction;', MessageKind.CANNOT_RESOLVE), |
+ // Call private function. |
+ analyze('_privateFunction();', MessageKind.CANNOT_RESOLVE), |
+ |
+ // Call unnamed (public) constructor on private class. |
+ analyze('new _PrivateClass();', MessageKind.CANNOT_RESOLVE), |
+ // Call public constructor on private class. |
+ analyze('new _PrivateClass.publicConstructor();', |
+ MessageKind.CANNOT_RESOLVE), |
+ // Call private constructor on private class. |
+ analyze('new _PrivateClass._privateConstructor();', |
MessageKind.CANNOT_RESOLVE), |
- // Call private constructor on private class. |
- analyze('new _PrivateClass._privateConstructor();', |
- MessageKind.CANNOT_RESOLVE), |
- // Call public getter of private type. |
- analyze('var value = publicClass.private;'), |
- // Read from private field on private class. |
- analyze('var value = publicClass.private._privateField;', |
- MessageKind.PRIVATE_ACCESS), |
- // Write to private field on private class. |
- analyze('publicClass.private._privateField = 0;', |
- MessageKind.PRIVATE_ACCESS), |
- // Call private getter on private class. |
- analyze('var value = publicClass.private._privateGetter;', |
- MessageKind.PRIVATE_ACCESS), |
- // Call private setter on private class. |
- analyze('publicClass.private._privateSetter = 0;', |
- MessageKind.PRIVATE_ACCESS), |
- // Access private method on private class. |
- analyze('var value = publicClass.private._privateMethod;', |
- MessageKind.PRIVATE_ACCESS), |
- // Call private method on private class. |
- analyze('publicClass.private._privateMethod();', |
- MessageKind.PRIVATE_ACCESS), |
- |
- // Read from public field on private class. |
- analyze('var value = publicClass.private.publicField;'), |
- // Write to public field on private class. |
- analyze('publicClass.private.publicField = 0;'), |
- // Call public getter on private class. |
- analyze('var value = publicClass.private.publicGetter;'), |
- // Call public setter on private class. |
- analyze('publicClass.private.publicSetter = 0;'), |
- // Access public method on private class. |
- analyze('var value = publicClass.private.publicMethod;'), |
- // Call public method on private class. |
- analyze('publicClass.private.publicMethod();'), |
- |
- // Call unnamed (public) constructor on public class. |
- analyze('publicClass = new PublicClass();'), |
- // Call public constructor on public class. |
- analyze('publicClass = new PublicClass.publicConstructor();'), |
- // Call private constructor on public class. |
- analyze('publicClass = new PublicClass._privateConstructor();', |
- MessageKind.CANNOT_FIND_CONSTRUCTOR), |
- // Read from private field on public class. |
- analyze('var value = publicClass._privateField;', |
- MessageKind.PRIVATE_ACCESS), |
- // Write to private field on public class. |
- analyze('publicClass._privateField = 0;', |
- MessageKind.PRIVATE_ACCESS), |
- // Call private getter on public class. |
- analyze('var value = publicClass._privateGetter;', |
- MessageKind.PRIVATE_ACCESS), |
- // Call private setter on public class. |
- analyze('publicClass._privateSetter = 0;', |
- MessageKind.PRIVATE_ACCESS), |
- // Access private method on public class. |
- analyze('var value = publicClass._privateMethod;', |
- MessageKind.PRIVATE_ACCESS), |
- // Call private method on public class. |
- analyze('publicClass._privateMethod();', |
- MessageKind.PRIVATE_ACCESS), |
- |
- // Read from public field on public class. |
- analyze('var value = publicClass.publicField;'), |
- // Write to public field on public class. |
- analyze('publicClass.publicField = 0;'), |
- // Call public getter on public class. |
- analyze('var value = publicClass.publicGetter;'), |
- // Call public setter on public class. |
- analyze('publicClass.publicSetter = 0;'), |
- // Access public method on public class. |
- analyze('var value = publicClass.publicMethod;'), |
- // Call public method on public class. |
- analyze('publicClass.publicMethod();'), |
- ], (f) => f())); |
+ // Call public getter of private type. |
+ analyze('var value = publicClass.private;'), |
+ // Read from private field on private class. |
+ analyze('var value = publicClass.private._privateField;', |
+ MessageKind.PRIVATE_ACCESS), |
+ // Write to private field on private class. |
+ analyze('publicClass.private._privateField = 0;', |
+ MessageKind.PRIVATE_ACCESS), |
+ // Call private getter on private class. |
+ analyze('var value = publicClass.private._privateGetter;', |
+ MessageKind.PRIVATE_ACCESS), |
+ // Call private setter on private class. |
+ analyze('publicClass.private._privateSetter = 0;', |
+ MessageKind.PRIVATE_ACCESS), |
+ // Access private method on private class. |
+ analyze('var value = publicClass.private._privateMethod;', |
+ MessageKind.PRIVATE_ACCESS), |
+ // Call private method on private class. |
+ analyze('publicClass.private._privateMethod();', |
+ MessageKind.PRIVATE_ACCESS), |
+ |
+ // Read from public field on private class. |
+ analyze('var value = publicClass.private.publicField;'), |
+ // Write to public field on private class. |
+ analyze('publicClass.private.publicField = 0;'), |
+ // Call public getter on private class. |
+ analyze('var value = publicClass.private.publicGetter;'), |
+ // Call public setter on private class. |
+ analyze('publicClass.private.publicSetter = 0;'), |
+ // Access public method on private class. |
+ analyze('var value = publicClass.private.publicMethod;'), |
+ // Call public method on private class. |
+ analyze('publicClass.private.publicMethod();'), |
+ |
+ // Call unnamed (public) constructor on public class. |
+ analyze('publicClass = new PublicClass();'), |
+ // Call public constructor on public class. |
+ analyze('publicClass = new PublicClass.publicConstructor();'), |
+ // Call private constructor on public class. |
+ analyze('publicClass = new PublicClass._privateConstructor();', |
+ MessageKind.CANNOT_FIND_CONSTRUCTOR), |
+ // Read from private field on public class. |
+ analyze('var value = publicClass._privateField;', |
+ MessageKind.PRIVATE_ACCESS), |
+ // Write to private field on public class. |
+ analyze('publicClass._privateField = 0;', MessageKind.PRIVATE_ACCESS), |
+ // Call private getter on public class. |
+ analyze('var value = publicClass._privateGetter;', |
+ MessageKind.PRIVATE_ACCESS), |
+ // Call private setter on public class. |
+ analyze('publicClass._privateSetter = 0;', MessageKind.PRIVATE_ACCESS), |
+ // Access private method on public class. |
+ analyze('var value = publicClass._privateMethod;', |
+ MessageKind.PRIVATE_ACCESS), |
+ // Call private method on public class. |
+ analyze('publicClass._privateMethod();', MessageKind.PRIVATE_ACCESS), |
+ |
+ // Read from public field on public class. |
+ analyze('var value = publicClass.publicField;'), |
+ // Write to public field on public class. |
+ analyze('publicClass.publicField = 0;'), |
+ // Call public getter on public class. |
+ analyze('var value = publicClass.publicGetter;'), |
+ // Call public setter on public class. |
+ analyze('publicClass.publicSetter = 0;'), |
+ // Access public method on public class. |
+ analyze('var value = publicClass.publicMethod;'), |
+ // Call public method on public class. |
+ analyze('publicClass.publicMethod();'), |
+ ], (f) => f())); |
} |
- |