blob: f5ae77dac8f89ad36b3c79966c4efab564b5ed3b [file] [log] [blame]
/*
* Copyright (c) 2018, 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 String readLineSync({
* Encoding encoding: systemEncoding,
* bool retainNewlines: false
* })
* Synchronously read a line from stdin.
* @description Checks that line is read from stdin.
* @author iarkh@unipro.ru
*/
import "../../../Utils/expect.dart";
import "dart:io";
import "stdin_utils.dart";
run_process() { stdout.write(stdin.readLineSync()); }
run_main() async {
String executable = Platform.resolvedExecutable;
String eScript = Platform.script.toString();
int called = 0;
await Process.start(executable, [eScript, "test"], runInShell: true).then(
(Process process) async {
process.stdin.writeln("Hello");
await process.stdout.toList().then((out) {
Expect.listEquals([72, 101, 108, 108, 111], flattenList<int>(out));
called++;
});
});
Expect.equals(1, called);
}
main(List<String> args) {
args.length > 0 ? run_process() : run_main();
}