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

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

Issue 557563002: Store the async-await compiled pub code directly in the repo. (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: 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 e34ce431c0d2dca1bc1c859c4d3f1d7fe5b1fd4c..1f308d046ceed93093463799151387cc97c4dd62 100644
--- a/sdk/lib/_internal/pub/test/pubspec_test.dart
+++ b/sdk/lib/_internal/pub_generated/test/pubspec_test.dart
@@ -1,83 +1,67 @@
-// Copyright (c) 2012, 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.
-
library pubspec_test;
-
import 'dart:async';
-
import 'package:unittest/unittest.dart';
-
import '../lib/src/package.dart';
import '../lib/src/pubspec.dart';
import '../lib/src/source.dart';
import '../lib/src/source_registry.dart';
import '../lib/src/version.dart';
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 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.");
-
- dynamic parseDescription(String filePath, description,
- {bool fromLockFile: false}) {
+ 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<String> getDirectory(PackageId id) =>
+ throw new UnsupportedError("Cannot get the directory for mock packages.");
+ dynamic parseDescription(String filePath, description, {bool fromLockFile:
+ false}) {
if (description != 'ok') throw new FormatException('Bad');
return description;
}
-
bool descriptionsEqual(description1, description2) =>
description1 == description2;
-
String packageName(description) => 'foo';
}
-
main() {
initConfig();
group('parse()', () {
var sources = new SourceRegistry();
sources.register(new MockSource());
-
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);
expect(() => fn(pubspec), expectation);
}
-
test("doesn't eagerly throw an error for an invalid field", () {
- // Shouldn't throw an error.
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);
});
-
test("allows a version constraint for dependencies", () {
var pubspec = new Pubspec.parse('''
dependencies:
@@ -85,22 +69,18 @@ dependencies:
mock: ok
version: ">=1.2.3 <3.4.5"
''', sources);
-
var foo = pubspec.dependencies[0];
expect(foo.name, equals('foo'));
expect(foo.constraint.allows(new Version(1, 2, 3)), isTrue);
expect(foo.constraint.allows(new Version(1, 2, 5)), isTrue);
expect(foo.constraint.allows(new Version(3, 4, 5)), isFalse);
});
-
test("allows an empty dependencies map", () {
var pubspec = new Pubspec.parse('''
dependencies:
''', sources);
-
expect(pubspec.dependencies, isEmpty);
});
-
test("allows a version constraint for dev dependencies", () {
var pubspec = new Pubspec.parse('''
dev_dependencies:
@@ -108,22 +88,18 @@ dev_dependencies:
mock: ok
version: ">=1.2.3 <3.4.5"
''', sources);
-
var foo = pubspec.devDependencies[0];
expect(foo.name, equals('foo'));
expect(foo.constraint.allows(new Version(1, 2, 3)), isTrue);
expect(foo.constraint.allows(new Version(1, 2, 5)), isTrue);
expect(foo.constraint.allows(new Version(3, 4, 5)), isFalse);
});
-
test("allows an empty dev dependencies map", () {
var pubspec = new Pubspec.parse('''
dev_dependencies:
''', sources);
-
expect(pubspec.devDependencies, isEmpty);
});
-
test("allows a version constraint for dependency overrides", () {
var pubspec = new Pubspec.parse('''
dependency_overrides:
@@ -131,34 +107,28 @@ dependency_overrides:
mock: ok
version: ">=1.2.3 <3.4.5"
''', sources);
-
var foo = pubspec.dependencyOverrides[0];
expect(foo.name, equals('foo'));
expect(foo.constraint.allows(new Version(1, 2, 3)), isTrue);
expect(foo.constraint.allows(new Version(1, 2, 5)), isTrue);
expect(foo.constraint.allows(new Version(3, 4, 5)), isFalse);
});
-
test("allows an empty dependency overrides map", () {
var pubspec = new Pubspec.parse('''
dependency_overrides:
''', sources);
-
expect(pubspec.dependencyOverrides, isEmpty);
});
-
test("allows an unknown source", () {
var pubspec = new Pubspec.parse('''
dependencies:
foo:
unknown: blah
''', sources);
-
var foo = pubspec.dependencies[0];
expect(foo.name, equals('foo'));
expect(foo.source, equals('unknown'));
});
-
test("throws if a package is in dependencies and dev_dependencies", () {
var contents = '''
dependencies:
@@ -171,7 +141,6 @@ dev_dependencies:
expectPubspecException(contents, (pubspec) => pubspec.dependencies);
expectPubspecException(contents, (pubspec) => pubspec.devDependencies);
});
-
test("throws if it dependes on itself", () {
expectPubspecException('''
name: myapp
@@ -180,7 +149,6 @@ dependencies:
mock: ok
''', (pubspec) => pubspec.dependencies);
});
-
test("throws if it has a dev dependency on itself", () {
expectPubspecException('''
name: myapp
@@ -189,7 +157,6 @@ dev_dependencies:
mock: ok
''', (pubspec) => pubspec.devDependencies);
});
-
test("throws if it has an override on itself", () {
expectPubspecException('''
name: myapp
@@ -198,7 +165,6 @@ dependency_overrides:
mock: ok
''', (pubspec) => pubspec.dependencyOverrides);
});
-
test("throws if the description isn't valid", () {
expectPubspecException('''
dependencies:
@@ -206,7 +172,6 @@ dependencies:
mock: bad
''', (pubspec) => pubspec.dependencies);
});
-
test("throws if dependency version is not a string", () {
expectPubspecException('''
dependencies:
@@ -215,7 +180,6 @@ dependencies:
version: 1.2
''', (pubspec) => pubspec.dependencies);
});
-
test("throws if version is not a version constraint", () {
expectPubspecException('''
dependencies:
@@ -224,109 +188,97 @@ dependencies:
version: not constraint
''', (pubspec) => pubspec.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: 1.0', (pubspec) => pubspec.version);
});
-
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"}}]''',
(pubspec) => pubspec.transformers,
'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:
- pkg: {outer: {\$inner: value}}
''', sources);
-
var pkg = pubspec.transformers[0].single;
expect(pkg.configuration["outer"]["\$inner"], equals("value"));
});
-
test("throws if the \$include value is not a string or list", () {
expectPubspecException('''
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", () {
expectPubspecException('''
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", () {
expectPubspecException('''
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", () {
expectPubspecException('''
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", () {
var pubspec = new Pubspec.parse('''
name: pkg
@@ -335,10 +287,8 @@ dependencies:
mock: ok
transformers:
- foo''', sources);
-
expect(pubspec.transformers[0].single.id.package, equals("foo"));
});
-
test("allows a transformer from a dev dependency", () {
var pubspec = new Pubspec.parse('''
name: pkg
@@ -347,10 +297,8 @@ dev_dependencies:
mock: ok
transformers:
- foo''', sources);
-
expect(pubspec.transformers[0].single.id.package, equals("foo"));
});
-
test("allows a transformer from a dependency override", () {
var pubspec = new Pubspec.parse('''
name: pkg
@@ -359,10 +307,8 @@ dependency_overrides:
mock: ok
transformers:
- foo''', sources);
-
expect(pubspec.transformers[0].single.id.package, equals("foo"));
});
-
test("allows comment-only files", () {
var pubspec = new Pubspec.parse('''
# No external dependencies yet
@@ -373,74 +319,70 @@ transformers:
expect(pubspec.version, equals(Version.none));
expect(pubspec.dependencies, isEmpty);
});
-
group("environment", () {
test("defaults to any SDK constraint if environment is omitted", () {
var pubspec = new Pubspec.parse('', sources);
expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any));
});
-
test("allows an empty environment map", () {
var pubspec = new Pubspec.parse('''
environment:
''', sources);
expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any));
});
-
test("throws if the environment value isn't a map", () {
- expectPubspecException('environment: []',
+ expectPubspecException(
+ 'environment: []',
(pubspec) => pubspec.environment);
});
-
test("allows a version constraint for the sdk", () {
var pubspec = new Pubspec.parse('''
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);
});
});
-
group("publishTo", () {
test("defaults to null if omitted", () {
var pubspec = new Pubspec.parse('', sources);
expect(pubspec.publishTo, isNull);
});
-
test("throws if not a string", () {
- expectPubspecException('publish_to: 123',
+ expectPubspecException(
+ 'publish_to: 123',
(pubspec) => pubspec.publishTo);
});
-
test("allows a URL", () {
var pubspec = new Pubspec.parse('''
publish_to: http://example.com
''', sources);
expect(pubspec.publishTo, equals("http://example.com"));
});
-
test("allows none", () {
var pubspec = new Pubspec.parse('''
publish_to: none
''', sources);
expect(pubspec.publishTo, equals("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);
});
});

Powered by Google App Engine
This is Rietveld 408576698