1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00
denoland-deno/js/os_test.ts
2019-02-02 22:05:30 -05:00

34 lines
855 B
TypeScript

// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, testPerm, assert, assertEqual } from "./test_util.ts";
import * as deno from "deno";
testPerm({ env: true }, function envSuccess() {
const env = deno.env();
assert(env !== null);
env.test_var = "Hello World";
const newEnv = deno.env();
assertEqual(env.test_var, newEnv.test_var);
});
test(function envFailure() {
let caughtError = false;
try {
const env = deno.env();
} catch (err) {
caughtError = true;
assertEqual(err.kind, deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied");
}
assert(caughtError);
});
test(function osPid() {
console.log("pid", deno.pid);
assert(deno.pid > 0);
});
// See complete tests in tools/is_tty_test.py
test(function osIsTTYSmoke() {
console.log(deno.isTTY());
});