OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:io' as io; | 5 import 'dart:io' as io; |
6 | 6 |
7 import '../lib/shared_messages.dart'; | 7 import '../lib/shared_messages.dart'; |
8 | 8 |
9 void testJsonIsUpdated() { | 9 void testJsonIsUpdated() { |
10 var packageRoot = io.Platform.packageRoot; | 10 var packageRoot = io.Platform.packageRoot; |
(...skipping 15 matching lines...) Expand all Loading... |
26 void testIdsAreUnique() { | 26 void testIdsAreUnique() { |
27 var usedIds = new Set(); | 27 var usedIds = new Set(); |
28 for (var entry in MESSAGES.values) { | 28 for (var entry in MESSAGES.values) { |
29 var id = "${entry.id}-${entry.subId}"; | 29 var id = "${entry.id}-${entry.subId}"; |
30 if (!usedIds.add(id)) { | 30 if (!usedIds.add(id)) { |
31 throw "Id appears twice: $id"; | 31 throw "Id appears twice: $id"; |
32 } | 32 } |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
| 36 void testSpecializationsAreOfSameId() { |
| 37 for (var entry in MESSAGES.values) { |
| 38 var specializationOf = entry.specializationOf; |
| 39 if (specializationOf == null) continue; |
| 40 var generic = MESSAGES[specializationOf]; |
| 41 if (generic == null) { |
| 42 throw "More generic message doesn't exist: $specializationOf"; |
| 43 } |
| 44 if (generic.id != entry.id) { |
| 45 var id = "${entry.id}-${entry.subId}"; |
| 46 var genericId = "${generic.id}-${generic.subId}"; |
| 47 throw "Specialization doesn't have same id: $id - $genericId"; |
| 48 } |
| 49 } |
| 50 } |
| 51 |
36 void main() { | 52 void main() { |
37 testJsonIsUpdated(); | 53 testJsonIsUpdated(); |
38 testIdsAreUnique(); | 54 testIdsAreUnique(); |
| 55 testSpecializationsAreOfSameId(); |
39 } | 56 } |
OLD | NEW |