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

Unified Diff: tests/lib/mirrors/symbol_validation_test.dart

Issue 177483002: Add validation of private symbols to the dart2js mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 10 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 | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/symbol_validation_test.dart
diff --git a/tests/lib/mirrors/symbol_validation_test.dart b/tests/lib/mirrors/symbol_validation_test.dart
index b0f5ac5383fae9a3786cf168ad29a2eed058783d..1a38e79e203ed2f8871d5b4b07ca0ae043ac4244 100644
--- a/tests/lib/mirrors/symbol_validation_test.dart
+++ b/tests/lib/mirrors/symbol_validation_test.dart
@@ -11,7 +11,6 @@ validSymbol(String string) {
Expect.equals(string,
MirrorSystem.getName(new Symbol(string)),
'Valid symbol "$string" should be invertable');
- return; /// 01: ok
Expect.equals(string,
MirrorSystem.getName(MirrorSystem.getSymbol(string)),
'Valid symbol "$string" should be invertable');
@@ -21,12 +20,19 @@ invalidSymbol(String string) {
Expect.throws(() => new Symbol(string),
(e) => e is ArgumentError,
'Invalid symbol "$string" should be rejected');
- return; /// 01: continued
Expect.throws(() => MirrorSystem.getSymbol(string),
- (e) => e is ArgumentError,
+ (e) => e is ArgumentError,
'Invalid symbol "$string" should be rejected');
}
+validPrivateSymbol(String string) {
+ ClosureMirror closure = reflect(main);
+ LibraryMirror library = closure.function.owner;
+ Expect.equals(string,
+ MirrorSystem.getName(MirrorSystem.getSymbol(string, library)),
+ 'Valid private symbol "$string" should be invertable');
+}
+
main() {
// Operators that can be declared as class member operators.
// These are all valid as symbols.
@@ -43,7 +49,7 @@ main() {
var simpleSymbols = [
'foo', 'bar_', 'baz.quz', 'fisk1', 'hest2fisk', 'a.b.c.d.e',
r'$', r'foo$', r'bar$bar', r'$.$', r'x6$_', r'$6_', r'x.$$6_',
- 'x_', 'x_.x_',
+ 'x_', 'x_.x_', 'unary', 'x.unary'
];
simpleSymbols.expand((s) => [s, "s="]).forEach(validSymbol);
@@ -122,4 +128,10 @@ main() {
builtInIdentifiers.expand((w) => [w, "$w=", "x.$w" , "$w.x", "x.$w.x",
"$w=", "x.$w="])
.forEach(validSymbol);
+
+ var privateSymbols = [
+ '_', '_x', 'x._y', 'x._', 'x.y._', 'x._.y', '_true'
+ ];
+ privateSymbols.forEach(invalidSymbol);
+ privateSymbols.forEach(validPrivateSymbol); /// 01: ok
}
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698