mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:30:32 +00:00
e4cc3c98e5
TEST=ci Bug: Contributes to https://github.com/dart-lang/sdk/issues/49529 Change-Id: Ic129ef2d89f625d9ec6a7a1c301cffddd60b2ff7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258920 Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Michael Thomsen <mit@google.com> Reviewed-by: Slava Egorov <vegorov@google.com>
94 lines
2.1 KiB
Dart
94 lines
2.1 KiB
Dart
// Copyright (c) 2019, 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 "dart:async";
|
|
import "dart:isolate";
|
|
import "dart:typed_data";
|
|
import "package:expect/expect.dart";
|
|
|
|
const large = 1 << 30;
|
|
|
|
void child(replyPort) {
|
|
print("Child start");
|
|
|
|
print("Child Uint8List");
|
|
dynamic x = new Uint8List(large);
|
|
for (int i = 0; i < 4; i++) {
|
|
x[i] = i;
|
|
}
|
|
for (int i = x.length - 4; i < x.length; i++) {
|
|
x[i] = x.length - i;
|
|
}
|
|
replyPort.send(x);
|
|
x = null;
|
|
|
|
// Too slow.
|
|
// print("Child Array");
|
|
// x = new List.filled(large, null);
|
|
// for (int i = 0; i < 4; i++) {
|
|
// x[i] = i;
|
|
// }
|
|
// replyPort.send(x);
|
|
// x = null;
|
|
|
|
print("Child OneByteString");
|
|
x = null;
|
|
x = "Z";
|
|
while (x.length < large) {
|
|
x = x * 2;
|
|
}
|
|
replyPort.send(x);
|
|
x = null;
|
|
|
|
print("Child done");
|
|
}
|
|
|
|
Future<void> main(List<String> args) async {
|
|
print("Parent start");
|
|
|
|
ReceivePort port = new ReceivePort();
|
|
Isolate.spawn(child, port.sendPort);
|
|
StreamIterator<dynamic> incoming = new StreamIterator<dynamic>(port);
|
|
|
|
print("Parent Uint8");
|
|
Expect.isTrue(await incoming.moveNext());
|
|
dynamic x = incoming.current;
|
|
Expect.isTrue(x is Uint8List);
|
|
Expect.equals(large, x.length);
|
|
for (int i = 0; i < 4; i++) {
|
|
Expect.equals(i, x[i]);
|
|
}
|
|
for (int i = x.length - 4; i < x.length; i++) {
|
|
Expect.equals(x.length - i, x[i]);
|
|
}
|
|
x = null;
|
|
|
|
// Too slow.
|
|
// print("Parent Array");
|
|
// Expect.isTrue(await incoming.moveNext());
|
|
// x = incoming.current;
|
|
// Expect.isTrue(x is List);
|
|
// Expect.equals(large, x.length);
|
|
// for (int i = 0; i < 4; i++) {
|
|
// Expect.equals(i, x[i]);
|
|
// }
|
|
// x = null;
|
|
|
|
print("Parent OneByteString");
|
|
Expect.isTrue(await incoming.moveNext());
|
|
x = incoming.current;
|
|
Expect.isTrue(x is String);
|
|
Expect.equals(large, x.length);
|
|
for (int i = 0; i < 4; i++) {
|
|
Expect.equals("Z", x[i]);
|
|
}
|
|
for (int i = x.length - 4; i < x.length; i++) {
|
|
Expect.equals("Z", x[i]);
|
|
}
|
|
x = null;
|
|
|
|
port.close();
|
|
print("Parent done");
|
|
}
|