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

Unified Diff: sdk/lib/_internal/pub_generated/test/pubspec_test.dart

Issue 887223007: Revert "Use native async/await support in pub." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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: sdk/lib/_internal/pub_generated/test/pubspec_test.dart
diff --git a/sdk/lib/_internal/pub/test/pubspec_test.dart b/sdk/lib/_internal/pub_generated/test/pubspec_test.dart
similarity index 78%
copy from sdk/lib/_internal/pub/test/pubspec_test.dart
copy to sdk/lib/_internal/pub_generated/test/pubspec_test.dart
index 4fddbd41d5182e72cfdb604e848d7a5135913f0d..1418bf9bbfede1d9d5d46b7a5395d1efbcdc3584 100644
--- a/sdk/lib/_internal/pub/test/pubspec_test.dart
+++ b/sdk/lib/_internal/pub_generated/test/pubspec_test.dart
@@ -19,17 +19,17 @@ import 'test_pub.dart';
class MockSource extends Source {
final String name = "mock";
- Future<Pubspec> doDescribe(PackageId id) => throw new UnsupportedError(
- "Cannot describe mock packages.");
+ Future<Pubspec> doDescribe(PackageId id) =>
+ throw new UnsupportedError("Cannot describe mock packages.");
- Future get(PackageId id, String symlink) => throw new UnsupportedError(
- "Cannot get a mock package.");
+ Future get(PackageId id, String symlink) =>
+ throw new UnsupportedError("Cannot get a mock package.");
- Future<String> getDirectory(PackageId id) => throw new UnsupportedError(
- "Cannot get the directory for mock packages.");
+ Future<String> getDirectory(PackageId id) =>
+ throw new UnsupportedError("Cannot get the directory for mock packages.");
- dynamic parseDescription(String filePath, description,
- {bool fromLockFile: false}) {
+ dynamic parseDescription(String filePath, description, {bool fromLockFile:
+ false}) {
if (description != 'ok') throw new FormatException('Bad');
return description;
}
@@ -48,15 +48,16 @@ main() {
sources.register(new PathSource());
var throwsPubspecException =
- throwsA(new isInstanceOf<PubspecException>('PubspecException'));
+ throwsA(new isInstanceOf<PubspecException>('PubspecException'));
expectPubspecException(String contents, fn(Pubspec pubspec),
[String expectedContains]) {
var expectation = throwsPubspecException;
if (expectedContains != null) {
- expectation = throwsA(allOf(
- new isInstanceOf<PubspecException>('PubspecException'),
- predicate((error) => error.message.contains(expectedContains))));
+ expectation = throwsA(
+ allOf(
+ new isInstanceOf<PubspecException>('PubspecException'),
+ predicate((error) => error.message.contains(expectedContains))));
}
var pubspec = new Pubspec.parse(contents, sources);
@@ -68,15 +69,21 @@ main() {
new Pubspec.parse('version: not a semver', sources);
});
- test("eagerly throws an error if the pubspec name doesn't match the "
- "expected name", () {
- expect(() => new Pubspec.parse("name: foo", sources, expectedName: 'bar'),
+ test(
+ "eagerly throws an error if the pubspec name doesn't match the "
+ "expected name",
+ () {
+ expect(
+ () => new Pubspec.parse("name: foo", sources, expectedName: 'bar'),
throwsPubspecException);
});
- test("eagerly throws an error if the pubspec doesn't have a name and an "
- "expected name is passed", () {
- expect(() => new Pubspec.parse("{}", sources, expectedName: 'bar'),
+ test(
+ "eagerly throws an error if the pubspec doesn't have a name and an "
+ "expected name is passed",
+ () {
+ expect(
+ () => new Pubspec.parse("{}", sources, expectedName: 'bar'),
throwsPubspecException);
});
@@ -231,55 +238,65 @@ dependencies:
});
test("throws if 'name' is not a string", () {
- expectPubspecException('name: [not, a, string]',
+ expectPubspecException(
+ 'name: [not, a, string]',
(pubspec) => pubspec.name);
});
test("throws if version is not a string", () {
- expectPubspecException('version: [2, 0, 0]',
+ expectPubspecException(
+ 'version: [2, 0, 0]',
(pubspec) => pubspec.version,
'"version" field must be a string');
});
test("throws if version is malformed (looking like a double)", () {
- expectPubspecException('version: 2.1',
+ expectPubspecException(
+ 'version: 2.1',
(pubspec) => pubspec.version,
'"version" field must have three numeric components: major, minor, '
- 'and patch. Instead of "2.1", consider "2.1.0"');
+ 'and patch. Instead of "2.1", consider "2.1.0"');
});
test("throws if version is malformed (looking like an int)", () {
- expectPubspecException('version: 2',
+ expectPubspecException(
+ 'version: 2',
(pubspec) => pubspec.version,
'"version" field must have three numeric components: major, minor, '
- 'and patch. Instead of "2", consider "2.0.0"');
+ 'and patch. Instead of "2", consider "2.0.0"');
});
test("throws if version is not a version", () {
- expectPubspecException('version: not version',
+ expectPubspecException(
+ 'version: not version',
(pubspec) => pubspec.version);
});
test("throws if transformers isn't a list", () {
- expectPubspecException('transformers: "not list"',
+ expectPubspecException(
+ 'transformers: "not list"',
(pubspec) => pubspec.transformers,
'"transformers" field must be a list');
});
test("throws if a transformer isn't a string or map", () {
- expectPubspecException('transformers: [12]',
+ expectPubspecException(
+ 'transformers: [12]',
(pubspec) => pubspec.transformers,
'A transformer must be a string or map.');
});
test("throws if a transformer's configuration isn't a map", () {
- expectPubspecException('transformers: [{pkg: 12}]',
+ expectPubspecException(
+ 'transformers: [{pkg: 12}]',
(pubspec) => pubspec.transformers,
"A transformer's configuration must be a map.");
});
- test("throws if a transformer's configuration contains an unknown "
- "reserved key at the top level", () {
+ test(
+ "throws if a transformer's configuration contains an unknown "
+ "reserved key at the top level",
+ () {
expectPubspecException('''
name: pkg
transformers: [{pkg: {\$key: "value"}}]''',
@@ -287,8 +304,10 @@ transformers: [{pkg: {\$key: "value"}}]''',
'Invalid transformer config: Unknown reserved field.');
});
- test("doesn't throw if a transformer's configuration contains a "
- "non-top-level key beginning with a dollar sign", () {
+ test(
+ "doesn't throw if a transformer's configuration contains a "
+ "non-top-level key beginning with a dollar sign",
+ () {
var pubspec = new Pubspec.parse('''
name: pkg
transformers:
@@ -305,8 +324,7 @@ name: pkg
transformers:
- pkg: {\$include: 123}''',
(pubspec) => pubspec.transformers,
- 'Invalid transformer config: "\$include" field must be a string or '
- 'list.');
+ 'Invalid transformer config: "\$include" field must be a string or ' 'list.');
});
test("throws if the \$include list contains a non-string", () {
@@ -314,9 +332,8 @@ transformers:
name: pkg
transformers:
- pkg: {\$include: ["ok", 123, "alright", null]}''',
- (pubspec) => pubspec.transformers,
- 'Invalid transformer config: "\$include" field may contain only '
- 'strings.');
+ (pubspec) => pubspec.transformers,
+ 'Invalid transformer config: "\$include" field may contain only ' 'strings.');
});
test("throws if the \$exclude value is not a string or list", () {
@@ -324,9 +341,8 @@ transformers:
name: pkg
transformers:
- pkg: {\$exclude: 123}''',
- (pubspec) => pubspec.transformers,
- 'Invalid transformer config: "\$exclude" field must be a string or '
- 'list.');
+ (pubspec) => pubspec.transformers,
+ 'Invalid transformer config: "\$exclude" field must be a string or ' 'list.');
});
test("throws if the \$exclude list contains a non-string", () {
@@ -334,18 +350,15 @@ transformers:
name: pkg
transformers:
- pkg: {\$exclude: ["ok", 123, "alright", null]}''',
- (pubspec) => pubspec.transformers,
- 'Invalid transformer config: "\$exclude" field may contain only '
- 'strings.');
+ (pubspec) => pubspec.transformers,
+ 'Invalid transformer config: "\$exclude" field may contain only ' 'strings.');
});
test("throws if a transformer is not from a dependency", () {
expectPubspecException('''
name: pkg
transformers: [foo]
-''',
- (pubspec) => pubspec.transformers,
- '"foo" is not a dependency.');
+''', (pubspec) => pubspec.transformers, '"foo" is not a dependency.');
});
test("allows a transformer from a normal dependency", () {
@@ -400,9 +413,9 @@ transformers:
name: pkg
dependencies:
from_path: {path: non_local_path}
-''', (pubspec) => pubspec.dependencies,
- '"non_local_path" is a relative path, but this isn\'t a local '
- 'pubspec.');
+''',
+ (pubspec) => pubspec.dependencies,
+ '"non_local_path" is a relative path, but this isn\'t a local ' 'pubspec.');
});
group("environment", () {
@@ -419,7 +432,8 @@ environment:
});
test("throws if the environment value isn't a map", () {
- expectPubspecException('environment: []',
+ expectPubspecException(
+ 'environment: []',
(pubspec) => pubspec.environment);
});
@@ -428,19 +442,23 @@ environment:
environment:
sdk: ">=1.2.3 <2.3.4"
''', sources);
- expect(pubspec.environment.sdkVersion,
+ expect(
+ pubspec.environment.sdkVersion,
equals(new VersionConstraint.parse(">=1.2.3 <2.3.4")));
});
test("throws if the sdk isn't a string", () {
- expectPubspecException('environment: {sdk: []}',
+ expectPubspecException(
+ 'environment: {sdk: []}',
(pubspec) => pubspec.environment);
- expectPubspecException('environment: {sdk: 1.0}',
+ expectPubspecException(
+ 'environment: {sdk: 1.0}',
(pubspec) => pubspec.environment);
});
test("throws if the sdk isn't a valid version constraint", () {
- expectPubspecException('environment: {sdk: "oopies"}',
+ expectPubspecException(
+ 'environment: {sdk: "oopies"}',
(pubspec) => pubspec.environment);
});
});
@@ -452,7 +470,8 @@ environment:
});
test("throws if not a string", () {
- expectPubspecException('publish_to: 123',
+ expectPubspecException(
+ 'publish_to: 123',
(pubspec) => pubspec.publishTo);
});
@@ -471,7 +490,8 @@ publish_to: none
});
test("throws on other strings", () {
- expectPubspecException('publish_to: http://bad.url:not-port',
+ expectPubspecException(
+ 'publish_to: http://bad.url:not-port',
(pubspec) => pubspec.publishTo);
});
});
@@ -491,32 +511,38 @@ executables:
});
test("throws if not a map", () {
- expectPubspecException('executables: not map',
+ expectPubspecException(
+ 'executables: not map',
(pubspec) => pubspec.executables);
});
test("throws if key is not a string", () {
- expectPubspecException('executables: {123: value}',
+ expectPubspecException(
+ 'executables: {123: value}',
(pubspec) => pubspec.executables);
});
test("throws if a key isn't a simple name", () {
- expectPubspecException('executables: {funny/name: ok}',
+ expectPubspecException(
+ 'executables: {funny/name: ok}',
(pubspec) => pubspec.executables);
});
test("throws if a value is not a string", () {
- expectPubspecException('executables: {command: 123}',
+ expectPubspecException(
+ 'executables: {command: 123}',
(pubspec) => pubspec.executables);
});
test("throws if a value contains a path separator", () {
- expectPubspecException('executables: {command: funny_name/part}',
+ expectPubspecException(
+ 'executables: {command: funny_name/part}',
(pubspec) => pubspec.executables);
});
test("throws if a value contains a windows path separator", () {
- expectPubspecException(r'executables: {command: funny_name\part}',
+ expectPubspecException(
+ r'executables: {command: funny_name\part}',
(pubspec) => pubspec.executables);
});

Powered by Google App Engine
This is Rietveld 408576698