summaryrefslogtreecommitdiff
path: root/js/os_test.ts
blob: 0784fd5e4006016808ef0de2e43163dbbad25e6b (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
// 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());
});