Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: pkg/polymer/test/build/unique_message_test.dart

Issue 513023002: Step one towards stable error messages with details: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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 /// Tests for some of the utility helper functions used by the compiler.
6 library polymer.test.build.messages_test;
7
8 import 'dart:mirrors';
9
10 import 'package:unittest/unittest.dart';
11 import 'package:code_transformers/messages/messages.dart' show Message;
12
13 import 'package:code_transformers/src/messages.dart' as p1;
14 import 'package:polymer/src/build/messages.dart' as p2;
15
16 /// [p1] and [p2] are accessed via mirrors, this comment prevents the analyzer
17 /// from complaining about it.
18 main() {
19 test('each message id is unique', () {
20 var seen = {};
21 int total = 0;
22 var mirrors = currentMirrorSystem();
23 _check(Symbol libName) {
24 var lib = mirrors.findLibrary(libName);
25 expect(lib, isNotNull);
26 lib.declarations.forEach((symbol, decl) {
27 if (decl is! VariableMirror) return;
28 var field = lib.getField(symbol).reflectee;
29 var name = MirrorSystem.getName(symbol);
30 if (field is! Message) return;
31 var id = field.id;
32 expect(seen.containsKey(id), isFalse, reason: 'Duplicate id `$id`. '
33 'Currently set for both `$name` and `${seen[id]}`.');
34 seen[id] = name;
35 total++;
36 });
37 }
38 _check(#polymer.src.build.messages);
39 _check(#code_transformers.src.messages);
40 expect(seen.length, total);
41 });
42 }
OLDNEW
« no previous file with comments | « pkg/polymer/test/build/script_compactor_test.dart ('k') | pkg/polymer/tool/create_message_details_page.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698