| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Basic test of Symbol class. | 5 // Basic test of Symbol class. |
| 6 | 6 |
| 7 main() { | 7 main() { |
| 8 var x; | 8 var x; |
| 9 print(x = const Symbol('fisk')); | 9 print(x = const Symbol('fisk')); |
| 10 try { | 10 try { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 print('Caught $e'); | 21 print('Caught $e'); |
| 22 } | 22 } |
| 23 | 23 |
| 24 try { | 24 try { |
| 25 print(const Symbol('_')); //# 03: compile-time error | 25 print(const Symbol('_')); //# 03: compile-time error |
| 26 } on ArgumentError catch (e) { | 26 } on ArgumentError catch (e) { |
| 27 print('Caught $e'); | 27 print('Caught $e'); |
| 28 } | 28 } |
| 29 | 29 |
| 30 try { | 30 try { |
| 31 var y = 0; | |
| 32 print(new Symbol(y)); //# 04: compile-time error | |
| 33 throw 'Expected a NoSuchMethodError or a TypeError'; //# 04: ok | |
| 34 } on NoSuchMethodError { | |
| 35 print('Caught NoSuchMethodError'); | |
| 36 } on TypeError { | |
| 37 print('Caught TypeError'); | |
| 38 } | |
| 39 | |
| 40 try { | |
| 41 print(new Symbol('0')); | 31 print(new Symbol('0')); |
| 42 throw 'Expected an ArgumentError'; | 32 throw 'Expected an ArgumentError'; |
| 43 } on ArgumentError catch (e) { | 33 } on ArgumentError catch (e) { |
| 44 print('Caught $e'); | 34 print('Caught $e'); |
| 45 } | 35 } |
| 46 | 36 |
| 47 try { | 37 try { |
| 48 print(new Symbol('_')); | 38 print(new Symbol('_')); |
| 49 throw 'Expected an ArgumentError'; | 39 throw 'Expected an ArgumentError'; |
| 50 } on ArgumentError catch (e) { | 40 } on ArgumentError catch (e) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 80 new Symbol('fisk').hashCode as int; | 70 new Symbol('fisk').hashCode as int; |
| 81 | 71 |
| 82 if (new Symbol('fisk').hashCode != x.hashCode) { | 72 if (new Symbol('fisk').hashCode != x.hashCode) { |
| 83 throw "non-const Symbol's hashCode not equal to its const equivalent"; | 73 throw "non-const Symbol's hashCode not equal to its const equivalent"; |
| 84 } | 74 } |
| 85 | 75 |
| 86 if (new Symbol('') != const Symbol('')) { | 76 if (new Symbol('') != const Symbol('')) { |
| 87 throw 'empty Symbol not equals to itself'; | 77 throw 'empty Symbol not equals to itself'; |
| 88 } | 78 } |
| 89 } | 79 } |
| OLD | NEW |