Skip to content
Snippets Groups Projects
Commit fb3f374d authored by nweiz@google.com's avatar nweiz@google.com Committed by Natalie Weizenbaum
Browse files

Add a reserved namespace (himBHinitial identifiers) for transformer configuration.

R=rnystrom@google.com
BUG=14636

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge@30007 260f80e4-7a28-3924-810f-c04153c831b5
parent 2bc25fa8
No related branches found
No related tags found
No related merge requests found
......@@ -150,6 +150,15 @@ class Pubspec {
_error('"$field.$library" field must be a map, but was '
'"$configuration".');
}
var reservedKeys = configuration.keys
.where((key) => key is String && key.startsWith(r'$'))
.map((key) => '"$key"');
if (reservedKeys.isNotEmpty) {
_error('"$field.$library" field cannot contain reserved '
'${pluralize('field', reservedKeys.length)} '
'${toSentence(reservedKeys)}.');
}
}
var id = _wrapFormatException("transformer identifier",
......
......@@ -195,6 +195,18 @@ dependencies:
(pubspec) => pubspec.transformers);
});
test("throws if a transformer's configuration contains a top-level key "
"beginning with a dollar sign", () {
expectPubspecException('transformers: {pkg: {\$key: value}}',
(pubspec) => pubspec.transformers);
});
test("doesn't throw if a transformer's configuration contains a "
"non-top-level key beginning with a dollar sign", () {
expectPubspecException('transformers: {pkg: {\$key: value}}',
(pubspec) => pubspec.transformers);
});
test("allows comment-only files", () {
var pubspec = new Pubspec.parse('''
# No external dependencies yet
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment