Files
sdk/tests/standalone_2/io/stdin_has_terminal_test.dart
T
Zachary Anderson 616215df1b [dart:io] Adds Stdin.hasTerminal to mirror Stdout.hasTerminal
fixes #29083

Change-Id: I5f4d7ac2a5df9600fd3ad12abc2dd6068d9980af
Reviewed-on: https://dart-review.googlesource.com/23145
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2017-11-22 22:41:37 +00:00

27 lines
679 B
Dart

// 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.
import "dart:io";
import "package:expect/expect.dart";
void fiddleWithEchoMode() {
final bool echoMode = stdin.echoMode;
stdin.echoMode = false;
stdin.echoMode = true;
stdin.echoMode = echoMode;
}
void main() {
Expect.isNotNull(stdin.hasTerminal);
Expect.isTrue(stdin.hasTerminal is bool);
if (stdin.hasTerminal) {
fiddleWithEchoMode();
} else {
Expect.throws(() {
fiddleWithEchoMode();
}, (e) => e is StdinException);
}
}