Files
sdk/pkg/code_transformers/test/unique_message_test.dart
T
sigmund@google.com 1781d2cb42 Step one towards stable error messages with details:
- switches polymer to use a messages type
 - autogenerates an HTML page from the message list.
 - use these messages on polymer transformers
 - moves build_logger to code_Transformers, so we can also use this in other packages.

Still pending to do more, for example, find a permanent location and URI scheme for messages
so we can show them on the command-line, improve the UI to tak advantage of clustering, etc.

But I think it's good enough to get it in and iterate afterwards

R=jakemac@google.com, kathyw@google.com

Review URL: https://codereview.chromium.org//513023002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39884 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-04 20:28:15 +00:00

38 lines
1.3 KiB
Dart

// 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;
/// [p1] is 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();
var lib = mirrors.findLibrary(#code_transformers.src.messages);
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++;
});
expect(seen.length, total);
});
}