Skip to content

Commit 4a7dfd2

Browse files
committed
Big merge from experimental to bleeding edge.
Review URL: https://codereview.chromium.org//11783009 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16687 260f80e4-7a28-3924-810f-c04153c831b5
1 parent 309fcb1 commit 4a7dfd2

File tree

564 files changed

+21047
-6979
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

564 files changed

+21047
-6979
lines changed

pkg/args/lib/args.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class ArgParser {
353353
_setOption(Map results, _Option option, value) {
354354
// See if it's one of the allowed values.
355355
if (option.allowed != null) {
356-
_validate(option.allowed.some((allow) => allow == value),
356+
_validate(option.allowed.any((allow) => allow == value),
357357
'"$value" is not an allowed value for option "${option.name}".');
358358
}
359359

@@ -544,7 +544,7 @@ class ArgResults {
544544
}
545545

546546
/** Get the names of the options as a [Collection]. */
547-
Collection<String> get options => _options.keys;
547+
Collection<String> get options => _options.keys.toList();
548548
}
549549

550550
class _Option {
@@ -630,8 +630,8 @@ class _Usage {
630630
if (option.help != null) write(2, option.help);
631631

632632
if (option.allowedHelp != null) {
633-
var allowedNames = option.allowedHelp.keys;
634-
allowedNames.sort((a, b) => a.compareTo(b));
633+
var allowedNames = option.allowedHelp.keys.toList();
634+
allowedNames.sort();
635635
newline();
636636
for (var name in allowedNames) {
637637
write(1, getAllowedTitle(name));

pkg/args/test/args_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ main() {
450450
parser.addOption('meow', defaultsTo: 'kitty');
451451
var args = parser.parse([]);
452452
expect(args.options, hasLength(2));
453-
expect(args.options.some((o) => o == 'woof'), isTrue);
454-
expect(args.options.some((o) => o == 'meow'), isTrue);
453+
expect(args.options.any((o) => o == 'woof'), isTrue);
454+
expect(args.options.any((o) => o == 'meow'), isTrue);
455455
});
456456
});
457457

pkg/fixnum/lib/src/int32.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class int32 implements intx {
338338
int numberOfTrailingZeros() => _numberOfTrailingZeros(_i);
339339

340340
List<int> toBytes() {
341-
List<int> result = new List<int>(4);
341+
List<int> result = new List<int>.fixedLength(4);
342342
result[0] = _i & 0xff;
343343
result[1] = (_i >> 8) & 0xff;
344344
result[2] = (_i >> 16) & 0xff;

pkg/fixnum/lib/src/int64.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ class int64 implements intx {
625625
}
626626

627627
List<int> toBytes() {
628-
List<int> result = new List<int>(8);
628+
List<int> result = new List<int>.fixedLength(8);
629629
result[0] = _l & 0xff;
630630
result[1] = (_l >> 8) & 0xff;
631631
result[2] = ((_m << 6) & 0xfc) | ((_l >> 16) & 0x3f);

pkg/fixnum/test/int_64_vm_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class int64VMTest {
174174
testSet.add(new int64.fromInt(pow));
175175
}
176176

177-
TEST_VALUES = new List<int64>(testSet.length);
177+
TEST_VALUES = new List<int64>.fixedLength(testSet.length);
178178
int index = 0;
179179
for (int64 val in testSet) {
180180
TEST_VALUES[index++] = val;

pkg/http/lib/http.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/// "http://example.com/whatsit/create",
2828
/// fields: {"name": "doodle", "color": "blue"})
2929
/// .chain((response) => client.get(response.bodyFields['uri']))
30-
/// .transform((response) => print(response.body))
30+
/// .then((response) => print(response.body))
3131
/// .onComplete((_) => client.close());
3232
///
3333
/// You can also exert more fine-grained control over your requests and
@@ -53,6 +53,7 @@
5353
5454
library http;
5555

56+
import 'dart:async';
5657
import 'dart:scalarlist';
5758
import 'dart:uri';
5859

@@ -168,6 +169,6 @@ Future<Uint8List> readBytes(url, {Map<String, String> headers}) =>
168169
Future _withClient(Future fn(Client)) {
169170
var client = new Client();
170171
var future = fn(client);
171-
future.onComplete((_) => client.close());
172+
future.catchError((_) {}).then((_) => client.close());
172173
return future;
173174
}

pkg/http/lib/src/base_client.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
library base_client;
66

7+
import 'dart:async';
78
import 'dart:io';
89
import 'dart:scalarlist';
910
import 'dart:uri';
@@ -72,7 +73,7 @@ abstract class BaseClient implements Client {
7273
/// For more fine-grained control over the request and response, use [send] or
7374
/// [get] instead.
7475
Future<String> read(url, {Map<String, String> headers}) {
75-
return get(url, headers: headers).transform((response) {
76+
return get(url, headers: headers).then((response) {
7677
_checkResponseSuccess(url, response);
7778
return response.body;
7879
});
@@ -88,7 +89,7 @@ abstract class BaseClient implements Client {
8889
/// For more fine-grained control over the request and response, use [send] or
8990
/// [get] instead.
9091
Future<Uint8List> readBytes(url, {Map<String, String> headers}) {
91-
return get(url, headers: headers).transform((response) {
92+
return get(url, headers: headers).then((response) {
9293
_checkResponseSuccess(url, response);
9394
return response.bodyBytes;
9495
});
@@ -108,15 +109,15 @@ abstract class BaseClient implements Client {
108109
[Map<String, String> fields]) {
109110
// Wrap everything in a Future block so that synchronous validation errors
110111
// are passed asynchronously through the Future chain.
111-
return async.chain((_) {
112+
return async.then((_) {
112113
if (url is String) url = new Uri.fromString(url);
113114
var request = new Request(method, url);
114115

115116
if (headers != null) mapAddAll(request.headers, headers);
116117
if (fields != null && !fields.isEmpty) request.bodyFields = fields;
117118

118119
return send(request);
119-
}).chain(Response.fromStream);
120+
}).then(Response.fromStream);
120121
}
121122

122123
/// Throws an error if [response] is not successful.

pkg/http/lib/src/base_request.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
library base_request;
66

7+
import 'dart:async';
78
import 'dart:io';
89
import 'dart:isolate';
910
import 'dart:uri';
@@ -105,7 +106,7 @@ abstract class BaseRequest {
105106
/// requests.
106107
Future<StreamedResponse> send() {
107108
var client = new Client();
108-
return client.send(this).transform((response) {
109+
return client.send(this).then((response) {
109110
// TODO(nweiz): This makes me sick to my stomach, but it's currently the
110111
// best way to listen for the response stream being closed. Kill it with
111112
// fire once issue 4202 is fixed.
@@ -117,7 +118,7 @@ abstract class BaseRequest {
117118
});
118119

119120
return response;
120-
});
121+
}).catchError((_) { client.close(); });
121122
}
122123

123124
/// Throws an error if this request has been finalized.

pkg/http/lib/src/client.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
library client;
66

7+
import 'dart:async';
78
import 'dart:io';
89
import 'dart:scalarlist';
910

pkg/http/lib/src/io_client.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
library io_client;
66

7+
import 'dart:async';
78
import 'dart:io';
89

910
import 'base_client.dart';
@@ -25,6 +26,7 @@ class IOClient extends BaseClient {
2526

2627
var completer = new Completer<StreamedResponse>();
2728
var connection = _inner.openUrl(request.method, request.url);
29+
bool completed = false;
2830
connection.followRedirects = request.followRedirects;
2931
connection.maxRedirects = request.maxRedirects;
3032
connection.onError = (e) {
@@ -33,9 +35,10 @@ class IOClient extends BaseClient {
3335
// onRequest or onResponse callbacks get passed to onError. If the
3436
// completer has already fired, we want to re-throw those exceptions
3537
// to the top level so that they aren't silently ignored.
36-
if (completer.future.isComplete) throw e;
38+
if (completed) throw e;
3739

38-
completer.completeException(e);
40+
completed = true;
41+
completer.completeError(e);
3942
});
4043
};
4144

@@ -57,6 +60,9 @@ class IOClient extends BaseClient {
5760
var headers = <String>{};
5861
response.headers.forEach((key, value) => headers[key] = value);
5962

63+
if (completed) return;
64+
65+
completed = true;
6066
completer.complete(new StreamedResponse(
6167
response.inputStream,
6268
response.statusCode,

0 commit comments

Comments
 (0)