2019-01-21 14:03:30 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2018-08-30 13:49:24 -04:00
|
|
|
import { test, testPerm, assert, assertEqual } from "./test_util.ts";
|
|
|
|
import * as deno from "deno";
|
|
|
|
|
2019-01-13 09:39:23 -05:00
|
|
|
testPerm({ env: true }, function envSuccess() {
|
2018-08-31 07:51:12 -04:00
|
|
|
const env = deno.env();
|
|
|
|
assert(env !== null);
|
|
|
|
env.test_var = "Hello World";
|
|
|
|
const newEnv = deno.env();
|
|
|
|
assertEqual(env.test_var, newEnv.test_var);
|
|
|
|
});
|
|
|
|
|
2019-01-13 09:39:23 -05:00
|
|
|
test(function envFailure() {
|
2018-08-31 07:51:12 -04:00
|
|
|
let caughtError = false;
|
|
|
|
try {
|
|
|
|
const env = deno.env();
|
|
|
|
} catch (err) {
|
|
|
|
caughtError = true;
|
2018-09-09 19:28:56 -04:00
|
|
|
assertEqual(err.kind, deno.ErrorKind.PermissionDenied);
|
|
|
|
assertEqual(err.name, "PermissionDenied");
|
2018-08-31 07:51:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
assert(caughtError);
|
|
|
|
});
|
2019-01-06 14:16:42 -05:00
|
|
|
|
|
|
|
test(function osPid() {
|
|
|
|
console.log("pid", deno.pid);
|
|
|
|
assert(deno.pid > 0);
|
|
|
|
});
|
2019-02-02 22:05:30 -05:00
|
|
|
|
|
|
|
// See complete tests in tools/is_tty_test.py
|
|
|
|
test(function osIsTTYSmoke() {
|
|
|
|
console.log(deno.isTTY());
|
|
|
|
});
|