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/resources_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/resources_test.ts')
-rw-r--r-- | js/resources_test.ts | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/js/resources_test.ts b/js/resources_test.ts index 722602c98..65002e164 100644 --- a/js/resources_test.ts +++ b/js/resources_test.ts @@ -1,9 +1,8 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { test, testPerm, assertEqual } from "./test_util.ts"; -import * as deno from "deno"; test(function resourcesStdio() { - const res = deno.resources(); + const res = Deno.resources(); assertEqual(res[0], "stdin"); assertEqual(res[1], "stdout"); @@ -12,12 +11,12 @@ test(function resourcesStdio() { testPerm({ net: true }, async function resourcesNet() { const addr = "127.0.0.1:4501"; - const listener = deno.listen("tcp", addr); + const listener = Deno.listen("tcp", addr); - const dialerConn = await deno.dial("tcp", addr); + const dialerConn = await Deno.dial("tcp", addr); const listenerConn = await listener.accept(); - const res = deno.resources(); + const res = Deno.resources(); assertEqual(Object.values(res).filter(r => r === "tcpListener").length, 1); assertEqual(Object.values(res).filter(r => r === "tcpStream").length, 2); @@ -27,9 +26,9 @@ testPerm({ net: true }, async function resourcesNet() { }); testPerm({ read: true }, async function resourcesFile() { - const resourcesBefore = deno.resources(); - await deno.open("tests/hello.txt"); - const resourcesAfter = deno.resources(); + const resourcesBefore = Deno.resources(); + await Deno.open("tests/hello.txt"); + const resourcesAfter = Deno.resources(); // check that exactly one new resource (file) was added assertEqual( |