blob: b45a43f1a743e3085b488434780df91a36ab8c20 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
import { assert, assertThrows, unitTest } from "./test_util.ts";
// Note tests for Deno.setRaw is in integration tests.
unitTest({ perms: { read: true } }, function consoleSizeFile() {
const file = Deno.openSync("cli/tests/testdata/hello.txt");
assertThrows(() => {
Deno.consoleSize(file.rid);
}, Error);
file.close();
});
unitTest(function consoleSizeError() {
assertThrows(() => {
// Absurdly large rid.
Deno.consoleSize(0x7fffffff);
}, Deno.errors.BadResource);
});
unitTest({ perms: { read: true } }, function isatty() {
// CI not under TTY, so cannot test stdin/stdout/stderr.
const f = Deno.openSync("cli/tests/testdata/hello.txt");
assert(!Deno.isatty(f.rid));
f.close();
});
unitTest(function isattyError() {
let caught = false;
try {
// Absurdly large rid.
Deno.isatty(0x7fffffff);
} catch (e) {
caught = true;
assert(e instanceof Deno.errors.BadResource);
}
assert(caught);
});
|