| 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 library test.immutable_collections; | 5 library test.immutable_collections; |
| 6 | 6 |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
| 9 | 9 |
| 10 someException(e) => e is Exception || e is Error; | 10 someException(e) => e is Exception || e is Error; |
| 11 | 11 |
| 12 checkList(Iterable l, String reason) { | 12 checkList(Iterable l, String reason) { |
| 13 Expect.throws(() => l[0] = 'value', someException, reason); | 13 Expect.throws(() => l[0] = 'value', someException, reason); /// static type w
arning |
| 14 Expect.throws(() => l.add('value'), someException, reason); | 14 Expect.throws(() => l.add('value'), someException, reason); /// static type w
arning |
| 15 Expect.throws(() => l.clear(), someException, reason); | 15 Expect.throws(() => l.clear(), someException, reason); /// static type warnin
g |
| 16 } | 16 } |
| 17 | 17 |
| 18 checkMap(Map m, String reason) { | 18 checkMap(Map m, String reason) { |
| 19 Expect.throws(() => m[#key] = 'value', someException, reason); | 19 Expect.throws(() => m[#key] = 'value', someException, reason); |
| 20 checkList(m.keys, '$reason keys'); | 20 checkList(m.keys, '$reason keys'); |
| 21 checkList(m.values, '$reason values'); | 21 checkList(m.values, '$reason values'); |
| 22 } | 22 } |
| 23 | 23 |
| 24 checkVariable(VariableMirror vm) { | 24 checkVariable(VariableMirror vm) { |
| 25 checkList(vm.metadata, 'VariableMirror.metadata'); | 25 checkList(vm.metadata, 'VariableMirror.metadata'); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 lm.getters.values.forEach(checkMethod); | 80 lm.getters.values.forEach(checkMethod); |
| 81 lm.setters.values.forEach(checkMethod); | 81 lm.setters.values.forEach(checkMethod); |
| 82 lm.variables.values.forEach(checkVariable); | 82 lm.variables.values.forEach(checkVariable); |
| 83 } | 83 } |
| 84 | 84 |
| 85 main() { | 85 main() { |
| 86 currentMirrorSystem().libraries.values.forEach(checkLibrary); | 86 currentMirrorSystem().libraries.values.forEach(checkLibrary); |
| 87 checkType(currentMirrorSystem().voidType); | 87 checkType(currentMirrorSystem().voidType); |
| 88 checkType(currentMirrorSystem().dynamicType); | 88 checkType(currentMirrorSystem().dynamicType); |
| 89 } | 89 } |
| OLD | NEW |