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

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: 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
« dart/sdk/lib/core/symbol.dart ('K') | « 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..4830d7c5d71d47c011fd093352f98f589aa54562
--- /dev/null
+++ b/dart/tests/corelib/symbol_test.dart
@@ -0,0 +1,59 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
kasperl 2013/04/11 10:48:58 2013
ahe 2013/04/11 11:26:06 Done.
+// 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'));
+
+ 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));
+}
« dart/sdk/lib/core/symbol.dart ('K') | « dart/tests/corelib/corelib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698