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

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

Issue 24631003: Add proper API for creating private symbols wrt a library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: maintain dart2js coverage Created 7 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 | « tests/lib/mirrors/private_symbol_test.dart ('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
new file mode 100644
index 0000000000000000000000000000000000000000..0fe3c45c3d412b142226754f67f66ee0473c4d18
--- /dev/null
+++ b/tests/lib/mirrors/symbol_validation_test.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library symbol_validation_test;
+
+import 'dart:mirrors';
+import 'package:expect/expect.dart';
+
+validSymbol(String string) {
+ Expect.equals(string,
+ MirrorSystem.getName(new Symbol(string)),
+ 'Valid symbol "$string" should be invertable');
+ Expect.equals(string,
+ MirrorSystem.getName(MirrorSystem.getSymbol(string)),
+ 'Valid symbol "$string" should be invertable');
+}
+
+invalidSymbol(String string) {
+ Expect.throws(() => new Symbol(string),
+ (e) => e is ArgumentError,
+ 'Invalid symbol "$string" should be rejected');
+ Expect.throws(() => MirrorSystem.getSymbol(string),
+ (e) => e is ArgumentError,
+ 'Invalid symbol "$string" should be rejected');
+}
+
+main() {
+ ['%', '&', '*', '+', '-', '/', '<', '<<', '<=', '==', '>',
+ '>=', '>>', '[]', '[]=', '^', 'unary-', '|', '~', '~/']
+ .forEach(validSymbol);
+
+ ['foo', '_bar', 'baz.quz', 'fisk1', 'hest2fisk', 'a.b.c.d.e',
+ '\$', 'foo\$', 'bar\$bar']
+ .forEach(validSymbol);
+
+ ['6', '0foo', ',', 'S with M', '_invalid&private']
+ .forEach(invalidSymbol);
+}
« no previous file with comments | « tests/lib/mirrors/private_symbol_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698