diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2019-02-13 02:08:56 +1100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-02-12 10:08:56 -0500 |
commit | a21a5ad2fa4dcbad58fe63c298c69f8607705bf4 (patch) | |
tree | 03e0092f46813ffdf84f53ab58f71b8a0276207e /js/symlink_test.ts | |
parent | 1e5e091cb074896c7550b1b6f802582f12629048 (diff) |
Add Deno global namespace (#1748)
Resolves #1705
This PR adds the Deno APIs as a global namespace named `Deno`. For backwards
compatibility, the ability to `import * from "deno"` is preserved. I have tried
to convert every test and internal code the references the module to use the
namespace instead, but because I didn't break compatibility I am not sure.
On the REPL, `deno` no longer exists, replaced only with `Deno` to align with
the regular runtime.
The runtime type library includes both the namespace and module. This means it
duplicates the whole type information. When we remove the functionality from the
runtime, it will be a one line change to the library generator to remove the
module definition from the type library.
I marked a `TODO` in a couple places where to remove the `"deno"` module, but
there are additional places I know I didn't mark.
Diffstat (limited to 'js/symlink_test.ts')
-rw-r--r-- | js/symlink_test.ts | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/js/symlink_test.ts b/js/symlink_test.ts index ab8463878..6fa78ac3f 100644 --- a/js/symlink_test.ts +++ b/js/symlink_test.ts @@ -1,25 +1,24 @@ // 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({ read: true, write: true }, function symlinkSyncSuccess() { - const testDir = deno.makeTempDirSync(); + const testDir = Deno.makeTempDirSync(); const oldname = testDir + "/oldname"; const newname = testDir + "/newname"; - deno.mkdirSync(oldname); + Deno.mkdirSync(oldname); let errOnWindows; // Just for now, until we implement symlink for Windows. try { - deno.symlinkSync(oldname, newname); + Deno.symlinkSync(oldname, newname); } catch (e) { errOnWindows = e; } if (errOnWindows) { - assertEqual(errOnWindows.kind, deno.ErrorKind.Other); + assertEqual(errOnWindows.kind, Deno.ErrorKind.Other); assertEqual(errOnWindows.message, "Not implemented"); } else { - const newNameInfoLStat = deno.lstatSync(newname); - const newNameInfoStat = deno.statSync(newname); + const newNameInfoLStat = Deno.lstatSync(newname); + const newNameInfoStat = Deno.statSync(newname); assert(newNameInfoLStat.isSymlink()); assert(newNameInfoStat.isDirectory()); } @@ -28,11 +27,11 @@ testPerm({ read: true, write: true }, function symlinkSyncSuccess() { test(function symlinkSyncPerm() { let err; try { - deno.symlinkSync("oldbaddir", "newbaddir"); + Deno.symlinkSync("oldbaddir", "newbaddir"); } catch (e) { err = e; } - assertEqual(err.kind, deno.ErrorKind.PermissionDenied); + assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEqual(err.name, "PermissionDenied"); }); @@ -40,7 +39,7 @@ test(function symlinkSyncPerm() { testPerm({ write: true }, function symlinkSyncNotImplemented() { let err; try { - deno.symlinkSync("oldname", "newname", "dir"); + Deno.symlinkSync("oldname", "newname", "dir"); } catch (e) { err = e; } @@ -48,23 +47,23 @@ testPerm({ write: true }, function symlinkSyncNotImplemented() { }); testPerm({ read: true, write: true }, async function symlinkSuccess() { - const testDir = deno.makeTempDirSync(); + const testDir = Deno.makeTempDirSync(); const oldname = testDir + "/oldname"; const newname = testDir + "/newname"; - deno.mkdirSync(oldname); + Deno.mkdirSync(oldname); let errOnWindows; // Just for now, until we implement symlink for Windows. try { - await deno.symlink(oldname, newname); + await Deno.symlink(oldname, newname); } catch (e) { errOnWindows = e; } if (errOnWindows) { - assertEqual(errOnWindows.kind, deno.ErrorKind.Other); + assertEqual(errOnWindows.kind, Deno.ErrorKind.Other); assertEqual(errOnWindows.message, "Not implemented"); } else { - const newNameInfoLStat = deno.lstatSync(newname); - const newNameInfoStat = deno.statSync(newname); + const newNameInfoLStat = Deno.lstatSync(newname); + const newNameInfoStat = Deno.statSync(newname); assert(newNameInfoLStat.isSymlink()); assert(newNameInfoStat.isDirectory()); } |