Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // 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.
| |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 notString() => const Symbol(0); | |
| 6 | |
| 7 notIdentifier() => const Symbol('0'); | |
| 8 | |
| 9 privateIdentifier() => const Symbol('_'); | |
| 10 | |
| 11 main() { | |
| 12 var x; | |
| 13 print(x = const Symbol('fisk')); | |
| 14 | |
| 15 try { | |
| 16 print(notString()); /// 01: compile-time error | |
| 17 } on ArgumentError { | |
| 18 print('Caught ArgumentError'); | |
| 19 } on TypeError { | |
| 20 print('Caught TypeError'); | |
| 21 } | |
| 22 | |
| 23 try { | |
| 24 print(notIdentifier()); /// 02: compile-time error | |
| 25 } on ArgumentError catch (e) { | |
| 26 print('Caught $e'); | |
| 27 } | |
| 28 | |
| 29 try { | |
| 30 print(privateIdentifier()); /// 03: compile-time error | |
| 31 } on ArgumentError catch (e) { | |
| 32 print('Caught $e'); | |
| 33 } | |
| 34 | |
| 35 try { | |
| 36 print(new Symbol(0)); | |
| 37 throw 'Expected an ArgumentError or a TypeError'; | |
| 38 } on ArgumentError { | |
| 39 print('Caught ArgumentError'); | |
| 40 } on TypeError { | |
| 41 print('Caught TypeError'); | |
| 42 } | |
| 43 | |
| 44 try { | |
| 45 print(new Symbol('0')); | |
| 46 throw 'Expected an ArgumentError'; | |
| 47 } on ArgumentError catch (e) { | |
| 48 print('Caught $e'); | |
| 49 } | |
| 50 | |
| 51 try { | |
| 52 print(new Symbol('_')); | |
| 53 throw 'Expected an ArgumentError'; | |
| 54 } on ArgumentError catch (e) { | |
| 55 print('Caught $e'); | |
| 56 } | |
| 57 | |
| 58 print(identical(const Symbol('fisk'), x)); | |
| 59 } | |
| OLD | NEW |