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