blob: 381d20832909408c50ccbf39d0bfdac603483073 [file] [log] [blame]
// Copyright (c) 2017, 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.
/// @assertion void write(Object obj)
/// Converts [obj] to a [String] by invoking [Object.toString] and adds the
/// encoding of the result to the target consumer.
/// @description Checks that objects of the different types can be correctly
/// added to the consumer
/// @author iarkh@unipro.ru
import "../../../Utils/expect.dart";
import "dart:io";
List objects = [
"Testme",
123,
new StackTrace.fromString("Stack trace"),
[1, 2, 3],
null
];
String expected = "Testme123Stack trace[1, 2, 3]null";
run_process(IOSink sink) {
objects.forEach((x) {
sink.write(x);
});
}
run_main(String mode) async {
String executable = Platform.resolvedExecutable;
String eScript = Platform.script.toString();
int called = 0;
await Process.run(
executable, [...Platform.executableArguments, eScript, mode])
.then((ProcessResult results) {
Expect.equals(expected, mode == "err" ? results.stderr : results.stdout);
called++;
});
Expect.equals(1, called);
}
main(List<String> args) {
if (args.length > 0)
run_process(args[0] == "err" ? stderr : stdout);
else {
run_main("out");
run_main("err");
}
}