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 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 try { | 25 try { |
26 print(const Symbol('_')); //# 03: compile-time error | 26 print(const Symbol('_')); //# 03: compile-time error |
27 } on ArgumentError catch (e) { | 27 } on ArgumentError catch (e) { |
28 print('Caught $e'); | 28 print('Caught $e'); |
29 } | 29 } |
30 | 30 |
31 try { | 31 try { |
32 var y = 0; | 32 var y = 0; |
33 print(new Symbol(y)); | 33 print(new Symbol(y)); //# 04: compile-time error |
34 throw 'Expected a NoSuchMethodError or a TypeError'; | 34 throw 'Expected a NoSuchMethodError or a TypeError'; |
35 } on NoSuchMethodError { | 35 } on NoSuchMethodError { |
36 print('Caught NoSuchMethodError'); | 36 print('Caught NoSuchMethodError'); |
37 } on TypeError { | 37 } on TypeError { |
38 print('Caught TypeError'); | 38 print('Caught TypeError'); |
39 } | 39 } |
40 | 40 |
41 try { | 41 try { |
42 print(new Symbol('0')); | 42 print(new Symbol('0')); |
43 throw 'Expected an ArgumentError'; | 43 throw 'Expected an ArgumentError'; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 new Symbol('fisk').hashCode as int; | 81 new Symbol('fisk').hashCode as int; |
82 | 82 |
83 if (new Symbol('fisk').hashCode != x.hashCode) { | 83 if (new Symbol('fisk').hashCode != x.hashCode) { |
84 throw "non-const Symbol's hashCode not equal to its const equivalent"; | 84 throw "non-const Symbol's hashCode not equal to its const equivalent"; |
85 } | 85 } |
86 | 86 |
87 if (new Symbol('') != const Symbol('')) { | 87 if (new Symbol('') != const Symbol('')) { |
88 throw 'empty Symbol not equals to itself'; | 88 throw 'empty Symbol not equals to itself'; |
89 } | 89 } |
90 } | 90 } |
OLD | NEW |