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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/polymer/test/build/unique_message_test.dart
diff --git a/pkg/polymer/test/build/unique_message_test.dart b/pkg/polymer/test/build/unique_message_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3a69834de7230d04446f24113c2ffd215bce9a97
--- /dev/null
+++ b/pkg/polymer/test/build/unique_message_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// Tests for some of the utility helper functions used by the compiler.
+library polymer.test.build.messages_test;
+
+import 'dart:mirrors';
+
+import 'package:unittest/unittest.dart';
+import 'package:code_transformers/messages/messages.dart' show Message;
+
+import 'package:code_transformers/src/messages.dart' as p1;
+import 'package:polymer/src/build/messages.dart' as p2;
+
+/// [p1] and [p2] are accessed via mirrors, this comment prevents the analyzer
+/// from complaining about it.
+main() {
+ test('each message id is unique', () {
+ var seen = {};
+ int total = 0;
+ var mirrors = currentMirrorSystem();
+ _check(Symbol libName) {
+ var lib = mirrors.findLibrary(libName);
+ expect(lib, isNotNull);
+ lib.declarations.forEach((symbol, decl) {
+ if (decl is! VariableMirror) return;
+ var field = lib.getField(symbol).reflectee;
+ var name = MirrorSystem.getName(symbol);
+ if (field is! Message) return;
+ var id = field.id;
+ expect(seen.containsKey(id), isFalse, reason: 'Duplicate id `$id`. '
+ 'Currently set for both `$name` and `${seen[id]}`.');
+ seen[id] = name;
+ total++;
+ });
+ }
+ _check(#polymer.src.build.messages);
+ _check(#code_transformers.src.messages);
+ expect(seen.length, total);
+ });
+}
« 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