mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:51:18 +00:00
Migrated test block 171 to Dart 2.0.
R=rnystrom@google.com Moved schedule_microtask[2,3,5]_test off of package:test to package:async_helper and package:expect. Review-Url: https://codereview.chromium.org/3001793002 .
This commit is contained in:
parent
3ac0950efa
commit
d08e59e09c
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) 2013, 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 run_async_test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'dart:async';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
main() {
|
||||
// Check that the callbacks are executed in order.
|
||||
test("run async in order test", () {
|
||||
int lastCallback = -1;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.equals(lastCallback, i - 1);
|
||||
lastCallback = i;
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright (c) 2013, 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 run_async_test;
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
main() {
|
||||
test("run async timer after async test", () {
|
||||
// Check that Timers don't run before the async callbacks.
|
||||
bool timerCallbackExecuted = false;
|
||||
|
||||
Timer.run(expectAsync(() {
|
||||
timerCallbackExecuted = true;
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
// Busy loop.
|
||||
var sum = 1;
|
||||
var sw = new Stopwatch()..start();
|
||||
while (sw.elapsedMilliseconds < 5) {
|
||||
sum++;
|
||||
}
|
||||
if (sum == 0) throw "bad"; // Just to use the result.
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
});
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 2013, 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 run_async_test;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
main() {
|
||||
test("run async timer after async test", () {
|
||||
// Check that Timers don't run before the async callbacks.
|
||||
bool timerCallbackExecuted = false;
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
|
||||
Timer.run(expectAsync(() {
|
||||
timerCallbackExecuted = true;
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
// Busy loop.
|
||||
var sum = 1;
|
||||
var sw = new Stopwatch()..start();
|
||||
while (sw.elapsedMilliseconds < 5) {
|
||||
sum++;
|
||||
}
|
||||
if (sum == 0) throw "bad"; // Just to use the result.
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
});
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// VMOptions=--old_gen_heap_size=64
|
||||
|
||||
library slow_consumer3_test;
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
|
||||
const int KB = 1024;
|
||||
const int MB = KB * KB;
|
||||
const int GB = KB * KB * KB;
|
||||
|
||||
class SlowConsumer extends StreamConsumer {
|
||||
int receivedCount = 0;
|
||||
final int bytesPerSecond;
|
||||
final int bufferSize;
|
||||
final List bufferedData = [];
|
||||
int usedBufferSize = 0;
|
||||
int finalCount;
|
||||
|
||||
SlowConsumer(int this.bytesPerSecond, int this.bufferSize);
|
||||
|
||||
Future consume(Stream stream) {
|
||||
return addStream(stream).then((_) => close());
|
||||
}
|
||||
|
||||
Future addStream(Stream stream) {
|
||||
Completer result = new Completer();
|
||||
var subscription;
|
||||
subscription = stream.listen((List<int> data) {
|
||||
receivedCount += data.length;
|
||||
usedBufferSize += data.length;
|
||||
bufferedData.add(data);
|
||||
int currentBufferedDataLength = bufferedData.length;
|
||||
if (usedBufferSize > bufferSize) {
|
||||
subscription.pause();
|
||||
usedBufferSize = 0;
|
||||
int ms = data.length * 1000 ~/ bytesPerSecond;
|
||||
Duration duration = new Duration(milliseconds: ms);
|
||||
new Timer(duration, () {
|
||||
for (int i = 0; i < currentBufferedDataLength; i++) {
|
||||
bufferedData[i] = null;
|
||||
}
|
||||
subscription.resume();
|
||||
});
|
||||
}
|
||||
}, onDone: () {
|
||||
finalCount = receivedCount;
|
||||
result.complete(receivedCount);
|
||||
});
|
||||
return result.future;
|
||||
}
|
||||
|
||||
Future close() {
|
||||
return new Future.value(finalCount);
|
||||
}
|
||||
}
|
||||
|
||||
Stream<List> dataGenerator(int bytesTotal, int chunkSize) {
|
||||
int chunks = bytesTotal ~/ chunkSize;
|
||||
return new Stream.fromIterable(new Iterable.generate(chunks, (_) {
|
||||
// This assumes one byte per entry. In practice it will be more.
|
||||
return new List<int>(chunkSize);
|
||||
}));
|
||||
}
|
||||
|
||||
main() {
|
||||
asyncStart();
|
||||
// The data provider can deliver 800MBs of data as fast as it is
|
||||
// requested. The data is sent in 0.5MB chunks. The consumer has a buffer of
|
||||
// 3MB. That is, it can accept a few packages without pausing its input.
|
||||
//
|
||||
// Notice that we aren't really counting bytes, but words, since we use normal
|
||||
// lists where each entry takes up a full word. In 64-bit VMs this will be
|
||||
// 8 bytes per entry, so the 3*MB buffer is picked to stay below 32 actual
|
||||
// MiB.
|
||||
//
|
||||
// This test is limited to 32MB of heap-space (see VMOptions on top of the
|
||||
// file). If the consumer doesn't pause the data-provider it will run out of
|
||||
// heap-space.
|
||||
|
||||
dataGenerator(100 * MB, 512 * KB)
|
||||
.pipe(new SlowConsumer(200 * MB, 3 * MB))
|
||||
.then((count) {
|
||||
Expect.equals(100 * MB, count);
|
||||
asyncEnd();
|
||||
});
|
||||
}
|
|
@ -161,9 +161,7 @@ math/math2_test: RuntimeError
|
|||
|
||||
[ $compiler == dart2js && $runtime == jsshell ]
|
||||
async/timer_regress22626_test: RuntimeError # Non-zero timers not supported; Issue 7728.
|
||||
async/slow_consumer2_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/slow_consumer3_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/slow_consumer_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/future_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/stream_from_iterable_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/stream_state_nonzero_timer_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/timer_cancel_test: RuntimeError,OK # Needs Timer to run.
|
||||
|
@ -178,7 +176,7 @@ async/stream_periodic3_test: RuntimeError # Timer interface not supported; Issue
|
|||
async/stream_periodic4_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/stream_periodic5_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/stream_periodic6_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/run_zoned7_test: RuntimeError # Timer interface not supported: Issue 7728.
|
||||
async/catch_errors22_test: RuntimeError # Timer interface not supported: Issue 7728.
|
||||
async/timer_isActive_test: RuntimeError # Timer interface not supported: Issue 7728.
|
||||
async/zone_empty_description2_test: RuntimeError # Timer interface not supported: Issue 7728.
|
||||
async/zone_create_timer2_test: RuntimeError # Timer interface not supported: Issue 7728.
|
||||
|
@ -188,7 +186,6 @@ async/catch_errors13_test: Fail # Timer interface not supported: Issue 7728.
|
|||
async/catch_errors14_test: Fail # Timer interface not supported: Issue 7728.
|
||||
async/catch_errors15_test: Fail # Timer interface not supported: Issue 7728.
|
||||
async/catch_errors8_test: Fail # Timer interface not supported: Issue 7728.
|
||||
async/run_zoned8_test: Fail # Timer interface not supported: Issue 7728.
|
||||
async/zone_bind_test: Fail # Timer interface not supported: Issue 7728.
|
||||
async/stream_timeout_test: Fail # Timer interface not supported: Issue 7728.
|
||||
async/stream_asyncexpand_test: RuntimeError # Timer interface not supported: Issue 7728.
|
||||
|
@ -225,10 +222,10 @@ mirrors/*: Skip # Issue 27929: Triage
|
|||
[ $runtime == flutter ]
|
||||
mirrors/*: Skip # Flutter does not support mirrors.
|
||||
async/catch_errors11_test: Skip # Flutter Issue 9113
|
||||
async/run_zoned6_test/01: Skip # Flutter Issue 9113
|
||||
async/schedule_microtask_test: Skip # Flutter Issue 9113
|
||||
async/intercept_schedule_microtask2_test: Skip # Flutter Issue 9113
|
||||
async/intercept_schedule_microtask6_test: Skip # Flutter Issue 9113
|
||||
async/stream_empty_test: Skip # Flutter Issue 9113
|
||||
async/run_zoned9_test/01: Skip # Flutter Issue 9113
|
||||
async/intercept_schedule_microtask5_test: Skip # Flutter Issue 9113
|
||||
async/stream_event_transformed_test: Skip # Flutter Issue 9113
|
||||
math/random_secure_test: RuntimeError # Flutter Issue 9113
|
||||
|
||||
|
@ -243,7 +240,6 @@ mirrors/mirrors_reader_test: Timeout, Slow, RuntimeError # Issue 16589
|
|||
|
||||
[ $runtime == chrome && $system == macos ]
|
||||
async/timer_isActive_test: Fail, Pass, Timeout # Issue 22696
|
||||
async/slow_consumer_test: Pass, Timeout # Issue 22696
|
||||
async/catch_errors11_test: Pass, Timeout # Issue 22696
|
||||
|
||||
[ $runtime == chrome && $system == linux ]
|
||||
|
@ -254,7 +250,6 @@ convert/streamed_conversion_utf8_encode_test: SkipSlow # Times out. Issue 22050
|
|||
convert/streamed_conversion_utf8_decode_test: SkipSlow # Times out. Issue 22050
|
||||
convert/streamed_conversion_json_utf8_encode_test: SkipSlow # Times out. Issue 22050
|
||||
convert/streamed_conversion_json_utf8_decode_test: SkipSlow # Times out. Issue 22050
|
||||
async/slow_consumer2_test: SkipSlow # Times out. Issue 22050
|
||||
async/stream_timeout_test: SkipSlow # Times out. Issue 22050
|
||||
|
||||
[ $compiler == dart2js ]
|
||||
|
@ -285,9 +280,7 @@ mirrors/mirrors_used*: SkipByDesign # Invalid tests. MirrorsUsed does not have a
|
|||
# These use package:unittest
|
||||
async/first_regression_test: RuntimeError
|
||||
async/future_timeout_test: RuntimeError
|
||||
async/schedule_microtask2_test: RuntimeError
|
||||
async/schedule_microtask3_test: RuntimeError
|
||||
async/schedule_microtask5_test: RuntimeError
|
||||
async/multiple_timer_test: RuntimeError
|
||||
async/stream_controller_async_test: RuntimeError
|
||||
async/stream_first_where_test: RuntimeError
|
||||
async/stream_from_iterable_test: RuntimeError
|
||||
|
@ -328,7 +321,6 @@ mirrors/mirrors_reader_test: SkipSlow # Times out. Issue 20806.
|
|||
mirrors/null_test: Fail # Issue 16831
|
||||
|
||||
[ $compiler == dart2js && $runtime == jsshell ]
|
||||
async/schedule_microtask_test: Fail # Preamble file does not correctly implement scheduleImmediate.
|
||||
|
||||
[ $compiler == dart2analyzer ]
|
||||
mirrors/generic_f_bounded_mixin_application_test: StaticWarning # Test Issue
|
||||
|
@ -442,7 +434,9 @@ async/timer_regress22626_test: Pass, RuntimeError # Timing dependent.
|
|||
mirrors/other_declarations_location_test: Crash # assertion error, TypeParameter not having position.
|
||||
|
||||
[ $compiler == dartk || $compiler == dartkp ]
|
||||
async/schedule_microtask2_test: RuntimeError
|
||||
async/future_or_strong_test: RuntimeError
|
||||
async/future_test/01: RuntimeError
|
||||
async/future_test/none: RuntimeError
|
||||
mirrors/abstract_class_test/00: RuntimeError
|
||||
mirrors/abstract_class_test/none: RuntimeError
|
||||
mirrors/class_declarations_test/01: RuntimeError
|
||||
|
|
|
@ -2,19 +2,20 @@
|
|||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
library run_async_test;
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import 'package:expect/expect.dart';
|
||||
import 'dart:async';
|
||||
|
||||
main() {
|
||||
StackTrace trace;
|
||||
asyncStart();
|
||||
var f = new Future(() {
|
||||
throw "foo";
|
||||
});
|
||||
f.catchError((e, st) {
|
||||
Expect.equals("foo", e);
|
||||
Expect.isNotNull(st);
|
||||
asyncEnd();
|
||||
});
|
||||
int lastCallback = -1;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
asyncStart();
|
||||
scheduleMicrotask(() {
|
||||
Expect.equals(lastCallback, i - 1);
|
||||
lastCallback = i;
|
||||
asyncEnd();
|
||||
});
|
||||
}
|
||||
}
|
41
tests/lib_2/async/schedule_microtask3_test.dart
Normal file
41
tests/lib_2/async/schedule_microtask3_test.dart
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) 2013, 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 run_async_test;
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
// Check that Timers don't run before the async callbacks.
|
||||
bool timerCallbackExecuted = false;
|
||||
|
||||
asyncStart();
|
||||
Timer.run(() {
|
||||
timerCallbackExecuted = true;
|
||||
asyncEnd();
|
||||
});
|
||||
|
||||
scheduleMicrotask(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
});
|
||||
|
||||
scheduleMicrotask(() {
|
||||
// Busy loop.
|
||||
var sum = 1;
|
||||
var sw = new Stopwatch()..start();
|
||||
while (sw.elapsedMilliseconds < 5) {
|
||||
sum++;
|
||||
}
|
||||
if (sum == 0) throw "bad"; // Just to use the result.
|
||||
scheduleMicrotask(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
});
|
||||
});
|
||||
|
||||
scheduleMicrotask(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
});
|
||||
}
|
45
tests/lib_2/async/schedule_microtask5_test.dart
Normal file
45
tests/lib_2/async/schedule_microtask5_test.dart
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) 2013, 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 run_async_test;
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
// Check that Timers don't run before the async callbacks.
|
||||
bool timerCallbackExecuted = false;
|
||||
|
||||
scheduleMicrotask(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
});
|
||||
|
||||
asyncStart();
|
||||
Timer.run(() {
|
||||
timerCallbackExecuted = true;
|
||||
asyncEnd();
|
||||
});
|
||||
|
||||
scheduleMicrotask(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
});
|
||||
|
||||
scheduleMicrotask(() {
|
||||
// Busy loop.
|
||||
var sum = 1;
|
||||
var sw = new Stopwatch()..start();
|
||||
while (sw.elapsedMilliseconds < 5) {
|
||||
sum++;
|
||||
}
|
||||
if (sum == 0) throw "bad"; // Just to use the result.
|
||||
scheduleMicrotask(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
});
|
||||
});
|
||||
|
||||
scheduleMicrotask(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
});
|
||||
}
|
|
@ -14,11 +14,11 @@ const int KB = 1024;
|
|||
const int MB = KB * KB;
|
||||
const int GB = KB * KB * KB;
|
||||
|
||||
class SlowConsumer extends StreamConsumer {
|
||||
class SlowConsumer extends StreamConsumer<List<int>> {
|
||||
int receivedCount = 0;
|
||||
final int bytesPerSecond;
|
||||
final int bufferSize;
|
||||
final List bufferedData = [];
|
||||
final List<int> bufferedData = [];
|
||||
int usedBufferSize = 0;
|
||||
int finalCount;
|
||||
|
||||
|
@ -60,7 +60,7 @@ class SlowConsumer extends StreamConsumer {
|
|||
}
|
||||
}
|
||||
|
||||
Stream<List> dataGenerator(int bytesTotal, int chunkSize) {
|
||||
Stream<List<int>> dataGenerator(int bytesTotal, int chunkSize) {
|
||||
int chunks = bytesTotal ~/ chunkSize;
|
||||
return new Stream.fromIterable(new Iterable.generate(chunks, (_) {
|
||||
// This assumes one byte per entry. In practice it will be more.
|
|
@ -10,3 +10,9 @@ async/future_or_only_in_async_test/00: MissingCompileTimeError
|
|||
|
||||
[ $hot_reload || $hot_reload_rollback ]
|
||||
async/multiple_timer_test: Pass, Fail # Timing related
|
||||
|
||||
[ $runtime == chrome && $system == macos ]
|
||||
async/slow_consumer_test: Pass, Timeout # Issue 22696
|
||||
|
||||
[ $runtime == chrome || $runtime == ff ]
|
||||
async/slow_consumer2_test: SkipSlow # Times out. Issue 22050
|
||||
|
|
|
@ -11,6 +11,13 @@ async/catch_errors28_test: Fail # Timer interface not supported: Issue 7728.
|
|||
async/future_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/future_constructor2_test: Fail # Timer interface not supported: Issue 7728.
|
||||
async/multiple_timer_test: RuntimeError,OK # Needs Timer to run.
|
||||
async/slow_consumer2_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/slow_consumer3_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/slow_consumer_test: RuntimeError # Timer interface not supported; Issue 7728.
|
||||
async/run_zoned7_test: RuntimeError # Timer interface not supported: Issue 7728.
|
||||
async/run_zoned8_test: Fail # Timer interface not supported: Issue 7728.
|
||||
async/schedule_microtask_test: Fail # Preamble file does not correctly implement scheduleImmediate.
|
||||
async/schedule_microtask3_test: RuntimeError
|
||||
|
||||
[ $compiler == dart2js ]
|
||||
async/future_or_strong_test: RuntimeError
|
||||
|
|
|
@ -7,3 +7,4 @@ async/future_or_bad_type_test/none: RuntimeError # Issue 29922
|
|||
async/future_or_bad_type_test/implements: RuntimeError # Issue 29922
|
||||
async/future_test: RuntimeError # Issue 29922
|
||||
async/futures_test: RuntimeError # Issue 29922
|
||||
async/slow_consumer_test: Pass, Timeout # Issue 29922
|
||||
|
|
|
@ -6,3 +6,6 @@
|
|||
async/intercept_schedule_microtask2_test: Skip # Flutter Issue 9113
|
||||
async/intercept_schedule_microtask6_test: Skip # Flutter Issue 9113
|
||||
async/intercept_schedule_microtask5_test: Skip # Flutter Issue 9113
|
||||
async/run_zoned6_test/01: Skip # Flutter Issue 9113
|
||||
async/schedule_microtask_test: Skip # Flutter Issue 9113
|
||||
async/run_zoned9_test/01: Skip # Flutter Issue 9113
|
||||
|
|
|
@ -6,3 +6,4 @@
|
|||
async/future_or_strong_test: RuntimeError
|
||||
async/future_test/01: RuntimeError
|
||||
async/future_test/none: RuntimeError
|
||||
async/schedule_microtask2_test: RuntimeError
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
[ $runtime == vm && $system == fuchsia ]
|
||||
async/first_regression_test: RuntimeError
|
||||
async/future_timeout_test: RuntimeError
|
||||
async/schedule_microtask2_test: RuntimeError
|
||||
async/schedule_microtask3_test: RuntimeError
|
||||
async/schedule_microtask5_test: RuntimeError
|
||||
|
||||
[ $strong && $runtime == vm ]
|
||||
async/future_or_only_in_async_test/00: MissingCompileTimeError
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
|
||||
main() {
|
||||
// Make sure `runZoned` returns the result of a synchronous call.
|
||||
Expect.equals(499, runZoned(() => 499));
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
|
||||
main() {
|
||||
// Make sure `runZoned` returns the result of a synchronous call when an
|
||||
// error handler is defined.
|
||||
Expect.equals(
|
||||
499,
|
||||
runZoned(() => 499, onError: (e) {
|
||||
throw "Unexpected";
|
||||
}));
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
|
||||
main() {
|
||||
asyncStart();
|
||||
// Ensure that `runZoned`'s onError handles synchronous errors.
|
||||
runZoned(() {
|
||||
throw 0;
|
||||
}, onError: (e) {
|
||||
Expect.equals(0, e);
|
||||
asyncEnd();
|
||||
});
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
|
||||
main() {
|
||||
asyncStart();
|
||||
// Ensure that `runZoned`'s onError handles synchronous errors but delegates
|
||||
// to the top-level when the handler returns false.
|
||||
try {
|
||||
runZoned(() {
|
||||
throw 0;
|
||||
}, onError: (e) {
|
||||
Expect.equals(0, e);
|
||||
if (false) //# 01: runtime error
|
||||
asyncEnd();
|
||||
throw e; //# 01: runtime error
|
||||
});
|
||||
} catch (e) {
|
||||
// We should never see an error here.
|
||||
if (false) //# 01: continued
|
||||
rethrow;
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
import 'catch_errors.dart';
|
||||
|
||||
main() {
|
||||
asyncStart();
|
||||
Completer done = new Completer();
|
||||
|
||||
var events = [];
|
||||
// Test runZoned with periodic Timers.
|
||||
runZoned(() {
|
||||
int counter = 0;
|
||||
new Timer.periodic(const Duration(milliseconds: 50), (timer) {
|
||||
if (counter == 5) {
|
||||
timer.cancel();
|
||||
done.complete(true);
|
||||
}
|
||||
counter++;
|
||||
events.add(counter);
|
||||
});
|
||||
});
|
||||
|
||||
done.future.whenComplete(() {
|
||||
Expect.listEquals([
|
||||
"main exit",
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
], events);
|
||||
asyncEnd();
|
||||
});
|
||||
events.add("main exit");
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
import 'catch_errors.dart';
|
||||
|
||||
main() {
|
||||
asyncStart();
|
||||
Completer done = new Completer();
|
||||
|
||||
var events = [];
|
||||
// Test runZoned with periodic Timers.
|
||||
runZoned(() {
|
||||
int counter = 0;
|
||||
new Timer.periodic(const Duration(milliseconds: 50), (timer) {
|
||||
if (counter == 1) {
|
||||
timer.cancel();
|
||||
done.complete(true);
|
||||
}
|
||||
counter++;
|
||||
events.add(counter);
|
||||
throw counter;
|
||||
});
|
||||
}, onError: (e) {
|
||||
events.add("error: $e");
|
||||
});
|
||||
|
||||
done.future.whenComplete(() {
|
||||
Expect.listEquals([
|
||||
"main exit",
|
||||
1,
|
||||
"error: 1",
|
||||
2,
|
||||
"error: 2",
|
||||
], events);
|
||||
asyncEnd();
|
||||
});
|
||||
events.add("main exit");
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
|
||||
main() {
|
||||
asyncStart();
|
||||
// Ensure that `runZoned`'s onError handles synchronous errors but delegates
|
||||
// to the next runZoned when the handler returns false.
|
||||
bool sawInnerHandler = false;
|
||||
try {
|
||||
runZoned(() {
|
||||
runZoned(() {
|
||||
throw 0;
|
||||
}, onError: (e) {
|
||||
Expect.equals(0, e);
|
||||
sawInnerHandler = true;
|
||||
throw e;
|
||||
});
|
||||
}, onError: (e) {
|
||||
Expect.equals(0, e);
|
||||
Expect.isTrue(sawInnerHandler);
|
||||
// If we are waiting for an error, don't asyncEnd, but let it time out.
|
||||
if (false) //# 01: runtime error
|
||||
asyncEnd();
|
||||
throw e; // //# 01: continued
|
||||
});
|
||||
} catch (e) {
|
||||
// We should never see an error here.
|
||||
if (false) // //# 01: continued
|
||||
rethrow;
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) 2013, 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 run_async_test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'dart:async';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
main() {
|
||||
// Check that the callbacks are executed in order.
|
||||
test("run async in order test", () {
|
||||
int lastCallback = -1;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.equals(lastCallback, i - 1);
|
||||
lastCallback = i;
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright (c) 2013, 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 run_async_test;
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
main() {
|
||||
test("run async timer after async test", () {
|
||||
// Check that Timers don't run before the async callbacks.
|
||||
bool timerCallbackExecuted = false;
|
||||
|
||||
Timer.run(expectAsync(() {
|
||||
timerCallbackExecuted = true;
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
// Busy loop.
|
||||
var sum = 1;
|
||||
var sw = new Stopwatch()..start();
|
||||
while (sw.elapsedMilliseconds < 5) {
|
||||
sum++;
|
||||
}
|
||||
if (sum == 0) throw "bad"; // Just to use the result.
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
});
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 2013, 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 run_async_test;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
main() {
|
||||
test("run async timer after async test", () {
|
||||
// Check that Timers don't run before the async callbacks.
|
||||
bool timerCallbackExecuted = false;
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
|
||||
Timer.run(expectAsync(() {
|
||||
timerCallbackExecuted = true;
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
// Busy loop.
|
||||
var sum = 1;
|
||||
var sw = new Stopwatch()..start();
|
||||
while (sw.elapsedMilliseconds < 5) {
|
||||
sum++;
|
||||
}
|
||||
if (sum == 0) throw "bad"; // Just to use the result.
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
}));
|
||||
|
||||
scheduleMicrotask(expectAsync(() {
|
||||
Expect.isFalse(timerCallbackExecuted);
|
||||
}));
|
||||
});
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
|
||||
Future testOneScheduleMicrotask() {
|
||||
var completer = new Completer();
|
||||
Timer.run(() {
|
||||
scheduleMicrotask(completer.complete);
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
Future testMultipleScheduleMicrotask() {
|
||||
var completer = new Completer();
|
||||
Timer.run(() {
|
||||
const TOTAL = 10;
|
||||
int done = 0;
|
||||
for (int i = 0; i < TOTAL; i++) {
|
||||
scheduleMicrotask(() {
|
||||
done++;
|
||||
if (done == TOTAL) completer.complete();
|
||||
;
|
||||
});
|
||||
}
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
Future testScheduleMicrotaskThenTimer() {
|
||||
var completer = new Completer();
|
||||
Timer.run(() {
|
||||
bool scheduleMicrotaskDone = false;
|
||||
scheduleMicrotask(() {
|
||||
Expect.isFalse(scheduleMicrotaskDone);
|
||||
scheduleMicrotaskDone = true;
|
||||
});
|
||||
Timer.run(() {
|
||||
Expect.isTrue(scheduleMicrotaskDone);
|
||||
completer.complete();
|
||||
});
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
Future testTimerThenScheduleMicrotask() {
|
||||
var completer = new Completer();
|
||||
Timer.run(() {
|
||||
bool scheduleMicrotaskDone = false;
|
||||
Timer.run(() {
|
||||
Expect.isTrue(scheduleMicrotaskDone);
|
||||
completer.complete();
|
||||
});
|
||||
scheduleMicrotask(() {
|
||||
Expect.isFalse(scheduleMicrotaskDone);
|
||||
scheduleMicrotaskDone = true;
|
||||
});
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
Future testTimerThenScheduleMicrotaskChain() {
|
||||
var completer = new Completer();
|
||||
Timer.run(() {
|
||||
const TOTAL = 10;
|
||||
int scheduleMicrotaskDone = 0;
|
||||
Timer.run(() {
|
||||
Expect.equals(TOTAL, scheduleMicrotaskDone);
|
||||
completer.complete();
|
||||
});
|
||||
Future scheduleMicrotaskCallback() {
|
||||
scheduleMicrotaskDone++;
|
||||
if (scheduleMicrotaskDone != TOTAL) {
|
||||
scheduleMicrotask(scheduleMicrotaskCallback);
|
||||
}
|
||||
}
|
||||
|
||||
scheduleMicrotask(scheduleMicrotaskCallback);
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
main() {
|
||||
asyncStart();
|
||||
testOneScheduleMicrotask()
|
||||
.then((_) => testMultipleScheduleMicrotask())
|
||||
.then((_) => testScheduleMicrotaskThenTimer())
|
||||
.then((_) => testTimerThenScheduleMicrotask())
|
||||
.then((_) => testTimerThenScheduleMicrotaskChain())
|
||||
.then((_) => asyncEnd());
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// VMOptions=--old_gen_heap_size=64
|
||||
|
||||
library slow_consumer2_test;
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
|
||||
const int KB = 1024;
|
||||
const int MB = KB * KB;
|
||||
const int GB = KB * KB * KB;
|
||||
|
||||
class SlowConsumer extends StreamConsumer {
|
||||
int receivedCount = 0;
|
||||
final int bytesPerSecond;
|
||||
final int bufferSize;
|
||||
final List bufferedData = [];
|
||||
int usedBufferSize = 0;
|
||||
int finalCount;
|
||||
|
||||
SlowConsumer(int this.bytesPerSecond, int this.bufferSize);
|
||||
|
||||
Future consume(Stream stream) {
|
||||
return addStream(stream).then((_) => close());
|
||||
}
|
||||
|
||||
Future addStream(Stream stream) {
|
||||
Completer result = new Completer();
|
||||
var subscription;
|
||||
subscription = stream.listen((List<int> data) {
|
||||
receivedCount += data.length;
|
||||
usedBufferSize += data.length;
|
||||
bufferedData.add(data);
|
||||
int currentBufferedDataLength = bufferedData.length;
|
||||
if (usedBufferSize > bufferSize) {
|
||||
subscription.pause();
|
||||
usedBufferSize = 0;
|
||||
int ms = data.length * 1000 ~/ bytesPerSecond;
|
||||
Duration duration = new Duration(milliseconds: ms);
|
||||
new Timer(duration, () {
|
||||
for (int i = 0; i < currentBufferedDataLength; i++) {
|
||||
bufferedData[i] = null;
|
||||
}
|
||||
subscription.resume();
|
||||
});
|
||||
}
|
||||
}, onDone: () {
|
||||
finalCount = receivedCount;
|
||||
result.complete(receivedCount);
|
||||
});
|
||||
return result.future;
|
||||
}
|
||||
|
||||
Future close() {
|
||||
return new Future.value(finalCount);
|
||||
}
|
||||
}
|
||||
|
||||
class DataProvider {
|
||||
final int chunkSize;
|
||||
final int bytesPerSecond;
|
||||
int sentCount = 0;
|
||||
int targetCount;
|
||||
StreamController controller;
|
||||
|
||||
DataProvider(int this.bytesPerSecond, int this.targetCount, this.chunkSize) {
|
||||
controller = new StreamController(
|
||||
sync: true, onPause: onPauseStateChange, onResume: onPauseStateChange);
|
||||
Timer.run(send);
|
||||
}
|
||||
|
||||
Stream get stream => controller.stream;
|
||||
|
||||
send() {
|
||||
if (controller.isPaused) return;
|
||||
if (sentCount == targetCount) {
|
||||
controller.close();
|
||||
return;
|
||||
}
|
||||
int listSize = chunkSize;
|
||||
sentCount += listSize;
|
||||
if (sentCount > targetCount) {
|
||||
listSize -= sentCount - targetCount;
|
||||
sentCount = targetCount;
|
||||
}
|
||||
controller.add(new List(listSize));
|
||||
int ms = listSize * 1000 ~/ bytesPerSecond;
|
||||
Duration duration = new Duration(milliseconds: ms);
|
||||
if (!controller.isPaused) new Timer(duration, send);
|
||||
}
|
||||
|
||||
onPauseStateChange() {
|
||||
// We don't care if we just unpaused or paused. In either case we just
|
||||
// call send which will test it for us.
|
||||
send();
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
asyncStart();
|
||||
// The data provider can deliver 800MB/s of data. It sends 100MB of data to
|
||||
// the slower consumer who can only read 200MB/s. The data is sent in 1MB
|
||||
// chunks. The consumer has a buffer of 5MB. That is, it can accept a few
|
||||
// packages without pausing its input.
|
||||
//
|
||||
// This test is limited to 32MB of heap-space (see VMOptions on top of the
|
||||
// file). If the consumer doesn't pause the data-provider it will run out of
|
||||
// heap-space.
|
||||
|
||||
new DataProvider(800 * MB, 100 * MB, 1 * MB)
|
||||
.stream
|
||||
.pipe(new SlowConsumer(200 * MB, 5 * MB))
|
||||
.then((count) {
|
||||
Expect.equals(100 * MB, count);
|
||||
asyncEnd();
|
||||
});
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// VMOptions=--old_gen_heap_size=64
|
||||
|
||||
library slow_consumer_test;
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
|
||||
const int KB = 1024;
|
||||
const int MB = KB * KB;
|
||||
const int GB = KB * KB * KB;
|
||||
|
||||
class SlowConsumer extends StreamConsumer {
|
||||
var current = new Future.value(0);
|
||||
final int bytesPerSecond;
|
||||
int finalCount;
|
||||
|
||||
SlowConsumer(int this.bytesPerSecond);
|
||||
|
||||
Future consume(Stream stream) {
|
||||
return addStream(stream).then((_) => close());
|
||||
}
|
||||
|
||||
Future addStream(Stream stream) {
|
||||
bool done = false;
|
||||
Completer completer = new Completer();
|
||||
var subscription;
|
||||
subscription = stream.listen((List<int> data) {
|
||||
current = current.then((count) {
|
||||
// Simulated amount of time it takes to handle the data.
|
||||
int ms = data.length * 1000 ~/ bytesPerSecond;
|
||||
Duration duration = new Duration(milliseconds: ms);
|
||||
if (!done) subscription.pause();
|
||||
return new Future.delayed(duration, () {
|
||||
if (!done) subscription.resume();
|
||||
// Make sure we use data here to keep tracking it.
|
||||
return count + data.length;
|
||||
});
|
||||
});
|
||||
}, onDone: () {
|
||||
done = true;
|
||||
current.then((count) {
|
||||
finalCount = count;
|
||||
completer.complete(count);
|
||||
});
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
Future close() {
|
||||
return new Future.value(finalCount);
|
||||
}
|
||||
}
|
||||
|
||||
class DataProvider {
|
||||
final int chunkSize;
|
||||
final int bytesPerSecond;
|
||||
int sentCount = 0;
|
||||
int targetCount;
|
||||
StreamController controller;
|
||||
Timer pendingSend;
|
||||
|
||||
DataProvider(int this.bytesPerSecond, int this.targetCount, this.chunkSize) {
|
||||
controller = new StreamController(
|
||||
sync: true, onPause: onPauseStateChange, onResume: onPauseStateChange);
|
||||
Timer.run(send);
|
||||
}
|
||||
|
||||
Stream get stream => controller.stream;
|
||||
|
||||
send() {
|
||||
if (pendingSend != null) {
|
||||
pendingSend.cancel();
|
||||
pendingSend = null;
|
||||
}
|
||||
if (controller.isPaused) return;
|
||||
if (sentCount == targetCount) {
|
||||
controller.close();
|
||||
return;
|
||||
}
|
||||
int listSize = chunkSize;
|
||||
sentCount += listSize;
|
||||
if (sentCount > targetCount) {
|
||||
listSize -= sentCount - targetCount;
|
||||
sentCount = targetCount;
|
||||
}
|
||||
controller.add(new List(listSize));
|
||||
int ms = listSize * 1000 ~/ bytesPerSecond;
|
||||
Duration duration = new Duration(milliseconds: ms);
|
||||
if (!controller.isPaused) {
|
||||
pendingSend = new Timer(duration, send);
|
||||
}
|
||||
}
|
||||
|
||||
onPauseStateChange() {
|
||||
// We don't care if we just unpaused or paused. In either case we just
|
||||
// call send which will test it for us.
|
||||
send();
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
asyncStart();
|
||||
// The data provider can deliver 800MB/s of data. It sends 100MB of data to
|
||||
// the slower consumer who can only read 200MB/s. The data is sent in 1MB
|
||||
// chunks.
|
||||
//
|
||||
// This test is limited to 64MB of heap-space (see VMOptions on top of the
|
||||
// file). If the consumer doesn't pause the data-provider it will run out of
|
||||
// heap-space.
|
||||
|
||||
new DataProvider(800 * MB, 100 * MB, 1 * MB)
|
||||
.stream
|
||||
.pipe(new SlowConsumer(200 * MB))
|
||||
.then((count) {
|
||||
Expect.equals(100 * MB, count);
|
||||
asyncEnd();
|
||||
});
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import 'dart:async';
|
||||
|
||||
StackTrace captureStackTrace() {
|
||||
try {
|
||||
throw 0;
|
||||
} catch (e, st) {
|
||||
return st;
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
StackTrace trace = captureStackTrace();
|
||||
asyncStart();
|
||||
var f = new Future.error(499, trace);
|
||||
f.catchError((e, st) {
|
||||
Expect.identical(trace, st);
|
||||
asyncEnd();
|
||||
});
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import 'dart:async';
|
||||
|
||||
main() {
|
||||
StackTrace trace;
|
||||
asyncStart();
|
||||
var f = new Future(() {
|
||||
throw "foo";
|
||||
});
|
||||
f.then((_) => 499).catchError((e, st) {
|
||||
Expect.equals("foo", e);
|
||||
Expect.isNotNull(st);
|
||||
asyncEnd();
|
||||
});
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import 'dart:async';
|
||||
|
||||
StackTrace captureStackTrace() {
|
||||
try {
|
||||
throw 0;
|
||||
} catch (e, st) {
|
||||
return st;
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
StackTrace trace = captureStackTrace();
|
||||
asyncStart();
|
||||
var f = new Future(() => 499);
|
||||
f.then((_) => new Future.error("e", trace)).catchError((e, st) {
|
||||
Expect.equals("e", e);
|
||||
Expect.identical(trace, st);
|
||||
asyncEnd();
|
||||
});
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import 'dart:async';
|
||||
|
||||
StackTrace captureStackTrace() {
|
||||
try {
|
||||
throw 0;
|
||||
} catch (e, st) {
|
||||
return st;
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
StackTrace trace = captureStackTrace();
|
||||
asyncStart();
|
||||
var f = new Future(() => 499);
|
||||
f.then((_) => new Future.error("e", trace)).whenComplete(() => 499).then((_) {
|
||||
throw "should never be reached";
|
||||
}).catchError((e, st) {
|
||||
Expect.equals("e", e);
|
||||
Expect.identical(trace, st);
|
||||
asyncEnd();
|
||||
});
|
||||
}
|
|
@ -22,7 +22,8 @@ async/future_test/none: Skip
|
|||
async/future_test/01: Skip
|
||||
async/future_test/none: Skip
|
||||
async/future_value_chain4_test: Skip
|
||||
async/slow_consumer3_test: Skip
|
||||
async/print_test/01: Skip
|
||||
async/print_test/none: Skip
|
||||
async/stream_controller_test: Skip
|
||||
async/stream_event_transformed_test: Skip
|
||||
async/stream_transformer_test: Skip
|
||||
|
@ -188,7 +189,6 @@ html/custom/regress_194523002_test: Crash # Issue 29922
|
|||
async/future_or_bad_type_test/none: RuntimeError # Issue 29922
|
||||
async/future_or_non_strong_test: RuntimeError # Issue 29922
|
||||
async/futures_test: RuntimeError # Issue 29922
|
||||
async/slow_consumer_test: Pass, Timeout # Issue 29922
|
||||
async/timer_not_available_test: RuntimeError # Issue 29922
|
||||
async/zone_error_callback_test: RuntimeError # Issue 29922
|
||||
async/zone_run_unary_test: RuntimeError # Issue 29922
|
||||
|
|
Loading…
Reference in a new issue