2021-01-11 12:13:41 -05:00
|
|
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
2020-09-27 06:22:32 -04:00
|
|
|
import { assert, assertThrows, unitTest } from "./test_util.ts";
|
2020-02-26 01:01:24 -05:00
|
|
|
|
|
|
|
// Note tests for Deno.setRaw is in integration tests.
|
|
|
|
|
2020-07-10 10:07:12 -04:00
|
|
|
unitTest({ perms: { read: true } }, function consoleSizeFile(): void {
|
|
|
|
const file = Deno.openSync("cli/tests/hello.txt");
|
|
|
|
assertThrows(() => {
|
|
|
|
Deno.consoleSize(file.rid);
|
|
|
|
}, Error);
|
|
|
|
file.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
unitTest(function consoleSizeError(): void {
|
|
|
|
assertThrows(() => {
|
|
|
|
// Absurdly large rid.
|
|
|
|
Deno.consoleSize(0x7fffffff);
|
|
|
|
}, Deno.errors.BadResource);
|
|
|
|
});
|
|
|
|
|
2020-03-04 11:31:14 -05:00
|
|
|
unitTest({ perms: { read: true } }, function isatty(): void {
|
2020-02-26 01:01:24 -05:00
|
|
|
// CI not under TTY, so cannot test stdin/stdout/stderr.
|
|
|
|
const f = Deno.openSync("cli/tests/hello.txt");
|
|
|
|
assert(!Deno.isatty(f.rid));
|
2020-02-29 12:45:47 -05:00
|
|
|
f.close();
|
2020-02-26 01:01:24 -05:00
|
|
|
});
|
|
|
|
|
2020-03-04 11:31:14 -05:00
|
|
|
unitTest(function isattyError(): void {
|
2020-02-26 01:01:24 -05:00
|
|
|
let caught = false;
|
|
|
|
try {
|
|
|
|
// Absurdly large rid.
|
|
|
|
Deno.isatty(0x7fffffff);
|
|
|
|
} catch (e) {
|
|
|
|
caught = true;
|
|
|
|
assert(e instanceof Deno.errors.BadResource);
|
|
|
|
}
|
|
|
|
assert(caught);
|
|
|
|
});
|