dartfmt
diff --git a/lib/src/authentication_challenge.dart b/lib/src/authentication_challenge.dart
index 66841b4..17955df 100644
--- a/lib/src/authentication_challenge.dart
+++ b/lib/src/authentication_challenge.dart
@@ -73,9 +73,9 @@
if (scanner.scan(token)) {
params[name] = scanner.lastMatch[0];
- } else {
- params[name] = expectQuotedString(
- scanner, name: "a token or a quoted string");
+ } else {
+ params[name] =
+ expectQuotedString(scanner, name: "a token or a quoted string");
}
scanner.scan(whitespace);
@@ -136,9 +136,9 @@
if (scanner.scan(token)) {
params[name] = scanner.lastMatch[0];
- } else {
- params[name] = expectQuotedString(
- scanner, name: "a token or a quoted string");
+ } else {
+ params[name] =
+ expectQuotedString(scanner, name: "a token or a quoted string");
}
scanner.scan(whitespace);
@@ -146,6 +146,6 @@
/// Creates a new challenge value with [scheme] and [parameters].
AuthenticationChallenge(this.scheme, Map<String, String> parameters)
- : parameters = new UnmodifiableMapView(
- new CaseInsensitiveMap.from(parameters));
+ : parameters =
+ new UnmodifiableMapView(new CaseInsensitiveMap.from(parameters));
}
diff --git a/lib/src/chunked_coding/decoder.dart b/lib/src/chunked_coding/decoder.dart
index 18530bc..3ffa520 100644
--- a/lib/src/chunked_coding/decoder.dart
+++ b/lib/src/chunked_coding/decoder.dart
@@ -21,8 +21,7 @@
var output = sink._decode(bytes, 0, bytes.length);
if (sink._state == _State.end) return output;
- throw new FormatException(
- "Input ended unexpectedly.", bytes, bytes.length);
+ throw new FormatException("Input ended unexpectedly.", bytes, bytes.length);
}
ByteConversionSink startChunkedConversion(Sink<List<int>> sink) =>
@@ -167,7 +166,8 @@
throw new FormatException(
"Invalid hexadecimal byte 0x${byte.toRadixString(16).toUpperCase()}.",
- bytes, index);
+ bytes,
+ index);
}
}
diff --git a/lib/src/http_date.dart b/lib/src/http_date.dart
index 8751b78..299f9e9 100644
--- a/lib/src/http_date.dart
+++ b/lib/src/http_date.dart
@@ -7,8 +7,20 @@
import 'utils.dart';
const _WEEKDAYS = const ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
-const _MONTHS = const ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
- "Sep", "Oct", "Nov", "Dec"];
+const _MONTHS = const [
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec"
+];
final _shortWeekdayRegExp = new RegExp(r"Mon|Tue|Wed|Thu|Fri|Sat|Sun");
final _longWeekdayRegExp =
diff --git a/lib/src/media_type.dart b/lib/src/media_type.dart
index 37dd6be..22283d6 100644
--- a/lib/src/media_type.dart
+++ b/lib/src/media_type.dart
@@ -21,12 +21,12 @@
class MediaType {
/// The primary identifier of the MIME type.
///
- /// This is always lowercase.
+ /// This is always lowercase.
final String type;
/// The secondary identifier of the MIME type.
///
- /// This is always lowercase.
+ /// This is always lowercase.
final String subtype;
/// The parameters to the media type.
@@ -91,8 +91,12 @@
/// [parameters] overwrites and adds to the corresponding field. If
/// [clearParameters] is passed, it replaces the corresponding field entirely
/// instead.
- MediaType change({String type, String subtype, String mimeType,
- Map<String, String> parameters, bool clearParameters: false}) {
+ MediaType change(
+ {String type,
+ String subtype,
+ String mimeType,
+ Map<String, String> parameters,
+ bool clearParameters: false}) {
if (mimeType != null) {
if (type != null) {
throw new ArgumentError("You may not pass both [type] and [mimeType].");
@@ -127,10 +131,7 @@
///
/// This will produce a valid HTTP media type.
String toString() {
- var buffer = new StringBuffer()
- ..write(type)
- ..write("/")
- ..write(subtype);
+ var buffer = new StringBuffer()..write(type)..write("/")..write(subtype);
parameters.forEach((attribute, value) {
buffer.write("; $attribute=");
diff --git a/lib/src/scan.dart b/lib/src/scan.dart
index 9af8428..6ba7a72 100644
--- a/lib/src/scan.dart
+++ b/lib/src/scan.dart
@@ -38,7 +38,7 @@
/// Once this is finished, [scanner] will be at the next non-LWS character in
/// the string, or the end of the string.
List/*<T>*/ parseList/*<T>*/(StringScanner scanner, /*=T*/ parseElement()) {
- var result = /*<T>*/[];
+ var result = /*<T>*/ [];
// Consume initial empty values.
while (scanner.scan(",")) {
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 79ce448..3bc6b66 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -16,8 +16,6 @@
'Invalid $name: ${error.message}', error.span, error.source);
} on FormatException catch (error) {
throw new FormatException(
- 'Invalid $name "$value": ${error.message}',
- error.source,
- error.offset);
+ 'Invalid $name "$value": ${error.message}', error.source, error.offset);
}
}
diff --git a/test/authentication_challenge_test.dart b/test/authentication_challenge_test.dart
index 4be4444..b647807 100644
--- a/test/authentication_challenge_test.dart
+++ b/test/authentication_challenge_test.dart
@@ -21,8 +21,8 @@
});
test("parses multiple challenges", () {
- var challenges = AuthenticationChallenge.parseHeader(
- "scheme1 realm=fblthp, scheme2 realm=asdfg");
+ var challenges = AuthenticationChallenge
+ .parseHeader("scheme1 realm=fblthp, scheme2 realm=asdfg");
expect(challenges, hasLength(2));
expect(challenges.first.scheme, equals("scheme1"));
expect(challenges.first.parameters, equals({"realm": "fblthp"}));
@@ -36,16 +36,12 @@
expect(challenges, hasLength(2));
expect(challenges.first.scheme, equals("scheme1"));
- expect(challenges.first.parameters, equals({
- "realm": "fblthp",
- "foo": "bar"
- }));
+ expect(challenges.first.parameters,
+ equals({"realm": "fblthp", "foo": "bar"}));
expect(challenges.last.scheme, equals("scheme2"));
- expect(challenges.last.parameters, equals({
- "realm": "asdfg",
- "baz": "bang"
- }));
+ expect(challenges.last.parameters,
+ equals({"realm": "asdfg", "baz": "bang"}));
});
});
}
@@ -66,20 +62,15 @@
test("parses multiple parameters", () {
var challenge = parseChallenge("scheme realm=fblthp, foo=bar, baz=qux");
expect(challenge.scheme, equals("scheme"));
- expect(challenge.parameters, equals({
- "realm": "fblthp",
- "foo": "bar",
- "baz": "qux"
- }));
+ expect(challenge.parameters,
+ equals({"realm": "fblthp", "foo": "bar", "baz": "qux"}));
});
test("parses quoted string parameters", () {
var challenge = parseChallenge('scheme realm="fblthp, foo=bar", baz="qux"');
expect(challenge.scheme, equals("scheme"));
- expect(challenge.parameters, equals({
- "realm": "fblthp, foo=bar",
- "baz": "qux"
- }));
+ expect(challenge.parameters,
+ equals({"realm": "fblthp, foo=bar", "baz": "qux"}));
});
test("normalizes the case of the scheme", () {
@@ -105,66 +96,46 @@
var challenge = parseChallenge(
" scheme\t \trealm\t = \tfblthp\t, \tfoo\t\r\n =\tbar\t");
expect(challenge.scheme, equals("scheme"));
- expect(challenge.parameters, equals({
- "realm": "fblthp",
- "foo": "bar"
- }));
+ expect(challenge.parameters, equals({"realm": "fblthp", "foo": "bar"}));
});
test("allows an empty parameter", () {
- var challenge = parseChallenge(
- "scheme realm=fblthp, , foo=bar");
+ var challenge = parseChallenge("scheme realm=fblthp, , foo=bar");
expect(challenge.scheme, equals("scheme"));
- expect(challenge.parameters, equals({
- "realm": "fblthp",
- "foo": "bar"
- }));
+ expect(challenge.parameters, equals({"realm": "fblthp", "foo": "bar"}));
});
test("allows a leading comma", () {
- var challenge = parseChallenge(
- "scheme , realm=fblthp, foo=bar,");
+ var challenge = parseChallenge("scheme , realm=fblthp, foo=bar,");
expect(challenge.scheme, equals("scheme"));
- expect(challenge.parameters, equals({
- "realm": "fblthp",
- "foo": "bar"
- }));
+ expect(challenge.parameters, equals({"realm": "fblthp", "foo": "bar"}));
});
test("allows a trailing comma", () {
- var challenge = parseChallenge(
- "scheme realm=fblthp, foo=bar, ,");
+ var challenge = parseChallenge("scheme realm=fblthp, foo=bar, ,");
expect(challenge.scheme, equals("scheme"));
- expect(challenge.parameters, equals({
- "realm": "fblthp",
- "foo": "bar"
- }));
+ expect(challenge.parameters, equals({"realm": "fblthp", "foo": "bar"}));
});
test("disallows only a scheme", () {
- expect(() => parseChallenge("scheme"),
- throwsFormatException);
+ expect(() => parseChallenge("scheme"), throwsFormatException);
});
test("disallows a valueless parameter", () {
- expect(() => parseChallenge("scheme realm"),
- throwsFormatException);
- expect(() => parseChallenge("scheme realm="),
- throwsFormatException);
- expect(() => parseChallenge("scheme realm, foo=bar"),
- throwsFormatException);
+ expect(() => parseChallenge("scheme realm"), throwsFormatException);
+ expect(() => parseChallenge("scheme realm="), throwsFormatException);
+ expect(
+ () => parseChallenge("scheme realm, foo=bar"), throwsFormatException);
});
test("requires a space after the scheme", () {
- expect(() => parseChallenge("scheme\trealm"),
- throwsFormatException);
- expect(() => parseChallenge("scheme\r\n\trealm="),
- throwsFormatException);
+ expect(() => parseChallenge("scheme\trealm"), throwsFormatException);
+ expect(() => parseChallenge("scheme\r\n\trealm="), throwsFormatException);
});
test("disallows junk after the parameters", () {
- expect(() => parseChallenge("scheme realm=fblthp foo"),
- throwsFormatException);
+ expect(
+ () => parseChallenge("scheme realm=fblthp foo"), throwsFormatException);
expect(() => parseChallenge("scheme realm=fblthp, foo=bar baz"),
throwsFormatException);
});
diff --git a/test/chunked_coding_test.dart b/test/chunked_coding_test.dart
index afe9b51..4d4a602 100644
--- a/test/chunked_coding_test.dart
+++ b/test/chunked_coding_test.dart
@@ -19,7 +19,8 @@
test("uses hex for chunk size", () {
var data = new Iterable<int>.generate(0xA7).toList();
- expect(chunkedCoding.encode(data),
+ expect(
+ chunkedCoding.encode(data),
equals([$a, $7, $cr, $lf]
..addAll(data)
..addAll([$cr, $lf, $0, $cr, $lf, $cr, $lf])));
@@ -41,20 +42,28 @@
test("adds headers to each chunk of bytes", () {
sink.add([1, 2, 3, 4]);
- expect(results, equals([[$4, $cr, $lf, 1, 2, 3, 4, $cr, $lf]]));
+ expect(
+ results,
+ equals([
+ [$4, $cr, $lf, 1, 2, 3, 4, $cr, $lf]
+ ]));
sink.add([5, 6, 7]);
- expect(results, equals([
- [$4, $cr, $lf, 1, 2, 3, 4, $cr, $lf],
- [$3, $cr, $lf, 5, 6, 7, $cr, $lf],
- ]));
+ expect(
+ results,
+ equals([
+ [$4, $cr, $lf, 1, 2, 3, 4, $cr, $lf],
+ [$3, $cr, $lf, 5, 6, 7, $cr, $lf],
+ ]));
sink.close();
- expect(results, equals([
- [$4, $cr, $lf, 1, 2, 3, 4, $cr, $lf],
- [$3, $cr, $lf, 5, 6, 7, $cr, $lf],
- [$0, $cr, $lf, $cr, $lf],
- ]));
+ expect(
+ results,
+ equals([
+ [$4, $cr, $lf, 1, 2, 3, 4, $cr, $lf],
+ [$3, $cr, $lf, 5, 6, 7, $cr, $lf],
+ [$0, $cr, $lf, $cr, $lf],
+ ]));
});
test("handles empty chunks", () {
@@ -62,24 +71,41 @@
expect(results, equals([[]]));
sink.add([1, 2, 3]);
- expect(results, equals([[], [$3, $cr, $lf, 1, 2, 3, $cr, $lf]]));
+ expect(
+ results,
+ equals([
+ [],
+ [$3, $cr, $lf, 1, 2, 3, $cr, $lf]
+ ]));
sink.add([]);
- expect(results, equals([[], [$3, $cr, $lf, 1, 2, 3, $cr, $lf], []]));
+ expect(
+ results,
+ equals([
+ [],
+ [$3, $cr, $lf, 1, 2, 3, $cr, $lf],
+ []
+ ]));
sink.close();
- expect(results, equals([
- [],
- [$3, $cr, $lf, 1, 2, 3, $cr, $lf],
- [],
- [$0, $cr, $lf, $cr, $lf],
- ]));
+ expect(
+ results,
+ equals([
+ [],
+ [$3, $cr, $lf, 1, 2, 3, $cr, $lf],
+ [],
+ [$0, $cr, $lf, $cr, $lf],
+ ]));
});
group("addSlice()", () {
test("adds bytes from the specified slice", () {
sink.addSlice([1, 2, 3, 4, 5], 1, 4, false);
- expect(results, equals([[$3, $cr, $lf, 2, 3, 4, $cr, $lf]]));
+ expect(
+ results,
+ equals([
+ [$3, $cr, $lf, 2, 3, 4, $cr, $lf]
+ ]));
});
test("doesn't add a header if the slice is empty", () {
@@ -89,8 +115,11 @@
test("adds a footer if isLast is true", () {
sink.addSlice([1, 2, 3, 4, 5], 1, 4, true);
- expect(results, equals(
- [[$3, $cr, $lf, 2, 3, 4, $cr, $lf, $0, $cr, $lf, $cr, $lf]]));
+ expect(
+ results,
+ equals([
+ [$3, $cr, $lf, 2, 3, 4, $cr, $lf, $0, $cr, $lf, $cr, $lf]
+ ]));
// Setting isLast shuld close the sink.
expect(() => sink.add([]), throwsStateError);
@@ -118,11 +147,32 @@
group("decoder", () {
test("parses chunked data", () {
- expect(chunkedCoding.decode([
- $3, $cr, $lf, 1, 2, 3, $cr, $lf,
- $4, $cr, $lf, 4, 5, 6, 7, $cr, $lf,
- $0, $cr, $lf, $cr, $lf,
- ]), equals([1, 2, 3, 4, 5, 6, 7]));
+ expect(
+ chunkedCoding.decode([
+ $3,
+ $cr,
+ $lf,
+ 1,
+ 2,
+ 3,
+ $cr,
+ $lf,
+ $4,
+ $cr,
+ $lf,
+ 4,
+ 5,
+ 6,
+ 7,
+ $cr,
+ $lf,
+ $0,
+ $cr,
+ $lf,
+ $cr,
+ $lf,
+ ]),
+ equals([1, 2, 3, 4, 5, 6, 7]));
});
test("parses hex size", () {
@@ -161,8 +211,8 @@
});
test("that ends after LF", () {
- expect(() => chunkedCoding.decode([$a, $cr, $lf]),
- throwsFormatException);
+ expect(
+ () => chunkedCoding.decode([$a, $cr, $lf]), throwsFormatException);
});
test("that ends after insufficient bytes", () {
@@ -186,8 +236,8 @@
});
test("that ends after the empty chunk", () {
- expect(() => chunkedCoding.decode([$0, $cr, $lf]),
- throwsFormatException);
+ expect(
+ () => chunkedCoding.decode([$0, $cr, $lf]), throwsFormatException);
});
test("that ends after the closing CR", () {
@@ -219,14 +269,28 @@
test("decodes each chunk of bytes", () {
sink.add([$4, $cr, $lf, 1, 2, 3, 4, $cr, $lf]);
- expect(results, equals([[1, 2, 3, 4]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3, 4]
+ ]));
sink.add([$3, $cr, $lf, 5, 6, 7, $cr, $lf]);
- expect(results, equals([[1, 2, 3, 4], [5, 6, 7]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3, 4],
+ [5, 6, 7]
+ ]));
sink.add([$0, $cr, $lf, $cr, $lf]);
sink.close();
- expect(results, equals([[1, 2, 3, 4], [5, 6, 7]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3, 4],
+ [5, 6, 7]
+ ]));
});
test("handles empty chunks", () {
@@ -234,14 +298,26 @@
expect(results, isEmpty);
sink.add([$3, $cr, $lf, 1, 2, 3, $cr, $lf]);
- expect(results, equals([[1, 2, 3]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3]
+ ]));
sink.add([]);
- expect(results, equals([[1, 2, 3]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3]
+ ]));
sink.add([$0, $cr, $lf, $cr, $lf]);
sink.close();
- expect(results, equals([[1, 2, 3]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3]
+ ]));
});
test("throws if the sink is closed before the message is done", () {
@@ -264,7 +340,11 @@
expect(results, isEmpty);
sink.add([$cr, $lf, 1, 2, 3]);
- expect(results, equals([[1, 2, 3]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3]
+ ]));
});
test("after CR", () {
@@ -272,7 +352,11 @@
expect(results, isEmpty);
sink.add([$lf, 1, 2, 3]);
- expect(results, equals([[1, 2, 3]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3]
+ ]));
});
test("after LF", () {
@@ -280,39 +364,79 @@
expect(results, isEmpty);
sink.add([1, 2, 3]);
- expect(results, equals([[1, 2, 3]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3]
+ ]));
});
test("after some bytes", () {
sink.add([$3, $cr, $lf, 1, 2]);
- expect(results, equals([[1, 2]]));
+ expect(
+ results,
+ equals([
+ [1, 2]
+ ]));
sink.add([3]);
- expect(results, equals([[1, 2], [3]]));
+ expect(
+ results,
+ equals([
+ [1, 2],
+ [3]
+ ]));
});
test("after all bytes", () {
sink.add([$3, $cr, $lf, 1, 2, 3]);
- expect(results, equals([[1, 2, 3]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3]
+ ]));
sink.add([$cr, $lf, $3, $cr, $lf, 2, 3, 4, $cr, $lf]);
- expect(results, equals([[1, 2, 3], [2, 3, 4]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3],
+ [2, 3, 4]
+ ]));
});
test("after a post-chunk CR", () {
sink.add([$3, $cr, $lf, 1, 2, 3, $cr]);
- expect(results, equals([[1, 2, 3]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3]
+ ]));
sink.add([$lf, $3, $cr, $lf, 2, 3, 4, $cr, $lf]);
- expect(results, equals([[1, 2, 3], [2, 3, 4]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3],
+ [2, 3, 4]
+ ]));
});
test("after a post-chunk LF", () {
sink.add([$3, $cr, $lf, 1, 2, 3, $cr, $lf]);
- expect(results, equals([[1, 2, 3]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3]
+ ]));
sink.add([$3, $cr, $lf, 2, 3, 4, $cr, $lf]);
- expect(results, equals([[1, 2, 3], [2, 3, 4]]));
+ expect(
+ results,
+ equals([
+ [1, 2, 3],
+ [2, 3, 4]
+ ]));
});
test("after empty chunk size", () {
@@ -363,7 +487,11 @@
group("addSlice()", () {
test("adds bytes from the specified slice", () {
sink.addSlice([1, $3, $cr, $lf, 2, 3, 4, 5], 1, 7, false);
- expect(results, equals([[2, 3, 4]]));
+ expect(
+ results,
+ equals([
+ [2, 3, 4]
+ ]));
});
test("doesn't decode if the slice is empty", () {
diff --git a/test/media_type_test.dart b/test/media_type_test.dart
index 01c58d4..be30b63 100644
--- a/test/media_type_test.dart
+++ b/test/media_type_test.dart
@@ -78,10 +78,7 @@
test("records parameters as case-insensitive", () {
var type = new MediaType.parse('test/plain;FoO=bar;bAz=bang');
- expect(type.parameters, equals({
- "FoO": "bar",
- "bAz": "bang"
- }));
+ expect(type.parameters, equals({"FoO": "bar", "bAz": "bang"}));
expect(type.parameters, containsPair("foo", "bar"));
expect(type.parameters, containsPair("baz", "bang"));
});
@@ -162,8 +159,10 @@
});
test("serializes multiple parameters", () {
- expect(new MediaType("text", "plain", {"foo": "bar", "baz": "bang"})
- .toString(), equals("text/plain; foo=bar; baz=bang"));
+ expect(
+ new MediaType("text", "plain", {"foo": "bar", "baz": "bang"})
+ .toString(),
+ equals("text/plain; foo=bar; baz=bang"));
});
});
}