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

Unified Diff: dart/tests/corelib/symbol_test.dart

Issue 14142003: Add Symbol class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix year Created 7 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 | « dart/tests/corelib/corelib.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/corelib/symbol_test.dart
diff --git a/dart/tests/corelib/symbol_test.dart b/dart/tests/corelib/symbol_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..53387a2a465d2ec1bbf66f311897e7592f35380b
--- /dev/null
+++ b/dart/tests/corelib/symbol_test.dart
@@ -0,0 +1,59 @@
+// 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.
+
+notString() => const Symbol(0);
+
+notIdentifier() => const Symbol('0');
+
+privateIdentifier() => const Symbol('_');
+
+main() {
+ var x;
+ print(x = const Symbol('fisk'));
kasperl 2013/04/11 10:48:58 Maybe turn x into a list of symbols and check more
+
+ try {
+ print(notString()); /// 01: compile-time error
+ } on ArgumentError {
+ print('Caught ArgumentError');
+ } on TypeError {
+ print('Caught TypeError');
+ }
+
+ try {
+ print(notIdentifier()); /// 02: compile-time error
+ } on ArgumentError catch (e) {
+ print('Caught $e');
+ }
+
+ try {
+ print(privateIdentifier()); /// 03: compile-time error
+ } on ArgumentError catch (e) {
+ print('Caught $e');
+ }
+
+ try {
+ print(new Symbol(0));
+ throw 'Expected an ArgumentError or a TypeError';
+ } on ArgumentError {
+ print('Caught ArgumentError');
+ } on TypeError {
+ print('Caught TypeError');
+ }
+
+ try {
+ print(new Symbol('0'));
+ throw 'Expected an ArgumentError';
+ } on ArgumentError catch (e) {
+ print('Caught $e');
+ }
+
+ try {
+ print(new Symbol('_'));
+ throw 'Expected an ArgumentError';
+ } on ArgumentError catch (e) {
+ print('Caught $e');
+ }
+
+ print(identical(const Symbol('fisk'), x));
+}
« no previous file with comments | « dart/tests/corelib/corelib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698