diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2020-02-25 22:01:24 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-26 01:01:24 -0500 |
commit | 5946808f66aab1983ade3db2541734bb43626a72 (patch) | |
tree | adb526497a9efc29d1b5744ae52449f08f453ef0 /cli/js/tty_test.ts | |
parent | e53064c4f22efeb8a4eda2712e15c77d2699a686 (diff) |
tty: Deno.setRaw(rid, mode) to turn on/off raw mode (#3958)
Diffstat (limited to 'cli/js/tty_test.ts')
-rw-r--r-- | cli/js/tty_test.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cli/js/tty_test.ts b/cli/js/tty_test.ts new file mode 100644 index 000000000..f58784a7c --- /dev/null +++ b/cli/js/tty_test.ts @@ -0,0 +1,22 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +import { test, testPerm, assert } from "./test_util.ts"; + +// Note tests for Deno.setRaw is in integration tests. + +testPerm({ read: true }, function isatty(): void { + // CI not under TTY, so cannot test stdin/stdout/stderr. + const f = Deno.openSync("cli/tests/hello.txt"); + assert(!Deno.isatty(f.rid)); +}); + +test(function isattyError(): void { + let caught = false; + try { + // Absurdly large rid. + Deno.isatty(0x7fffffff); + } catch (e) { + caught = true; + assert(e instanceof Deno.errors.BadResource); + } + assert(caught); +}); |