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)); |
+} |