mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
refactor(cli/tests): remove unnecessary void return types (#11577)
This commit is contained in:
parent
299c7cfe54
commit
3f0cf9619f
121 changed files with 1095 additions and 1177 deletions
|
@ -1,10 +1,10 @@
|
||||||
setTimeout((): void => {
|
setTimeout(() => {
|
||||||
console.log("World");
|
console.log("World");
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
console.log("Hello");
|
console.log("Hello");
|
||||||
|
|
||||||
const id = setTimeout((): void => {
|
const id = setTimeout(() => {
|
||||||
console.log("Not printed");
|
console.log("Not printed");
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Check that we can use the async keyword.
|
// Check that we can use the async keyword.
|
||||||
async function main(): Promise<void> {
|
async function main() {
|
||||||
await new Promise((resolve): void => {
|
await new Promise((resolve) => {
|
||||||
console.log("2");
|
console.log("2");
|
||||||
setTimeout(resolve, 100);
|
setTimeout(resolve, 100);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(async (): Promise<void> => {
|
(async () => {
|
||||||
const { returnsHi, returnsFoo2, printHello3 } = await import(
|
const { returnsHi, returnsFoo2, printHello3 } = await import(
|
||||||
"./subdir/mod1.ts"
|
"./subdir/mod1.ts"
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,6 +4,6 @@ import "./subdir/auto_print_hello.ts";
|
||||||
|
|
||||||
import "./subdir/auto_print_hello.ts";
|
import "./subdir/auto_print_hello.ts";
|
||||||
|
|
||||||
(async (): Promise<void> => {
|
(async () => {
|
||||||
await import("./subdir/auto_print_hello.ts");
|
await import("./subdir/auto_print_hello.ts");
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// This is to test if Deno would die at 2nd await
|
// This is to test if Deno would die at 2nd await
|
||||||
// See https://github.com/denoland/deno/issues/919
|
// See https://github.com/denoland/deno/issues/919
|
||||||
(async (): Promise<void> => {
|
(async () => {
|
||||||
const currDirInfo = await Deno.stat(".");
|
const currDirInfo = await Deno.stat(".");
|
||||||
const parentDirInfo = await Deno.stat("..");
|
const parentDirInfo = await Deno.stat("..");
|
||||||
console.log(currDirInfo.isDirectory);
|
console.log(currDirInfo.isDirectory);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
function fn(): Promise<never> {
|
function fn(): Promise<never> {
|
||||||
throw new Error("message");
|
throw new Error("message");
|
||||||
}
|
}
|
||||||
async function call(): Promise<void> {
|
async function call() {
|
||||||
try {
|
try {
|
||||||
console.log("before await fn()");
|
console.log("before await fn()");
|
||||||
await fn();
|
await fn();
|
||||||
|
@ -11,4 +11,4 @@ async function call(): Promise<void> {
|
||||||
}
|
}
|
||||||
console.log("after try-catch");
|
console.log("after try-catch");
|
||||||
}
|
}
|
||||||
call().catch((): void => console.log("outer catch"));
|
call().catch(() => console.log("outer catch"));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
window.onload = async (): Promise<void> => {
|
window.onload = async () => {
|
||||||
console.log(performance.now() % 2 !== 0);
|
console.log(performance.now() % 2 !== 0);
|
||||||
await Deno.permissions.revoke({ name: "hrtime" });
|
await Deno.permissions.revoke({ name: "hrtime" });
|
||||||
console.log(performance.now() % 2 === 0);
|
console.log(performance.now() % 2 === 0);
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Deno.args.forEach((arg): void => {
|
Deno.args.forEach((arg) => {
|
||||||
console.log(arg);
|
console.log(arg);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { assert } from "../../../test_util/std/testing/asserts.ts";
|
import { assert } from "../../../test_util/std/testing/asserts.ts";
|
||||||
import "./nest_imported.ts";
|
import "./nest_imported.ts";
|
||||||
|
|
||||||
const handler = (e: Event): void => {
|
const handler = (e: Event) => {
|
||||||
assert(!e.cancelable);
|
assert(!e.cancelable);
|
||||||
console.log(`got ${e.type} event in event handler (imported)`);
|
console.log(`got ${e.type} event in event handler (imported)`);
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@ import "./imported.ts";
|
||||||
assert(window.hasOwnProperty("onload"));
|
assert(window.hasOwnProperty("onload"));
|
||||||
assert(window.onload === null);
|
assert(window.onload === null);
|
||||||
|
|
||||||
const eventHandler = (e: Event): void => {
|
const eventHandler = (e: Event) => {
|
||||||
assert(!e.cancelable);
|
assert(!e.cancelable);
|
||||||
console.log(`got ${e.type} event in event handler (main)`);
|
console.log(`got ${e.type} event in event handler (main)`);
|
||||||
};
|
};
|
||||||
|
@ -13,12 +13,12 @@ window.addEventListener("load", eventHandler);
|
||||||
|
|
||||||
window.addEventListener("unload", eventHandler);
|
window.addEventListener("unload", eventHandler);
|
||||||
|
|
||||||
window.onload = (e: Event): void => {
|
window.onload = (e: Event) => {
|
||||||
assert(!e.cancelable);
|
assert(!e.cancelable);
|
||||||
console.log(`got ${e.type} event in onload function`);
|
console.log(`got ${e.type} event in onload function`);
|
||||||
};
|
};
|
||||||
|
|
||||||
window.onunload = (e: Event): void => {
|
window.onunload = (e: Event) => {
|
||||||
assert(!e.cancelable);
|
assert(!e.cancelable);
|
||||||
console.log(`got ${e.type} event in onunload function`);
|
console.log(`got ${e.type} event in onunload function`);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { assert } from "../../../test_util/std/testing/asserts.ts";
|
import { assert } from "../../../test_util/std/testing/asserts.ts";
|
||||||
|
|
||||||
const handler = (e: Event): void => {
|
const handler = (e: Event) => {
|
||||||
assert(!e.cancelable);
|
assert(!e.cancelable);
|
||||||
console.log(`got ${e.type} event in event handler (nest_imported)`);
|
console.log(`got ${e.type} event in event handler (nest_imported)`);
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { assertEquals } from "../../test_util/std/testing/asserts.ts";
|
||||||
|
|
||||||
const addr = Deno.args[1] || "127.0.0.1:4555";
|
const addr = Deno.args[1] || "127.0.0.1:4555";
|
||||||
|
|
||||||
async function proxyServer(): Promise<void> {
|
async function proxyServer() {
|
||||||
const server = serve(addr);
|
const server = serve(addr);
|
||||||
|
|
||||||
console.log(`Proxy server listening on http://${addr}/`);
|
console.log(`Proxy server listening on http://${addr}/`);
|
||||||
|
@ -13,7 +13,7 @@ async function proxyServer(): Promise<void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function proxyRequest(req: ServerRequest): Promise<void> {
|
async function proxyRequest(req: ServerRequest) {
|
||||||
console.log(`Proxy request to: ${req.url}`);
|
console.log(`Proxy request to: ${req.url}`);
|
||||||
const proxyAuthorization = req.headers.get("proxy-authorization");
|
const proxyAuthorization = req.headers.get("proxy-authorization");
|
||||||
if (proxyAuthorization) {
|
if (proxyAuthorization) {
|
||||||
|
@ -31,7 +31,7 @@ async function proxyRequest(req: ServerRequest): Promise<void> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testFetch(): Promise<void> {
|
async function testFetch() {
|
||||||
const c = Deno.run({
|
const c = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
|
@ -52,7 +52,7 @@ async function testFetch(): Promise<void> {
|
||||||
c.close();
|
c.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testModuleDownload(): Promise<void> {
|
async function testModuleDownload() {
|
||||||
const http = Deno.run({
|
const http = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
|
@ -72,7 +72,7 @@ async function testModuleDownload(): Promise<void> {
|
||||||
http.close();
|
http.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testFetchNoProxy(): Promise<void> {
|
async function testFetchNoProxy() {
|
||||||
const c = Deno.run({
|
const c = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
|
@ -94,7 +94,7 @@ async function testFetchNoProxy(): Promise<void> {
|
||||||
c.close();
|
c.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testModuleDownloadNoProxy(): Promise<void> {
|
async function testModuleDownloadNoProxy() {
|
||||||
const http = Deno.run({
|
const http = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
|
@ -115,7 +115,7 @@ async function testModuleDownloadNoProxy(): Promise<void> {
|
||||||
http.close();
|
http.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testFetchProgrammaticProxy(): Promise<void> {
|
async function testFetchProgrammaticProxy() {
|
||||||
const c = Deno.run({
|
const c = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
"code": "file://[WILDCARD]/cli/tests/subdir/subdir2/mod2.ts"
|
"code": "file://[WILDCARD]/cli/tests/subdir/subdir2/mod2.ts"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"size": 320,
|
"size": 308,
|
||||||
"mediaType": "TypeScript",
|
"mediaType": "TypeScript",
|
||||||
"local": "[WILDCARD]mod1.ts",
|
"local": "[WILDCARD]mod1.ts",
|
||||||
[WILDCARD]
|
[WILDCARD]
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
{
|
{
|
||||||
"specifier": "file://[WILDCARD]/cli/tests/subdir/print_hello.ts",
|
"specifier": "file://[WILDCARD]/cli/tests/subdir/print_hello.ts",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"size": 63,
|
"size": 57,
|
||||||
"mediaType": "TypeScript",
|
"mediaType": "TypeScript",
|
||||||
"local": "[WILDCARD]print_hello.ts",
|
"local": "[WILDCARD]print_hello.ts",
|
||||||
[WILDCARD]
|
[WILDCARD]
|
||||||
|
@ -43,11 +43,11 @@
|
||||||
"code": "file://[WILDCARD]/cli/tests/subdir/print_hello.ts"
|
"code": "file://[WILDCARD]/cli/tests/subdir/print_hello.ts"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"size": 163,
|
"size": 157,
|
||||||
"mediaType": "TypeScript",
|
"mediaType": "TypeScript",
|
||||||
"local": "[WILDCARD]mod2.ts",
|
"local": "[WILDCARD]mod2.ts",
|
||||||
[WILDCARD]
|
[WILDCARD]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"size": 757
|
"size": 733
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,10 @@
|
||||||
"code": "file://[WILDCARD]/cli/tests/recursive_imports/common.ts"
|
"code": "file://[WILDCARD]/cli/tests/recursive_imports/common.ts"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"size": 114,
|
"size": 108,
|
||||||
"mediaType": "TypeScript",
|
"mediaType": "TypeScript",
|
||||||
"local": "[WILDCARD]A.ts",
|
"local": "[WILDCARD]A.ts",
|
||||||
"checksum": "da204c16d3114763810864083af8891a887d65fbe34e4c8b5bf985dbc8f0b01f"
|
"checksum": "3b45a105d892584298490cb73372b2cac57118e1e42a677a1d5cacea704d8d3a"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"specifier": "file://[WILDCARD]/cli/tests/recursive_imports/B.ts",
|
"specifier": "file://[WILDCARD]/cli/tests/recursive_imports/B.ts",
|
||||||
|
@ -43,10 +43,10 @@
|
||||||
"code": "file://[WILDCARD]/cli/tests/recursive_imports/common.ts"
|
"code": "file://[WILDCARD]/cli/tests/recursive_imports/common.ts"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"size": 114,
|
"size": 108,
|
||||||
"mediaType": "TypeScript",
|
"mediaType": "TypeScript",
|
||||||
"local": "[WILDCARD]B.ts",
|
"local": "[WILDCARD]B.ts",
|
||||||
"checksum": "060ef62435d7e3a3276e8894307b19cf17772210a20dd091d24a670fadec6b83"
|
"checksum": "b12b0437ef9a91c4a4b1f66e8e4339f986b60bd8134031ccb296ce49df15b54e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"specifier": "file://[WILDCARD]/cli/tests/recursive_imports/C.ts",
|
"specifier": "file://[WILDCARD]/cli/tests/recursive_imports/C.ts",
|
||||||
|
@ -60,19 +60,19 @@
|
||||||
"code": "file://[WILDCARD]/cli/tests/recursive_imports/common.ts"
|
"code": "file://[WILDCARD]/cli/tests/recursive_imports/common.ts"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"size": 132,
|
"size": 126,
|
||||||
"mediaType": "TypeScript",
|
"mediaType": "TypeScript",
|
||||||
"local": "[WILDCARD]C.ts",
|
"local": "[WILDCARD]C.ts",
|
||||||
"checksum": "5190563583617a69f190f1cc76e6552df878df278cfaa5d5e30ebe0938cf5e0b"
|
"checksum": "605875a410741bfaeeade28cbccf45f219ad99d987ea695e35eda75d2c53a658"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"specifier": "file://[WILDCARD]/cli/tests/recursive_imports/common.ts",
|
"specifier": "file://[WILDCARD]/cli/tests/recursive_imports/common.ts",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"size": 34,
|
"size": 28,
|
||||||
"mediaType": "TypeScript",
|
"mediaType": "TypeScript",
|
||||||
"local": "[WILDCARD]common.ts",
|
"local": "[WILDCARD]common.ts",
|
||||||
"checksum": "01b595d69514bfd001ba2cf421feabeaef559513f10697bf1a22781f8a8ed7f0"
|
"checksum": "c70025f0b936c02980c3be1fbd78f6f36b6241927c44ea67580821a6e664d8b3"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"size": 475
|
"size": 451
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { a as defaultA, O } from "./subdir/m.ts";
|
||||||
export { O } from "./subdir/m.ts";
|
export { O } from "./subdir/m.ts";
|
||||||
|
|
||||||
interface AOptions {
|
interface AOptions {
|
||||||
a?(): void;
|
a?();
|
||||||
c?: O;
|
c?: O;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ export function returnsFoo2(): string {
|
||||||
return returnsFoo();
|
return returnsFoo();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function printHello3(): void {
|
export function printHello3() {
|
||||||
printHello2();
|
printHello2();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function throwsError(): void {
|
export function throwsError() {
|
||||||
throw Error("exception from mod1");
|
throw Error("exception from mod1");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { copy } from "../../test_util/std/io/util.ts";
|
import { copy } from "../../test_util/std/io/util.ts";
|
||||||
async function main(): Promise<void> {
|
async function main() {
|
||||||
for (let i = 1; i < Deno.args.length; i++) {
|
for (let i = 1; i < Deno.args.length; i++) {
|
||||||
const filename = Deno.args[i];
|
const filename = Deno.args[i];
|
||||||
const file = await Deno.open(filename);
|
const file = await Deno.open(filename);
|
||||||
|
|
|
@ -2,18 +2,18 @@
|
||||||
const name = Deno.args[0];
|
const name = Deno.args[0];
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
const test: { [key: string]: (...args: any[]) => void | Promise<void> } = {
|
const test: { [key: string]: (...args: any[]) => void | Promise<void> } = {
|
||||||
read(files: string[]): void {
|
read(files: string[]) {
|
||||||
files.forEach((file) => Deno.readFileSync(file));
|
files.forEach((file) => Deno.readFileSync(file));
|
||||||
},
|
},
|
||||||
write(files: string[]): void {
|
write(files: string[]) {
|
||||||
files.forEach((file) =>
|
files.forEach((file) =>
|
||||||
Deno.writeFileSync(file, new Uint8Array(0), { append: true })
|
Deno.writeFileSync(file, new Uint8Array(0), { append: true })
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
netFetch(urls: string[]): void {
|
netFetch(urls: string[]) {
|
||||||
urls.forEach((url) => fetch(url));
|
urls.forEach((url) => fetch(url));
|
||||||
},
|
},
|
||||||
netListen(endpoints: string[]): void {
|
netListen(endpoints: string[]) {
|
||||||
endpoints.forEach((endpoint) => {
|
endpoints.forEach((endpoint) => {
|
||||||
const index = endpoint.lastIndexOf(":");
|
const index = endpoint.lastIndexOf(":");
|
||||||
const [hostname, port] = [
|
const [hostname, port] = [
|
||||||
|
@ -28,7 +28,7 @@ const test: { [key: string]: (...args: any[]) => void | Promise<void> } = {
|
||||||
listener.close();
|
listener.close();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async netConnect(endpoints: string[]): Promise<void> {
|
async netConnect(endpoints: string[]) {
|
||||||
for (const endpoint of endpoints) {
|
for (const endpoint of endpoints) {
|
||||||
const index = endpoint.lastIndexOf(":");
|
const index = endpoint.lastIndexOf(":");
|
||||||
const [hostname, port] = [
|
const [hostname, port] = [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function echo(args: string[]): void {
|
function echo(args: string[]) {
|
||||||
const msg = args.join(", ");
|
const msg = args.join(", ");
|
||||||
Deno.stdout.write(new TextEncoder().encode(msg));
|
Deno.stdout.write(new TextEncoder().encode(msg));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ const [hostname, port] = addr.split(":");
|
||||||
const listener = Deno.listen({ hostname, port: Number(port) });
|
const listener = Deno.listen({ hostname, port: Number(port) });
|
||||||
console.log("listening on", addr);
|
console.log("listening on", addr);
|
||||||
listener.accept().then(
|
listener.accept().then(
|
||||||
async (conn): Promise<void> => {
|
async (conn) => {
|
||||||
console.log("received bytes:", await copy(conn, conn));
|
console.log("received bytes:", await copy(conn, conn));
|
||||||
conn.close();
|
conn.close();
|
||||||
listener.close();
|
listener.close();
|
||||||
|
|
|
@ -2,7 +2,7 @@ function foo(): never {
|
||||||
throw Error("bad");
|
throw Error("bad");
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar(): void {
|
function bar() {
|
||||||
foo();
|
foo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { throwsError } from "./subdir/mod1.ts";
|
import { throwsError } from "./subdir/mod1.ts";
|
||||||
|
|
||||||
function foo(): void {
|
function foo() {
|
||||||
throwsError();
|
throwsError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
(async (): Promise<void> => {
|
(async () => {
|
||||||
const _badModule = await import("./bad-module.ts");
|
const _badModule = await import("./bad-module.ts");
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
(async (): Promise<void> => {
|
(async () => {
|
||||||
const _badModule = await import("bad-module.ts");
|
const _badModule = await import("bad-module.ts");
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const p = (async (): Promise<void> => {
|
const p = (async () => {
|
||||||
await Promise.resolve().then((): never => {
|
await Promise.resolve().then((): never => {
|
||||||
throw new Error("async");
|
throw new Error("async");
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { A } from "./recursive_imports/A.ts";
|
import { A } from "./recursive_imports/A.ts";
|
||||||
|
|
||||||
export function test(): void {
|
export function test() {
|
||||||
A();
|
A();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
function define(_foo: string[]): void {}
|
function define(_foo: string[]) {}
|
||||||
define(["long"]);
|
define(["long"]);
|
||||||
console.log("ok");
|
console.log("ok");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"http://127.0.0.1:4545/cli/tests/subdir/print_hello.ts": "fe7bbccaedb6579200a8b582f905139296402d06b1b91109d6e12c41a23125da",
|
"http://127.0.0.1:4545/cli/tests/subdir/print_hello.ts": "fa6692c8f9ff3fb107e773c3ece5274e9d08be282867a1e3ded1d9c00fcaa63c",
|
||||||
"http://127.0.0.1:4545/cli/tests/003_relative_import.ts": "bad"
|
"http://127.0.0.1:4545/cli/tests/003_relative_import.ts": "bad"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"http://127.0.0.1:4545/cli/tests/subdir/mod1.ts": "bc699ebc05dec9a4baf2109258f03e6ec8dd5498e2f8c5469b62073b3b241657",
|
"http://127.0.0.1:4545/cli/tests/subdir/mod1.ts": "bfc1037b02c99abc20367f739bca7455813a5950066abd77965bff33b6eece0f",
|
||||||
"http://127.0.0.1:4545/cli/tests/subdir/print_hello.ts": "fe7bbccaedb6579200a8b582f905139296402d06b1b91109d6e12c41a23125da",
|
"http://127.0.0.1:4545/cli/tests/subdir/print_hello.ts": "fa6692c8f9ff3fb107e773c3ece5274e9d08be282867a1e3ded1d9c00fcaa63c",
|
||||||
"http://127.0.0.1:4545/cli/tests/subdir/subdir2/mod2.ts": "bad"
|
"http://127.0.0.1:4545/cli/tests/subdir/subdir2/mod2.ts": "bad"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"http://127.0.0.1:4545/cli/tests/subdir/print_hello.ts": "fe7bbccaedb6579200a8b582f905139296402d06b1b91109d6e12c41a23125da",
|
"http://127.0.0.1:4545/cli/tests/subdir/print_hello.ts": "fa6692c8f9ff3fb107e773c3ece5274e9d08be282867a1e3ded1d9c00fcaa63c",
|
||||||
"http://127.0.0.1:4545/cli/tests/003_relative_import.ts": "aa9e16de824f81871a1c7164d5bd6857df7db2e18621750bd66b0bde4df07f21"
|
"http://127.0.0.1:4545/cli/tests/003_relative_import.ts": "aa9e16de824f81871a1c7164d5bd6857df7db2e18621750bd66b0bde4df07f21"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"http://127.0.0.1:4545/cli/tests/013_dynamic_import.ts": "c875f10de49bded1ad76f1709d68e6cf2c0cfb8e8e862542a3fcb4ab09257b99",
|
"http://127.0.0.1:4545/cli/tests/013_dynamic_import.ts": "f0d2d108c100e769cda9f26b74326f21e44cab81611aa7f6cd2b731d4cbc1995",
|
||||||
"http://127.0.0.1:4545/cli/tests/subdir/mod1.ts": "bc699ebc05dec9a4baf2109258f03e6ec8dd5498e2f8c5469b62073b3b241657",
|
"http://127.0.0.1:4545/cli/tests/subdir/mod1.ts": "bfc1037b02c99abc20367f739bca7455813a5950066abd77965bff33b6eece0f",
|
||||||
"http://127.0.0.1:4545/cli/tests/subdir/print_hello.ts": "fe7bbccaedb6579200a8b582f905139296402d06b1b91109d6e12c41a23125da",
|
"http://127.0.0.1:4545/cli/tests/subdir/print_hello.ts": "fa6692c8f9ff3fb107e773c3ece5274e9d08be282867a1e3ded1d9c00fcaa63c",
|
||||||
"http://127.0.0.1:4545/cli/tests/subdir/subdir2/mod2.ts": "bad"
|
"http://127.0.0.1:4545/cli/tests/subdir/subdir2/mod2.ts": "bad"
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,20 @@
|
||||||
const name = Deno.args[0];
|
const name = Deno.args[0];
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
const test: { [key: string]: (...args: any[]) => void | Promise<void> } = {
|
const test: { [key: string]: (...args: any[]) => void | Promise<void> } = {
|
||||||
readRequired(): Promise<void> {
|
readRequired() {
|
||||||
Deno.readFileSync("README.md");
|
Deno.readFileSync("README.md");
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
writeRequired(): void {
|
writeRequired() {
|
||||||
Deno.makeTempDirSync();
|
Deno.makeTempDirSync();
|
||||||
},
|
},
|
||||||
envRequired(): void {
|
envRequired() {
|
||||||
Deno.env.get("home");
|
Deno.env.get("home");
|
||||||
},
|
},
|
||||||
netRequired(): void {
|
netRequired() {
|
||||||
Deno.listen({ transport: "tcp", port: 4541 });
|
Deno.listen({ transport: "tcp", port: 4541 });
|
||||||
},
|
},
|
||||||
runRequired(): void {
|
runRequired() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: Deno.build.os === "windows"
|
cmd: Deno.build.os === "windows"
|
||||||
? ["cmd.exe", "/c", "echo hello"]
|
? ["cmd.exe", "/c", "echo hello"]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { B } from "./B.ts";
|
import { B } from "./B.ts";
|
||||||
import { thing } from "./common.ts";
|
import { thing } from "./common.ts";
|
||||||
|
|
||||||
export function A(): void {
|
export function A() {
|
||||||
thing();
|
thing();
|
||||||
B();
|
B();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { C } from "./C.ts";
|
import { C } from "./C.ts";
|
||||||
import { thing } from "./common.ts";
|
import { thing } from "./common.ts";
|
||||||
|
|
||||||
export function B(): void {
|
export function B() {
|
||||||
thing();
|
thing();
|
||||||
C();
|
C();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { A } from "./A.ts";
|
import { A } from "./A.ts";
|
||||||
import { thing } from "./common.ts";
|
import { thing } from "./common.ts";
|
||||||
|
|
||||||
export function C(): void {
|
export function C() {
|
||||||
if (A != null) {
|
if (A != null) {
|
||||||
thing();
|
thing();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
export function thing(): void {
|
export function thing() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as circular2 from "./circular2.ts";
|
import * as circular2 from "./circular2.ts";
|
||||||
|
|
||||||
export function f1(): void {
|
export function f1() {
|
||||||
console.log("f1");
|
console.log("f1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as circular1 from "./circular1.ts";
|
import * as circular1 from "./circular1.ts";
|
||||||
|
|
||||||
export function f2(): void {
|
export function f2() {
|
||||||
console.log("f2");
|
console.log("f2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ export function returnsFoo2(): string {
|
||||||
return returnsFoo();
|
return returnsFoo();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function printHello3(): void {
|
export function printHello3() {
|
||||||
printHello2();
|
printHello2();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function throwsError(): void {
|
export function throwsError() {
|
||||||
throw Error("exception from mod1");
|
throw Error("exception from mod1");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export function printHello(): void {
|
export function printHello() {
|
||||||
console.log("Hello");
|
console.log("Hello");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(async (): Promise<void> => {
|
(async () => {
|
||||||
const { printHello } = await import("../mod2.ts");
|
const { printHello } = await import("../mod2.ts");
|
||||||
printHello();
|
printHello();
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -4,6 +4,6 @@ export function returnsFoo(): string {
|
||||||
return "Foo";
|
return "Foo";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function printHello2(): void {
|
export function printHello2() {
|
||||||
printHello();
|
printHello();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ function Decorator() {
|
||||||
|
|
||||||
class SomeClass {
|
class SomeClass {
|
||||||
@Decorator()
|
@Decorator()
|
||||||
async test(): Promise<void> {}
|
async test() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
new SomeClass().test();
|
new SomeClass().test();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { foo } from "./export_type_def.ts";
|
import { foo } from "./export_type_def.ts";
|
||||||
|
|
||||||
function bar(a: number): void {
|
function bar(a: number) {
|
||||||
console.log(a);
|
console.log(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ unitTest(function signalCallsOnabort() {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const { signal } = controller;
|
const { signal } = controller;
|
||||||
let called = false;
|
let called = false;
|
||||||
signal.onabort = (evt): void => {
|
signal.onabort = (evt) => {
|
||||||
assert(evt);
|
assert(evt);
|
||||||
assertEquals(evt.type, "abort");
|
assertEquals(evt.type, "abort");
|
||||||
called = true;
|
called = true;
|
||||||
|
@ -41,7 +41,7 @@ unitTest(function onlyAbortsOnce() {
|
||||||
const { signal } = controller;
|
const { signal } = controller;
|
||||||
let called = 0;
|
let called = 0;
|
||||||
signal.addEventListener("abort", () => called++);
|
signal.addEventListener("abort", () => called++);
|
||||||
signal.onabort = (): void => {
|
signal.onabort = () => {
|
||||||
called++;
|
called++;
|
||||||
};
|
};
|
||||||
controller.abort();
|
controller.abort();
|
||||||
|
|
|
@ -7,14 +7,14 @@ import {
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
import { concat } from "../../../test_util/std/bytes/mod.ts";
|
import { concat } from "../../../test_util/std/bytes/mod.ts";
|
||||||
|
|
||||||
unitTest(function blobString(): void {
|
unitTest(function blobString() {
|
||||||
const b1 = new Blob(["Hello World"]);
|
const b1 = new Blob(["Hello World"]);
|
||||||
const str = "Test";
|
const str = "Test";
|
||||||
const b2 = new Blob([b1, str]);
|
const b2 = new Blob([b1, str]);
|
||||||
assertEquals(b2.size, b1.size + str.length);
|
assertEquals(b2.size, b1.size + str.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function blobBuffer(): void {
|
unitTest(function blobBuffer() {
|
||||||
const buffer = new ArrayBuffer(12);
|
const buffer = new ArrayBuffer(12);
|
||||||
const u8 = new Uint8Array(buffer);
|
const u8 = new Uint8Array(buffer);
|
||||||
const f1 = new Float32Array(buffer);
|
const f1 = new Float32Array(buffer);
|
||||||
|
@ -24,7 +24,7 @@ unitTest(function blobBuffer(): void {
|
||||||
assertEquals(b2.size, 3 * u8.length);
|
assertEquals(b2.size, 3 * u8.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function blobSlice(): void {
|
unitTest(function blobSlice() {
|
||||||
const blob = new Blob(["Deno", "Foo"]);
|
const blob = new Blob(["Deno", "Foo"]);
|
||||||
const b1 = blob.slice(0, 3, "Text/HTML");
|
const b1 = blob.slice(0, 3, "Text/HTML");
|
||||||
assert(b1 instanceof Blob);
|
assert(b1 instanceof Blob);
|
||||||
|
@ -38,7 +38,7 @@ unitTest(function blobSlice(): void {
|
||||||
assertEquals(b4.size, blob.size);
|
assertEquals(b4.size, blob.size);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function blobInvalidType(): void {
|
unitTest(function blobInvalidType() {
|
||||||
const blob = new Blob(["foo"], {
|
const blob = new Blob(["foo"], {
|
||||||
type: "\u0521",
|
type: "\u0521",
|
||||||
});
|
});
|
||||||
|
@ -46,7 +46,7 @@ unitTest(function blobInvalidType(): void {
|
||||||
assertEquals(blob.type, "");
|
assertEquals(blob.type, "");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function blobShouldNotThrowError(): void {
|
unitTest(function blobShouldNotThrowError() {
|
||||||
let hasThrown = false;
|
let hasThrown = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -66,7 +66,7 @@ unitTest(function blobShouldNotThrowError(): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
/* TODO https://github.com/denoland/deno/issues/7540
|
/* TODO https://github.com/denoland/deno/issues/7540
|
||||||
unitTest(function nativeEndLine(): void {
|
unitTest(function nativeEndLine() {
|
||||||
const options = {
|
const options = {
|
||||||
ending: "native",
|
ending: "native",
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -76,12 +76,12 @@ unitTest(function nativeEndLine(): void {
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unitTest(async function blobText(): Promise<void> {
|
unitTest(async function blobText() {
|
||||||
const blob = new Blob(["Hello World"]);
|
const blob = new Blob(["Hello World"]);
|
||||||
assertEquals(await blob.text(), "Hello World");
|
assertEquals(await blob.text(), "Hello World");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function blobStream(): Promise<void> {
|
unitTest(async function blobStream() {
|
||||||
const blob = new Blob(["Hello World"]);
|
const blob = new Blob(["Hello World"]);
|
||||||
const stream = blob.stream();
|
const stream = blob.stream();
|
||||||
assert(stream instanceof ReadableStream);
|
assert(stream instanceof ReadableStream);
|
||||||
|
@ -99,18 +99,18 @@ unitTest(async function blobStream(): Promise<void> {
|
||||||
assertEquals(decoder.decode(bytes), "Hello World");
|
assertEquals(decoder.decode(bytes), "Hello World");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function blobArrayBuffer(): Promise<void> {
|
unitTest(async function blobArrayBuffer() {
|
||||||
const uint = new Uint8Array([102, 111, 111]);
|
const uint = new Uint8Array([102, 111, 111]);
|
||||||
const blob = new Blob([uint]);
|
const blob = new Blob([uint]);
|
||||||
assertEquals(await blob.arrayBuffer(), uint.buffer);
|
assertEquals(await blob.arrayBuffer(), uint.buffer);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function blobConstructorNameIsBlob(): void {
|
unitTest(function blobConstructorNameIsBlob() {
|
||||||
const blob = new Blob();
|
const blob = new Blob();
|
||||||
assertEquals(blob.constructor.name, "Blob");
|
assertEquals(blob.constructor.name, "Blob");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function blobCustomInspectFunction(): void {
|
unitTest(function blobCustomInspectFunction() {
|
||||||
const blob = new Blob();
|
const blob = new Blob();
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Deno.inspect(blob),
|
Deno.inspect(blob),
|
||||||
|
|
|
@ -23,7 +23,7 @@ const intArrays = [
|
||||||
Float32Array,
|
Float32Array,
|
||||||
Float64Array,
|
Float64Array,
|
||||||
];
|
];
|
||||||
unitTest(async function arrayBufferFromByteArrays(): Promise<void> {
|
unitTest(async function arrayBufferFromByteArrays() {
|
||||||
const buffer = new TextEncoder().encode("ahoyhoy8").buffer;
|
const buffer = new TextEncoder().encode("ahoyhoy8").buffer;
|
||||||
|
|
||||||
for (const type of intArrays) {
|
for (const type of intArrays) {
|
||||||
|
@ -36,7 +36,7 @@ unitTest(async function arrayBufferFromByteArrays(): Promise<void> {
|
||||||
//FormData
|
//FormData
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function bodyMultipartFormData(): Promise<void> {
|
async function bodyMultipartFormData() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"http://localhost:4545/multipart_form_data.txt",
|
"http://localhost:4545/multipart_form_data.txt",
|
||||||
);
|
);
|
||||||
|
@ -55,7 +55,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function bodyURLEncodedFormData(): Promise<void> {
|
async function bodyURLEncodedFormData() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"http://localhost:4545/cli/tests/subdir/form_urlencoded.txt",
|
"http://localhost:4545/cli/tests/subdir/form_urlencoded.txt",
|
||||||
);
|
);
|
||||||
|
@ -73,14 +73,14 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: {} }, async function bodyURLSearchParams(): Promise<void> {
|
unitTest({ perms: {} }, async function bodyURLSearchParams() {
|
||||||
const body = buildBody(new URLSearchParams({ hello: "world" }));
|
const body = buildBody(new URLSearchParams({ hello: "world" }));
|
||||||
|
|
||||||
const text = await body.text();
|
const text = await body.text();
|
||||||
assertEquals(text, "hello=world");
|
assertEquals(text, "hello=world");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function bodyArrayBufferMultipleParts(): Promise<void> {
|
unitTest(async function bodyArrayBufferMultipleParts() {
|
||||||
const parts: Uint8Array[] = [];
|
const parts: Uint8Array[] = [];
|
||||||
let size = 0;
|
let size = 0;
|
||||||
for (let i = 0; i <= 150000; i++) {
|
for (let i = 0; i <= 150000; i++) {
|
||||||
|
@ -91,7 +91,7 @@ unitTest(async function bodyArrayBufferMultipleParts(): Promise<void> {
|
||||||
|
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
const stream = new ReadableStream({
|
const stream = new ReadableStream({
|
||||||
pull(controller): void {
|
pull(controller) {
|
||||||
// parts.shift() takes forever: https://github.com/denoland/deno/issues/5259
|
// parts.shift() takes forever: https://github.com/denoland/deno/issues/5259
|
||||||
const chunk = parts[offset++];
|
const chunk = parts[offset++];
|
||||||
if (!chunk) return controller.close();
|
if (!chunk) return controller.close();
|
||||||
|
|
|
@ -21,7 +21,7 @@ let testString: string | null;
|
||||||
|
|
||||||
const ignoreMaxSizeTests = true;
|
const ignoreMaxSizeTests = true;
|
||||||
|
|
||||||
function init(): void {
|
function init() {
|
||||||
if (testBytes == null) {
|
if (testBytes == null) {
|
||||||
testBytes = new Uint8Array(N);
|
testBytes = new Uint8Array(N);
|
||||||
for (let i = 0; i < N; i++) {
|
for (let i = 0; i < N; i++) {
|
||||||
|
@ -32,7 +32,7 @@ function init(): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function check(buf: Deno.Buffer, s: string): void {
|
function check(buf: Deno.Buffer, s: string) {
|
||||||
const bytes = buf.bytes();
|
const bytes = buf.bytes();
|
||||||
assertEquals(buf.length, bytes.byteLength);
|
assertEquals(buf.length, bytes.byteLength);
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
|
@ -67,7 +67,7 @@ async function empty(
|
||||||
buf: Deno.Buffer,
|
buf: Deno.Buffer,
|
||||||
s: string,
|
s: string,
|
||||||
fub: Uint8Array,
|
fub: Uint8Array,
|
||||||
): Promise<void> {
|
) {
|
||||||
check(buf, s);
|
check(buf, s);
|
||||||
while (true) {
|
while (true) {
|
||||||
const r = await buf.read(fub);
|
const r = await buf.read(fub);
|
||||||
|
@ -87,7 +87,7 @@ function repeat(c: string, bytes: number): Uint8Array {
|
||||||
return ui8;
|
return ui8;
|
||||||
}
|
}
|
||||||
|
|
||||||
unitTest(function bufferNewBuffer(): void {
|
unitTest(function bufferNewBuffer() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
assert(testString);
|
assert(testString);
|
||||||
|
@ -95,7 +95,7 @@ unitTest(function bufferNewBuffer(): void {
|
||||||
check(buf, testString);
|
check(buf, testString);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function bufferBasicOperations(): Promise<void> {
|
unitTest(async function bufferBasicOperations() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
assert(testString);
|
assert(testString);
|
||||||
|
@ -135,7 +135,7 @@ unitTest(async function bufferBasicOperations(): Promise<void> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function bufferReadEmptyAtEOF(): Promise<void> {
|
unitTest(async function bufferReadEmptyAtEOF() {
|
||||||
// check that EOF of 'buf' is not reached (even though it's empty) if
|
// check that EOF of 'buf' is not reached (even though it's empty) if
|
||||||
// results are written to buffer that has 0 length (ie. it can't store any data)
|
// results are written to buffer that has 0 length (ie. it can't store any data)
|
||||||
const buf = new Deno.Buffer();
|
const buf = new Deno.Buffer();
|
||||||
|
@ -144,7 +144,7 @@ unitTest(async function bufferReadEmptyAtEOF(): Promise<void> {
|
||||||
assertEquals(result, 0);
|
assertEquals(result, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function bufferLargeByteWrites(): Promise<void> {
|
unitTest(async function bufferLargeByteWrites() {
|
||||||
init();
|
init();
|
||||||
const buf = new Deno.Buffer();
|
const buf = new Deno.Buffer();
|
||||||
const limit = 9;
|
const limit = 9;
|
||||||
|
@ -155,7 +155,7 @@ unitTest(async function bufferLargeByteWrites(): Promise<void> {
|
||||||
check(buf, "");
|
check(buf, "");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function bufferTooLargeByteWrites(): Promise<void> {
|
unitTest(async function bufferTooLargeByteWrites() {
|
||||||
init();
|
init();
|
||||||
const tmp = new Uint8Array(72);
|
const tmp = new Uint8Array(72);
|
||||||
const growLen = Number.MAX_VALUE;
|
const growLen = Number.MAX_VALUE;
|
||||||
|
@ -174,7 +174,7 @@ unitTest(async function bufferTooLargeByteWrites(): Promise<void> {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: ignoreMaxSizeTests },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
function bufferGrowWriteMaxBuffer(): void {
|
function bufferGrowWriteMaxBuffer() {
|
||||||
const bufSize = 16 * 1024;
|
const bufSize = 16 * 1024;
|
||||||
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
||||||
for (const capacity of capacities) {
|
for (const capacity of capacities) {
|
||||||
|
@ -196,7 +196,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: ignoreMaxSizeTests },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
async function bufferGrowReadCloseMaxBufferPlus1(): Promise<void> {
|
async function bufferGrowReadCloseMaxBufferPlus1() {
|
||||||
const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1));
|
const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1));
|
||||||
const buf = new Deno.Buffer();
|
const buf = new Deno.Buffer();
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: ignoreMaxSizeTests },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
function bufferGrowReadSyncCloseMaxBufferPlus1(): void {
|
function bufferGrowReadSyncCloseMaxBufferPlus1() {
|
||||||
const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1));
|
const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1));
|
||||||
const buf = new Deno.Buffer();
|
const buf = new Deno.Buffer();
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: ignoreMaxSizeTests },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
function bufferGrowReadSyncCloseToMaxBuffer(): void {
|
function bufferGrowReadSyncCloseToMaxBuffer() {
|
||||||
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
||||||
for (const capacity of capacities) {
|
for (const capacity of capacities) {
|
||||||
const reader = new Deno.Buffer(new ArrayBuffer(capacity));
|
const reader = new Deno.Buffer(new ArrayBuffer(capacity));
|
||||||
|
@ -242,7 +242,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: ignoreMaxSizeTests },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
async function bufferGrowReadCloseToMaxBuffer(): Promise<void> {
|
async function bufferGrowReadCloseToMaxBuffer() {
|
||||||
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
||||||
for (const capacity of capacities) {
|
for (const capacity of capacities) {
|
||||||
const reader = new Deno.Buffer(new ArrayBuffer(capacity));
|
const reader = new Deno.Buffer(new ArrayBuffer(capacity));
|
||||||
|
@ -255,7 +255,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: ignoreMaxSizeTests },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
async function bufferReadCloseToMaxBufferWithInitialGrow(): Promise<void> {
|
async function bufferReadCloseToMaxBufferWithInitialGrow() {
|
||||||
const capacities = [MAX_SIZE, MAX_SIZE - 1, MAX_SIZE - 512];
|
const capacities = [MAX_SIZE, MAX_SIZE - 1, MAX_SIZE - 512];
|
||||||
for (const capacity of capacities) {
|
for (const capacity of capacities) {
|
||||||
const reader = new Deno.Buffer(new ArrayBuffer(capacity));
|
const reader = new Deno.Buffer(new ArrayBuffer(capacity));
|
||||||
|
@ -267,7 +267,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(async function bufferLargeByteReads(): Promise<void> {
|
unitTest(async function bufferLargeByteReads() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
assert(testString);
|
assert(testString);
|
||||||
|
@ -280,12 +280,12 @@ unitTest(async function bufferLargeByteReads(): Promise<void> {
|
||||||
check(buf, "");
|
check(buf, "");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function bufferCapWithPreallocatedSlice(): void {
|
unitTest(function bufferCapWithPreallocatedSlice() {
|
||||||
const buf = new Deno.Buffer(new ArrayBuffer(10));
|
const buf = new Deno.Buffer(new ArrayBuffer(10));
|
||||||
assertEquals(buf.capacity, 10);
|
assertEquals(buf.capacity, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function bufferReadFrom(): Promise<void> {
|
unitTest(async function bufferReadFrom() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
assert(testString);
|
assert(testString);
|
||||||
|
@ -307,7 +307,7 @@ unitTest(async function bufferReadFrom(): Promise<void> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function bufferReadFromSync(): Promise<void> {
|
unitTest(async function bufferReadFromSync() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
assert(testString);
|
assert(testString);
|
||||||
|
@ -329,7 +329,7 @@ unitTest(async function bufferReadFromSync(): Promise<void> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function bufferTestGrow(): Promise<void> {
|
unitTest(async function bufferTestGrow() {
|
||||||
const tmp = new Uint8Array(72);
|
const tmp = new Uint8Array(72);
|
||||||
for (const startLen of [0, 100, 1000, 10000]) {
|
for (const startLen of [0, 100, 1000, 10000]) {
|
||||||
const xBytes = repeat("x", startLen);
|
const xBytes = repeat("x", startLen);
|
||||||
|
@ -353,7 +353,7 @@ unitTest(async function bufferTestGrow(): Promise<void> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function testReadAll(): Promise<void> {
|
unitTest(async function testReadAll() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer);
|
const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer);
|
||||||
|
@ -364,7 +364,7 @@ unitTest(async function testReadAll(): Promise<void> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function testReadAllSync(): void {
|
unitTest(function testReadAllSync() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer);
|
const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer);
|
||||||
|
@ -375,7 +375,7 @@ unitTest(function testReadAllSync(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function testWriteAll(): Promise<void> {
|
unitTest(async function testWriteAll() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
const writer = new Deno.Buffer();
|
const writer = new Deno.Buffer();
|
||||||
|
@ -387,7 +387,7 @@ unitTest(async function testWriteAll(): Promise<void> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function testWriteAllSync(): void {
|
unitTest(function testWriteAllSync() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
const writer = new Deno.Buffer();
|
const writer = new Deno.Buffer();
|
||||||
|
@ -399,7 +399,7 @@ unitTest(function testWriteAllSync(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function testBufferBytesArrayBufferLength(): void {
|
unitTest(function testBufferBytesArrayBufferLength() {
|
||||||
// defaults to copy
|
// defaults to copy
|
||||||
const args = [{}, { copy: undefined }, undefined, { copy: true }];
|
const args = [{}, { copy: undefined }, undefined, { copy: true }];
|
||||||
for (const arg of args) {
|
for (const arg of args) {
|
||||||
|
@ -418,7 +418,7 @@ unitTest(function testBufferBytesArrayBufferLength(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function testBufferBytesCopyFalse(): void {
|
unitTest(function testBufferBytesCopyFalse() {
|
||||||
const bufSize = 64 * 1024;
|
const bufSize = 64 * 1024;
|
||||||
const bytes = new TextEncoder().encode("a".repeat(bufSize));
|
const bytes = new TextEncoder().encode("a".repeat(bufSize));
|
||||||
const reader = new Deno.Buffer();
|
const reader = new Deno.Buffer();
|
||||||
|
@ -433,7 +433,7 @@ unitTest(function testBufferBytesCopyFalse(): void {
|
||||||
assert(actualBytes.buffer.byteLength > actualBytes.byteLength);
|
assert(actualBytes.buffer.byteLength > actualBytes.byteLength);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function testBufferBytesCopyFalseGrowExactBytes(): void {
|
unitTest(function testBufferBytesCopyFalseGrowExactBytes() {
|
||||||
const bufSize = 64 * 1024;
|
const bufSize = 64 * 1024;
|
||||||
const bytes = new TextEncoder().encode("a".repeat(bufSize));
|
const bytes = new TextEncoder().encode("a".repeat(bufSize));
|
||||||
const reader = new Deno.Buffer();
|
const reader = new Deno.Buffer();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assert, unitTest } from "./test_util.ts";
|
import { assert, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function buildInfo(): void {
|
unitTest(function buildInfo() {
|
||||||
// Deno.build is injected by rollup at compile time. Here
|
// Deno.build is injected by rollup at compile time. Here
|
||||||
// we check it has been properly transformed.
|
// we check it has been properly transformed.
|
||||||
const { arch, os } = Deno.build;
|
const { arch, os } = Deno.build;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
function chmodSyncSuccess(): void {
|
function chmodSyncSuccess() {
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const data = enc.encode("Hello");
|
const data = enc.encode("Hello");
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
|
@ -26,7 +26,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
function chmodSyncUrl(): void {
|
function chmodSyncUrl() {
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const data = enc.encode("Hello");
|
const data = enc.encode("Hello");
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
|
@ -49,7 +49,7 @@ unitTest(
|
||||||
ignore: Deno.build.os === "windows",
|
ignore: Deno.build.os === "windows",
|
||||||
perms: { read: true, write: true },
|
perms: { read: true, write: true },
|
||||||
},
|
},
|
||||||
function chmodSyncSymlinkSuccess(): void {
|
function chmodSyncSymlinkSuccess() {
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const data = enc.encode("Hello");
|
const data = enc.encode("Hello");
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
|
@ -75,14 +75,14 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { write: true } }, function chmodSyncFailure(): void {
|
unitTest({ perms: { write: true } }, function chmodSyncFailure() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
const filename = "/badfile.txt";
|
const filename = "/badfile.txt";
|
||||||
Deno.chmodSync(filename, 0o777);
|
Deno.chmodSync(filename, 0o777);
|
||||||
}, Deno.errors.NotFound);
|
}, Deno.errors.NotFound);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { write: false } }, function chmodSyncPerm(): void {
|
unitTest({ perms: { write: false } }, function chmodSyncPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.chmodSync("/somefile.txt", 0o777);
|
Deno.chmodSync("/somefile.txt", 0o777);
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -90,7 +90,7 @@ unitTest({ perms: { write: false } }, function chmodSyncPerm(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
async function chmodSuccess(): Promise<void> {
|
async function chmodSuccess() {
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const data = enc.encode("Hello");
|
const data = enc.encode("Hello");
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
|
@ -107,7 +107,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
async function chmodUrl(): Promise<void> {
|
async function chmodUrl() {
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const data = enc.encode("Hello");
|
const data = enc.encode("Hello");
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
|
@ -131,7 +131,7 @@ unitTest(
|
||||||
ignore: Deno.build.os === "windows",
|
ignore: Deno.build.os === "windows",
|
||||||
perms: { read: true, write: true },
|
perms: { read: true, write: true },
|
||||||
},
|
},
|
||||||
async function chmodSymlinkSuccess(): Promise<void> {
|
async function chmodSymlinkSuccess() {
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const data = enc.encode("Hello");
|
const data = enc.encode("Hello");
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
|
@ -157,18 +157,14 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { write: true } }, async function chmodFailure(): Promise<
|
unitTest({ perms: { write: true } }, async function chmodFailure() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
const filename = "/badfile.txt";
|
const filename = "/badfile.txt";
|
||||||
await Deno.chmod(filename, 0o777);
|
await Deno.chmod(filename, 0o777);
|
||||||
}, Deno.errors.NotFound);
|
}, Deno.errors.NotFound);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { write: false } }, async function chmodPerm(): Promise<
|
unitTest({ perms: { write: false } }, async function chmodPerm() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.chmod("/somefile.txt", 0o777);
|
await Deno.chmod("/somefile.txt", 0o777);
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
|
|
@ -31,7 +31,7 @@ async function getUidAndGid(): Promise<{ uid: number; gid: number }> {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os == "windows" },
|
{ ignore: Deno.build.os == "windows" },
|
||||||
async function chownNoWritePermission(): Promise<void> {
|
async function chownNoWritePermission() {
|
||||||
const filePath = "chown_test_file.txt";
|
const filePath = "chown_test_file.txt";
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.chown(filePath, 1000, 1000);
|
await Deno.chown(filePath, 1000, 1000);
|
||||||
|
@ -41,7 +41,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
||||||
async function chownSyncFileNotExist(): Promise<void> {
|
async function chownSyncFileNotExist() {
|
||||||
const { uid, gid } = await getUidAndGid();
|
const { uid, gid } = await getUidAndGid();
|
||||||
const filePath = Deno.makeTempDirSync() + "/chown_test_file.txt";
|
const filePath = Deno.makeTempDirSync() + "/chown_test_file.txt";
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
||||||
async function chownFileNotExist(): Promise<void> {
|
async function chownFileNotExist() {
|
||||||
const { uid, gid } = await getUidAndGid();
|
const { uid, gid } = await getUidAndGid();
|
||||||
const filePath = (await Deno.makeTempDir()) + "/chown_test_file.txt";
|
const filePath = (await Deno.makeTempDir()) + "/chown_test_file.txt";
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true }, ignore: Deno.build.os == "windows" },
|
{ perms: { write: true }, ignore: Deno.build.os == "windows" },
|
||||||
function chownSyncPermissionDenied(): void {
|
function chownSyncPermissionDenied() {
|
||||||
const dirPath = Deno.makeTempDirSync();
|
const dirPath = Deno.makeTempDirSync();
|
||||||
const filePath = dirPath + "/chown_test_file.txt";
|
const filePath = dirPath + "/chown_test_file.txt";
|
||||||
Deno.writeTextFileSync(filePath, "Hello");
|
Deno.writeTextFileSync(filePath, "Hello");
|
||||||
|
@ -80,7 +80,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true }, ignore: Deno.build.os == "windows" },
|
{ perms: { write: true }, ignore: Deno.build.os == "windows" },
|
||||||
async function chownPermissionDenied(): Promise<void> {
|
async function chownPermissionDenied() {
|
||||||
const dirPath = await Deno.makeTempDir();
|
const dirPath = await Deno.makeTempDir();
|
||||||
const filePath = dirPath + "/chown_test_file.txt";
|
const filePath = dirPath + "/chown_test_file.txt";
|
||||||
await Deno.writeTextFile(filePath, "Hello");
|
await Deno.writeTextFile(filePath, "Hello");
|
||||||
|
@ -95,7 +95,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
||||||
async function chownSyncSucceed(): Promise<void> {
|
async function chownSyncSucceed() {
|
||||||
// TODO(bartlomieju): when a file's owner is actually being changed,
|
// TODO(bartlomieju): when a file's owner is actually being changed,
|
||||||
// chown only succeeds if run under priviledged user (root)
|
// chown only succeeds if run under priviledged user (root)
|
||||||
// The test script has no such privilege, so need to find a better way to test this case
|
// The test script has no such privilege, so need to find a better way to test this case
|
||||||
|
@ -115,7 +115,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
||||||
async function chownSyncWithUrl(): Promise<void> {
|
async function chownSyncWithUrl() {
|
||||||
const { uid, gid } = await getUidAndGid();
|
const { uid, gid } = await getUidAndGid();
|
||||||
const dirPath = Deno.makeTempDirSync();
|
const dirPath = Deno.makeTempDirSync();
|
||||||
const fileUrl = new URL(`file://${dirPath}/chown_test_file.txt`);
|
const fileUrl = new URL(`file://${dirPath}/chown_test_file.txt`);
|
||||||
|
@ -127,7 +127,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
||||||
async function chownSucceed(): Promise<void> {
|
async function chownSucceed() {
|
||||||
const { uid, gid } = await getUidAndGid();
|
const { uid, gid } = await getUidAndGid();
|
||||||
const dirPath = await Deno.makeTempDir();
|
const dirPath = await Deno.makeTempDir();
|
||||||
const filePath = dirPath + "/chown_test_file.txt";
|
const filePath = dirPath + "/chown_test_file.txt";
|
||||||
|
@ -139,7 +139,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
||||||
async function chownUidOnly(): Promise<void> {
|
async function chownUidOnly() {
|
||||||
const { uid } = await getUidAndGid();
|
const { uid } = await getUidAndGid();
|
||||||
const dirPath = await Deno.makeTempDir();
|
const dirPath = await Deno.makeTempDir();
|
||||||
const filePath = dirPath + "/chown_test_file.txt";
|
const filePath = dirPath + "/chown_test_file.txt";
|
||||||
|
@ -151,7 +151,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
{ perms: { run: true, write: true }, ignore: Deno.build.os == "windows" },
|
||||||
async function chownWithUrl(): Promise<void> {
|
async function chownWithUrl() {
|
||||||
// TODO(bartlomieju): same as chownSyncSucceed
|
// TODO(bartlomieju): same as chownSyncSucceed
|
||||||
const { uid, gid } = await getUidAndGid();
|
const { uid, gid } = await getUidAndGid();
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ function cssToAnsiEsc(css: Css, prevCss: Css | null = null): string {
|
||||||
|
|
||||||
// test cases from web-platform-tests
|
// test cases from web-platform-tests
|
||||||
// via https://github.com/web-platform-tests/wpt/blob/master/console/console-is-a-namespace.any.js
|
// via https://github.com/web-platform-tests/wpt/blob/master/console/console-is-a-namespace.any.js
|
||||||
unitTest(function consoleShouldBeANamespace(): void {
|
unitTest(function consoleShouldBeANamespace() {
|
||||||
const prototype1 = Object.getPrototypeOf(console);
|
const prototype1 = Object.getPrototypeOf(console);
|
||||||
const prototype2 = Object.getPrototypeOf(prototype1);
|
const prototype2 = Object.getPrototypeOf(prototype1);
|
||||||
|
|
||||||
|
@ -72,12 +72,12 @@ unitTest(function consoleShouldBeANamespace(): void {
|
||||||
assertEquals(prototype2, Object.prototype);
|
assertEquals(prototype2, Object.prototype);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleHasRightInstance(): void {
|
unitTest(function consoleHasRightInstance() {
|
||||||
assert(console instanceof Console);
|
assert(console instanceof Console);
|
||||||
assertEquals({} instanceof Console, false);
|
assertEquals({} instanceof Console, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestAssertShouldNotThrowError(): void {
|
unitTest(function consoleTestAssertShouldNotThrowError() {
|
||||||
mockConsole((console) => {
|
mockConsole((console) => {
|
||||||
console.assert(true);
|
console.assert(true);
|
||||||
let hasThrown = undefined;
|
let hasThrown = undefined;
|
||||||
|
@ -91,14 +91,14 @@ unitTest(function consoleTestAssertShouldNotThrowError(): void {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestStringifyComplexObjects(): void {
|
unitTest(function consoleTestStringifyComplexObjects() {
|
||||||
assertEquals(stringify("foo"), "foo");
|
assertEquals(stringify("foo"), "foo");
|
||||||
assertEquals(stringify(["foo", "bar"]), `[ "foo", "bar" ]`);
|
assertEquals(stringify(["foo", "bar"]), `[ "foo", "bar" ]`);
|
||||||
assertEquals(stringify({ foo: "bar" }), `{ foo: "bar" }`);
|
assertEquals(stringify({ foo: "bar" }), `{ foo: "bar" }`);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
function consoleTestStringifyComplexObjectsWithEscapedSequences(): void {
|
function consoleTestStringifyComplexObjectsWithEscapedSequences() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stringify(
|
stringify(
|
||||||
["foo\b", "foo\f", "foo\n", "foo\r", "foo\t", "foo\v", "foo\0"],
|
["foo\b", "foo\f", "foo\n", "foo\r", "foo\t", "foo\v", "foo\0"],
|
||||||
|
@ -167,14 +167,14 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(function consoleTestStringifyQuotes(): void {
|
unitTest(function consoleTestStringifyQuotes() {
|
||||||
assertEquals(stringify(["\\"]), `[ "\\\\" ]`);
|
assertEquals(stringify(["\\"]), `[ "\\\\" ]`);
|
||||||
assertEquals(stringify(['\\,"']), `[ '\\\\,"' ]`);
|
assertEquals(stringify(['\\,"']), `[ '\\\\,"' ]`);
|
||||||
assertEquals(stringify([`\\,",'`]), `[ \`\\\\,",'\` ]`);
|
assertEquals(stringify([`\\,",'`]), `[ \`\\\\,",'\` ]`);
|
||||||
assertEquals(stringify(["\\,\",',`"]), `[ "\\\\,\\",',\`" ]`);
|
assertEquals(stringify(["\\,\",',`"]), `[ "\\\\,\\",',\`" ]`);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestStringifyLongStrings(): void {
|
unitTest(function consoleTestStringifyLongStrings() {
|
||||||
const veryLongString = "a".repeat(200);
|
const veryLongString = "a".repeat(200);
|
||||||
// If we stringify an object containing the long string, it gets abbreviated.
|
// If we stringify an object containing the long string, it gets abbreviated.
|
||||||
let actual = stringify({ veryLongString });
|
let actual = stringify({ veryLongString });
|
||||||
|
@ -185,7 +185,7 @@ unitTest(function consoleTestStringifyLongStrings(): void {
|
||||||
assertEquals(actual, veryLongString);
|
assertEquals(actual, veryLongString);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestStringifyCircular(): void {
|
unitTest(function consoleTestStringifyCircular() {
|
||||||
class Base {
|
class Base {
|
||||||
a = 1;
|
a = 1;
|
||||||
m1() {}
|
m1() {}
|
||||||
|
@ -283,11 +283,11 @@ unitTest(function consoleTestStringifyCircular(): void {
|
||||||
assertEquals(stringify(undefined), "undefined");
|
assertEquals(stringify(undefined), "undefined");
|
||||||
assertEquals(stringify(new Extended()), "Extended { a: 1, b: 2 }");
|
assertEquals(stringify(new Extended()), "Extended { a: 1, b: 2 }");
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stringify(function f(): void {}),
|
stringify(function f() {}),
|
||||||
"[Function: f]",
|
"[Function: f]",
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stringify(async function af(): Promise<void> {}),
|
stringify(async function af() {}),
|
||||||
"[AsyncFunction: af]",
|
"[AsyncFunction: af]",
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
@ -354,7 +354,7 @@ unitTest(function consoleTestStringifyCircular(): void {
|
||||||
assertEquals(stripColor(Deno.inspect(nestedObj)), nestedObjExpected);
|
assertEquals(stripColor(Deno.inspect(nestedObj)), nestedObjExpected);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestStringifyFunctionWithPrototypeRemoved(): void {
|
unitTest(function consoleTestStringifyFunctionWithPrototypeRemoved() {
|
||||||
const f = function f() {};
|
const f = function f() {};
|
||||||
Reflect.setPrototypeOf(f, null);
|
Reflect.setPrototypeOf(f, null);
|
||||||
assertEquals(stringify(f), "[Function: f]");
|
assertEquals(stringify(f), "[Function: f]");
|
||||||
|
@ -369,7 +369,7 @@ unitTest(function consoleTestStringifyFunctionWithPrototypeRemoved(): void {
|
||||||
assertEquals(stringify(agf), "[Function: agf]");
|
assertEquals(stringify(agf), "[Function: agf]");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestStringifyFunctionWithProperties(): void {
|
unitTest(function consoleTestStringifyFunctionWithProperties() {
|
||||||
const f = () => "test";
|
const f = () => "test";
|
||||||
f.x = () => "foo";
|
f.x = () => "foo";
|
||||||
f.y = 3;
|
f.y = 3;
|
||||||
|
@ -413,7 +413,7 @@ unitTest(function consoleTestStringifyFunctionWithProperties(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestStringifyWithDepth(): void {
|
unitTest(function consoleTestStringifyWithDepth() {
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
const nestedObj: any = { a: { b: { c: { d: { e: { f: 42 } } } } } };
|
const nestedObj: any = { a: { b: { c: { d: { e: { f: 42 } } } } } };
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
@ -436,7 +436,7 @@ unitTest(function consoleTestStringifyWithDepth(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestStringifyLargeObject(): void {
|
unitTest(function consoleTestStringifyLargeObject() {
|
||||||
const obj = {
|
const obj = {
|
||||||
a: 2,
|
a: 2,
|
||||||
o: {
|
o: {
|
||||||
|
@ -768,7 +768,7 @@ unitTest(function consoleTestStringifyIterable() {
|
||||||
*/
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestStringifyIterableWhenGrouped(): void {
|
unitTest(function consoleTestStringifyIterableWhenGrouped() {
|
||||||
const withOddNumberOfEls = new Float64Array(
|
const withOddNumberOfEls = new Float64Array(
|
||||||
[
|
[
|
||||||
2.1,
|
2.1,
|
||||||
|
@ -846,7 +846,7 @@ unitTest(function consoleTestStringifyIterableWhenGrouped(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function consoleTestStringifyPromises(): Promise<void> {
|
unitTest(async function consoleTestStringifyPromises() {
|
||||||
const pendingPromise = new Promise((_res, _rej) => {});
|
const pendingPromise = new Promise((_res, _rej) => {});
|
||||||
assertEquals(stringify(pendingPromise), "Promise { <pending> }");
|
assertEquals(stringify(pendingPromise), "Promise { <pending> }");
|
||||||
|
|
||||||
|
@ -869,7 +869,7 @@ unitTest(async function consoleTestStringifyPromises(): Promise<void> {
|
||||||
assertEquals(strLines[1], " <rejected> Error: Whoops");
|
assertEquals(strLines[1], " <rejected> Error: Whoops");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestWithCustomInspector(): void {
|
unitTest(function consoleTestWithCustomInspector() {
|
||||||
class A {
|
class A {
|
||||||
[customInspect](): string {
|
[customInspect](): string {
|
||||||
return "b";
|
return "b";
|
||||||
|
@ -879,7 +879,7 @@ unitTest(function consoleTestWithCustomInspector(): void {
|
||||||
assertEquals(stringify(new A()), "b");
|
assertEquals(stringify(new A()), "b");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestWithCustomInspectorUsingInspectFunc(): void {
|
unitTest(function consoleTestWithCustomInspectorUsingInspectFunc() {
|
||||||
class A {
|
class A {
|
||||||
[customInspect](
|
[customInspect](
|
||||||
inspect: (v: unknown, opts?: Deno.InspectOptions) => string,
|
inspect: (v: unknown, opts?: Deno.InspectOptions) => string,
|
||||||
|
@ -891,7 +891,7 @@ unitTest(function consoleTestWithCustomInspectorUsingInspectFunc(): void {
|
||||||
assertEquals(stringify(new A()), "b { c: 1 }");
|
assertEquals(stringify(new A()), "b { c: 1 }");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestWithCustomInspectorError(): void {
|
unitTest(function consoleTestWithCustomInspectorError() {
|
||||||
class A {
|
class A {
|
||||||
[customInspect](): never {
|
[customInspect](): never {
|
||||||
throw new Error("BOOM");
|
throw new Error("BOOM");
|
||||||
|
@ -913,7 +913,7 @@ unitTest(function consoleTestWithCustomInspectorError(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestWithCustomInspectFunction(): void {
|
unitTest(function consoleTestWithCustomInspectFunction() {
|
||||||
function a() {}
|
function a() {}
|
||||||
Object.assign(a, {
|
Object.assign(a, {
|
||||||
[customInspect]() {
|
[customInspect]() {
|
||||||
|
@ -924,7 +924,7 @@ unitTest(function consoleTestWithCustomInspectFunction(): void {
|
||||||
assertEquals(stringify(a), "b");
|
assertEquals(stringify(a), "b");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestWithIntegerFormatSpecifier(): void {
|
unitTest(function consoleTestWithIntegerFormatSpecifier() {
|
||||||
assertEquals(stringify("%i"), "%i");
|
assertEquals(stringify("%i"), "%i");
|
||||||
assertEquals(stringify("%i", 42.0), "42");
|
assertEquals(stringify("%i", 42.0), "42");
|
||||||
assertEquals(stringify("%i", 42), "42");
|
assertEquals(stringify("%i", 42), "42");
|
||||||
|
@ -942,7 +942,7 @@ unitTest(function consoleTestWithIntegerFormatSpecifier(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestWithFloatFormatSpecifier(): void {
|
unitTest(function consoleTestWithFloatFormatSpecifier() {
|
||||||
assertEquals(stringify("%f"), "%f");
|
assertEquals(stringify("%f"), "%f");
|
||||||
assertEquals(stringify("%f", 42.0), "42");
|
assertEquals(stringify("%f", 42.0), "42");
|
||||||
assertEquals(stringify("%f", 42), "42");
|
assertEquals(stringify("%f", 42), "42");
|
||||||
|
@ -957,7 +957,7 @@ unitTest(function consoleTestWithFloatFormatSpecifier(): void {
|
||||||
assertEquals(stringify("%f %f", 42), "42 %f");
|
assertEquals(stringify("%f %f", 42), "42 %f");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestWithStringFormatSpecifier(): void {
|
unitTest(function consoleTestWithStringFormatSpecifier() {
|
||||||
assertEquals(stringify("%s"), "%s");
|
assertEquals(stringify("%s"), "%s");
|
||||||
assertEquals(stringify("%s", undefined), "undefined");
|
assertEquals(stringify("%s", undefined), "undefined");
|
||||||
assertEquals(stringify("%s", "foo"), "foo");
|
assertEquals(stringify("%s", "foo"), "foo");
|
||||||
|
@ -968,7 +968,7 @@ unitTest(function consoleTestWithStringFormatSpecifier(): void {
|
||||||
assertEquals(stringify("%s", Symbol("foo")), "Symbol(foo)");
|
assertEquals(stringify("%s", Symbol("foo")), "Symbol(foo)");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestWithObjectFormatSpecifier(): void {
|
unitTest(function consoleTestWithObjectFormatSpecifier() {
|
||||||
assertEquals(stringify("%o"), "%o");
|
assertEquals(stringify("%o"), "%o");
|
||||||
assertEquals(stringify("%o", 42), "42");
|
assertEquals(stringify("%o", 42), "42");
|
||||||
assertEquals(stringify("%o", "foo"), `"foo"`);
|
assertEquals(stringify("%o", "foo"), `"foo"`);
|
||||||
|
@ -980,13 +980,13 @@ unitTest(function consoleTestWithObjectFormatSpecifier(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestWithStyleSpecifier(): void {
|
unitTest(function consoleTestWithStyleSpecifier() {
|
||||||
assertEquals(stringify("%cfoo%cbar"), "%cfoo%cbar");
|
assertEquals(stringify("%cfoo%cbar"), "%cfoo%cbar");
|
||||||
assertEquals(stringify("%cfoo%cbar", ""), "foo%cbar");
|
assertEquals(stringify("%cfoo%cbar", ""), "foo%cbar");
|
||||||
assertEquals(stripColor(stringify("%cfoo%cbar", "", "color: red")), "foobar");
|
assertEquals(stripColor(stringify("%cfoo%cbar", "", "color: red")), "foobar");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleParseCssColor(): void {
|
unitTest(function consoleParseCssColor() {
|
||||||
assertEquals(parseCssColor("black"), [0, 0, 0]);
|
assertEquals(parseCssColor("black"), [0, 0, 0]);
|
||||||
assertEquals(parseCssColor("darkmagenta"), [139, 0, 139]);
|
assertEquals(parseCssColor("darkmagenta"), [139, 0, 139]);
|
||||||
assertEquals(parseCssColor("slateblue"), [106, 90, 205]);
|
assertEquals(parseCssColor("slateblue"), [106, 90, 205]);
|
||||||
|
@ -1005,7 +1005,7 @@ unitTest(function consoleParseCssColor(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleParseCss(): void {
|
unitTest(function consoleParseCss() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
parseCss("background-color: red"),
|
parseCss("background-color: red"),
|
||||||
{ ...DEFAULT_CSS, backgroundColor: [255, 0, 0] },
|
{ ...DEFAULT_CSS, backgroundColor: [255, 0, 0] },
|
||||||
|
@ -1059,7 +1059,7 @@ unitTest(function consoleParseCss(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleCssToAnsi(): void {
|
unitTest(function consoleCssToAnsi() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
cssToAnsiEsc({ ...DEFAULT_CSS, backgroundColor: [200, 201, 202] }),
|
cssToAnsiEsc({ ...DEFAULT_CSS, backgroundColor: [200, 201, 202] }),
|
||||||
"_[48;2;200;201;202m",
|
"_[48;2;200;201;202m",
|
||||||
|
@ -1099,7 +1099,7 @@ unitTest(function consoleCssToAnsi(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestWithVariousOrInvalidFormatSpecifier(): void {
|
unitTest(function consoleTestWithVariousOrInvalidFormatSpecifier() {
|
||||||
assertEquals(stringify("%s:%s"), "%s:%s");
|
assertEquals(stringify("%s:%s"), "%s:%s");
|
||||||
assertEquals(stringify("%i:%i"), "%i:%i");
|
assertEquals(stringify("%i:%i"), "%i:%i");
|
||||||
assertEquals(stringify("%d:%d"), "%d:%d");
|
assertEquals(stringify("%d:%d"), "%d:%d");
|
||||||
|
@ -1115,13 +1115,13 @@ unitTest(function consoleTestWithVariousOrInvalidFormatSpecifier(): void {
|
||||||
assertEquals(stringify("abc%", 1), "abc% 1");
|
assertEquals(stringify("abc%", 1), "abc% 1");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestCallToStringOnLabel(): void {
|
unitTest(function consoleTestCallToStringOnLabel() {
|
||||||
const methods = ["count", "countReset", "time", "timeLog", "timeEnd"];
|
const methods = ["count", "countReset", "time", "timeLog", "timeEnd"];
|
||||||
mockConsole((console) => {
|
mockConsole((console) => {
|
||||||
for (const method of methods) {
|
for (const method of methods) {
|
||||||
let hasCalled = false;
|
let hasCalled = false;
|
||||||
console[method]({
|
console[method]({
|
||||||
toString(): void {
|
toString() {
|
||||||
hasCalled = true;
|
hasCalled = true;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1130,7 +1130,7 @@ unitTest(function consoleTestCallToStringOnLabel(): void {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestError(): void {
|
unitTest(function consoleTestError() {
|
||||||
class MyError extends Error {
|
class MyError extends Error {
|
||||||
constructor(errStr: string) {
|
constructor(errStr: string) {
|
||||||
super(errStr);
|
super(errStr);
|
||||||
|
@ -1148,7 +1148,7 @@ unitTest(function consoleTestError(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function consoleTestClear(): void {
|
unitTest(function consoleTestClear() {
|
||||||
mockConsole((console, out) => {
|
mockConsole((console, out) => {
|
||||||
console.clear();
|
console.clear();
|
||||||
assertEquals(out.toString(), "\x1b[1;1H" + "\x1b[0J");
|
assertEquals(out.toString(), "\x1b[1;1H" + "\x1b[0J");
|
||||||
|
@ -1156,7 +1156,7 @@ unitTest(function consoleTestClear(): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test bound this issue
|
// Test bound this issue
|
||||||
unitTest(function consoleDetachedLog(): void {
|
unitTest(function consoleDetachedLog() {
|
||||||
mockConsole((console) => {
|
mockConsole((console) => {
|
||||||
const log = console.log;
|
const log = console.log;
|
||||||
const dir = console.dir;
|
const dir = console.dir;
|
||||||
|
@ -1197,7 +1197,7 @@ unitTest(function consoleDetachedLog(): void {
|
||||||
|
|
||||||
class StringBuffer {
|
class StringBuffer {
|
||||||
chunks: string[] = [];
|
chunks: string[] = [];
|
||||||
add(x: string): void {
|
add(x: string) {
|
||||||
this.chunks.push(x);
|
this.chunks.push(x);
|
||||||
}
|
}
|
||||||
toString(): string {
|
toString(): string {
|
||||||
|
@ -1213,12 +1213,12 @@ type ConsoleExamineFunc = (
|
||||||
both?: StringBuffer,
|
both?: StringBuffer,
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
function mockConsole(f: ConsoleExamineFunc): void {
|
function mockConsole(f: ConsoleExamineFunc) {
|
||||||
const out = new StringBuffer();
|
const out = new StringBuffer();
|
||||||
const err = new StringBuffer();
|
const err = new StringBuffer();
|
||||||
const both = new StringBuffer();
|
const both = new StringBuffer();
|
||||||
const csl = new Console(
|
const csl = new Console(
|
||||||
(x: string, level: number, printsNewLine: boolean): void => {
|
(x: string, level: number, printsNewLine: boolean) => {
|
||||||
const content = x + (printsNewLine ? "\n" : "");
|
const content = x + (printsNewLine ? "\n" : "");
|
||||||
const buf = level > 1 ? err : out;
|
const buf = level > 1 ? err : out;
|
||||||
buf.add(content);
|
buf.add(content);
|
||||||
|
@ -1229,8 +1229,8 @@ function mockConsole(f: ConsoleExamineFunc): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.group test
|
// console.group test
|
||||||
unitTest(function consoleGroup(): void {
|
unitTest(function consoleGroup() {
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.group("1");
|
console.group("1");
|
||||||
console.log("2");
|
console.log("2");
|
||||||
console.group("3");
|
console.group("3");
|
||||||
|
@ -1254,8 +1254,8 @@ unitTest(function consoleGroup(): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.group with console.warn test
|
// console.group with console.warn test
|
||||||
unitTest(function consoleGroupWarn(): void {
|
unitTest(function consoleGroupWarn() {
|
||||||
mockConsole((console, _out, _err, both): void => {
|
mockConsole((console, _out, _err, both) => {
|
||||||
assert(both);
|
assert(both);
|
||||||
console.warn("1");
|
console.warn("1");
|
||||||
console.group();
|
console.group();
|
||||||
|
@ -1284,8 +1284,8 @@ unitTest(function consoleGroupWarn(): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.table test
|
// console.table test
|
||||||
unitTest(function consoleTable(): void {
|
unitTest(function consoleTable() {
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table({ a: "test", b: 1 });
|
console.table({ a: "test", b: 1 });
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(out.toString()),
|
stripColor(out.toString()),
|
||||||
|
@ -1298,7 +1298,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table({ a: { b: 10 }, b: { b: 20, c: 30 } }, ["c"]);
|
console.table({ a: { b: 10 }, b: { b: 20, c: 30 } }, ["c"]);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(out.toString()),
|
stripColor(out.toString()),
|
||||||
|
@ -1311,7 +1311,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table([1, 2, [3, [4]], [5, 6], [[7], [8]]]);
|
console.table([1, 2, [3, [4]], [5, 6], [[7], [8]]]);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(out.toString()),
|
stripColor(out.toString()),
|
||||||
|
@ -1327,7 +1327,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table(new Set([1, 2, 3, "test"]));
|
console.table(new Set([1, 2, 3, "test"]));
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(out.toString()),
|
stripColor(out.toString()),
|
||||||
|
@ -1342,7 +1342,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table(
|
console.table(
|
||||||
new Map([
|
new Map([
|
||||||
[1, "one"],
|
[1, "one"],
|
||||||
|
@ -1360,7 +1360,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table({
|
console.table({
|
||||||
a: true,
|
a: true,
|
||||||
b: { c: { d: 10 }, e: [1, 2, [5, 6]] },
|
b: { c: { d: 10 }, e: [1, 2, [5, 6]] },
|
||||||
|
@ -1382,7 +1382,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table([
|
console.table([
|
||||||
1,
|
1,
|
||||||
"test",
|
"test",
|
||||||
|
@ -1404,7 +1404,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table([]);
|
console.table([]);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(out.toString()),
|
stripColor(out.toString()),
|
||||||
|
@ -1415,7 +1415,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table({});
|
console.table({});
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(out.toString()),
|
stripColor(out.toString()),
|
||||||
|
@ -1426,7 +1426,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table(new Set());
|
console.table(new Set());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(out.toString()),
|
stripColor(out.toString()),
|
||||||
|
@ -1437,7 +1437,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table(new Map());
|
console.table(new Map());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(out.toString()),
|
stripColor(out.toString()),
|
||||||
|
@ -1448,11 +1448,11 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table("test");
|
console.table("test");
|
||||||
assertEquals(out.toString(), "test\n");
|
assertEquals(out.toString(), "test\n");
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table(["Hello", "你好", "Amapá"]);
|
console.table(["Hello", "你好", "Amapá"]);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(out.toString()),
|
stripColor(out.toString()),
|
||||||
|
@ -1466,7 +1466,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table([
|
console.table([
|
||||||
[1, 2],
|
[1, 2],
|
||||||
[3, 4],
|
[3, 4],
|
||||||
|
@ -1482,7 +1482,7 @@ unitTest(function consoleTable(): void {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.table({ 1: { a: 4, b: 5 }, 2: null, 3: { b: 6, c: 7 } }, ["b"]);
|
console.table({ 1: { a: 4, b: 5 }, 2: null, 3: { b: 6, c: 7 } }, ["b"]);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(out.toString()),
|
stripColor(out.toString()),
|
||||||
|
@ -1532,7 +1532,7 @@ unitTest(function consoleTable(): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log(Error) test
|
// console.log(Error) test
|
||||||
unitTest(function consoleLogShouldNotThrowError(): void {
|
unitTest(function consoleLogShouldNotThrowError() {
|
||||||
mockConsole((console) => {
|
mockConsole((console) => {
|
||||||
let result = 0;
|
let result = 0;
|
||||||
try {
|
try {
|
||||||
|
@ -1545,14 +1545,14 @@ unitTest(function consoleLogShouldNotThrowError(): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
// output errors to the console should not include "Uncaught"
|
// output errors to the console should not include "Uncaught"
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.log(new Error("foo"));
|
console.log(new Error("foo"));
|
||||||
assertEquals(out.toString().includes("Uncaught"), false);
|
assertEquals(out.toString().includes("Uncaught"), false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log(Invalid Date) test
|
// console.log(Invalid Date) test
|
||||||
unitTest(function consoleLogShoultNotThrowErrorWhenInvalidDateIsPassed(): void {
|
unitTest(function consoleLogShoultNotThrowErrorWhenInvalidDateIsPassed() {
|
||||||
mockConsole((console, out) => {
|
mockConsole((console, out) => {
|
||||||
const invalidDate = new Date("test");
|
const invalidDate = new Date("test");
|
||||||
console.log(invalidDate);
|
console.log(invalidDate);
|
||||||
|
@ -1561,39 +1561,39 @@ unitTest(function consoleLogShoultNotThrowErrorWhenInvalidDateIsPassed(): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.dir test
|
// console.dir test
|
||||||
unitTest(function consoleDir(): void {
|
unitTest(function consoleDir() {
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.dir("DIR");
|
console.dir("DIR");
|
||||||
assertEquals(out.toString(), "DIR\n");
|
assertEquals(out.toString(), "DIR\n");
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.dir("DIR", { indentLevel: 2 });
|
console.dir("DIR", { indentLevel: 2 });
|
||||||
assertEquals(out.toString(), " DIR\n");
|
assertEquals(out.toString(), " DIR\n");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.dir test
|
// console.dir test
|
||||||
unitTest(function consoleDirXml(): void {
|
unitTest(function consoleDirXml() {
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.dirxml("DIRXML");
|
console.dirxml("DIRXML");
|
||||||
assertEquals(out.toString(), "DIRXML\n");
|
assertEquals(out.toString(), "DIRXML\n");
|
||||||
});
|
});
|
||||||
mockConsole((console, out): void => {
|
mockConsole((console, out) => {
|
||||||
console.dirxml("DIRXML", { indentLevel: 2 });
|
console.dirxml("DIRXML", { indentLevel: 2 });
|
||||||
assertEquals(out.toString(), " DIRXML\n");
|
assertEquals(out.toString(), " DIRXML\n");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.trace test
|
// console.trace test
|
||||||
unitTest(function consoleTrace(): void {
|
unitTest(function consoleTrace() {
|
||||||
mockConsole((console, _out, err): void => {
|
mockConsole((console, _out, err) => {
|
||||||
console.trace("%s", "custom message");
|
console.trace("%s", "custom message");
|
||||||
assert(err);
|
assert(err);
|
||||||
assert(err.toString().includes("Trace: custom message"));
|
assert(err.toString().includes("Trace: custom message"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function inspectString(): void {
|
unitTest(function inspectString() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(Deno.inspect("\0")),
|
stripColor(Deno.inspect("\0")),
|
||||||
`"\\x00"`,
|
`"\\x00"`,
|
||||||
|
@ -1604,7 +1604,7 @@ unitTest(function inspectString(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function inspectGetters(): void {
|
unitTest(function inspectGetters() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(Deno.inspect({
|
stripColor(Deno.inspect({
|
||||||
get foo() {
|
get foo() {
|
||||||
|
@ -1633,12 +1633,12 @@ unitTest(function inspectGetters(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function inspectPrototype(): void {
|
unitTest(function inspectPrototype() {
|
||||||
class A {}
|
class A {}
|
||||||
assertEquals(Deno.inspect(A.prototype), "A {}");
|
assertEquals(Deno.inspect(A.prototype), "A {}");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function inspectSorted(): void {
|
unitTest(function inspectSorted() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(Deno.inspect({ b: 2, a: 1 }, { sorted: true })),
|
stripColor(Deno.inspect({ b: 2, a: 1 }, { sorted: true })),
|
||||||
"{ a: 1, b: 2 }",
|
"{ a: 1, b: 2 }",
|
||||||
|
@ -1659,7 +1659,7 @@ unitTest(function inspectSorted(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function inspectTrailingComma(): void {
|
unitTest(function inspectTrailingComma() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(Deno.inspect(
|
stripColor(Deno.inspect(
|
||||||
[
|
[
|
||||||
|
@ -1714,7 +1714,7 @@ unitTest(function inspectTrailingComma(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function inspectCompact(): void {
|
unitTest(function inspectCompact() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(Deno.inspect({ a: 1, b: 2 }, { compact: false })),
|
stripColor(Deno.inspect({ a: 1, b: 2 }, { compact: false })),
|
||||||
`{
|
`{
|
||||||
|
@ -1724,7 +1724,7 @@ unitTest(function inspectCompact(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function inspectIterableLimit(): void {
|
unitTest(function inspectIterableLimit() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(Deno.inspect(["a", "b", "c"], { iterableLimit: 2 })),
|
stripColor(Deno.inspect(["a", "b", "c"], { iterableLimit: 2 })),
|
||||||
`[ "a", "b", ... 1 more items ]`,
|
`[ "a", "b", ... 1 more items ]`,
|
||||||
|
@ -1746,7 +1746,7 @@ unitTest(function inspectIterableLimit(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function inspectProxy(): void {
|
unitTest(function inspectProxy() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(Deno.inspect(
|
stripColor(Deno.inspect(
|
||||||
new Proxy([1, 2, 3], {}),
|
new Proxy([1, 2, 3], {}),
|
||||||
|
@ -1785,7 +1785,7 @@ unitTest(function inspectProxy(): void {
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(Deno.inspect(
|
stripColor(Deno.inspect(
|
||||||
new Proxy([1, 2, 3], { get(): void {} }),
|
new Proxy([1, 2, 3], { get() {} }),
|
||||||
{ showProxy: true },
|
{ showProxy: true },
|
||||||
)),
|
)),
|
||||||
"Proxy [ [ 1, 2, 3 ], { get: [Function: get] } ]",
|
"Proxy [ [ 1, 2, 3 ], { get: [Function: get] } ]",
|
||||||
|
@ -1803,7 +1803,7 @@ unitTest(function inspectProxy(): void {
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(Deno.inspect(
|
stripColor(Deno.inspect(
|
||||||
new Proxy([1, 2, 3, 4, 5, 6, 7], { get(): void {} }),
|
new Proxy([1, 2, 3, 4, 5, 6, 7], { get() {} }),
|
||||||
{ showProxy: true },
|
{ showProxy: true },
|
||||||
)),
|
)),
|
||||||
`Proxy [ [
|
`Proxy [ [
|
||||||
|
@ -1813,14 +1813,14 @@ unitTest(function inspectProxy(): void {
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
stripColor(Deno.inspect(
|
stripColor(Deno.inspect(
|
||||||
new Proxy(function fn() {}, { get(): void {} }),
|
new Proxy(function fn() {}, { get() {} }),
|
||||||
{ showProxy: true },
|
{ showProxy: true },
|
||||||
)),
|
)),
|
||||||
"Proxy [ [Function: fn], { get: [Function: get] } ]",
|
"Proxy [ [Function: fn], { get: [Function: get] } ]",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function inspectColors(): void {
|
unitTest(function inspectColors() {
|
||||||
assertEquals(Deno.inspect(1), "1");
|
assertEquals(Deno.inspect(1), "1");
|
||||||
assertStringIncludes(Deno.inspect(1, { colors: true }), "\x1b[");
|
assertStringIncludes(Deno.inspect(1, { colors: true }), "\x1b[");
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,7 +12,7 @@ function readFileString(filename: string | URL): string {
|
||||||
return dec.decode(dataRead);
|
return dec.decode(dataRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeFileString(filename: string | URL, s: string): void {
|
function writeFileString(filename: string | URL, s: string) {
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const data = enc.encode(s);
|
const data = enc.encode(s);
|
||||||
Deno.writeFileSync(filename, data, { mode: 0o666 });
|
Deno.writeFileSync(filename, data, { mode: 0o666 });
|
||||||
|
@ -21,7 +21,7 @@ function writeFileString(filename: string | URL, s: string): void {
|
||||||
function assertSameContent(
|
function assertSameContent(
|
||||||
filename1: string | URL,
|
filename1: string | URL,
|
||||||
filename2: string | URL,
|
filename2: string | URL,
|
||||||
): void {
|
) {
|
||||||
const data1 = Deno.readFileSync(filename1);
|
const data1 = Deno.readFileSync(filename1);
|
||||||
const data2 = Deno.readFileSync(filename2);
|
const data2 = Deno.readFileSync(filename2);
|
||||||
assertEquals(data1, data2);
|
assertEquals(data1, data2);
|
||||||
|
@ -29,7 +29,7 @@ function assertSameContent(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function copyFileSyncSuccess(): void {
|
function copyFileSyncSuccess() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const fromFilename = tempDir + "/from.txt";
|
const fromFilename = tempDir + "/from.txt";
|
||||||
const toFilename = tempDir + "/to.txt";
|
const toFilename = tempDir + "/to.txt";
|
||||||
|
@ -46,7 +46,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function copyFileSyncByUrl(): void {
|
function copyFileSyncByUrl() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const fromUrl = new URL(
|
const fromUrl = new URL(
|
||||||
`file://${Deno.build.os === "windows" ? "/" : ""}${tempDir}/from.txt`,
|
`file://${Deno.build.os === "windows" ? "/" : ""}${tempDir}/from.txt`,
|
||||||
|
@ -67,7 +67,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
function copyFileSyncFailure(): void {
|
function copyFileSyncFailure() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const fromFilename = tempDir + "/from.txt";
|
const fromFilename = tempDir + "/from.txt";
|
||||||
const toFilename = tempDir + "/to.txt";
|
const toFilename = tempDir + "/to.txt";
|
||||||
|
@ -82,7 +82,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: false } },
|
{ perms: { write: true, read: false } },
|
||||||
function copyFileSyncPerm1(): void {
|
function copyFileSyncPerm1() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.copyFileSync("/from.txt", "/to.txt");
|
Deno.copyFileSync("/from.txt", "/to.txt");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -91,7 +91,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: false, read: true } },
|
{ perms: { write: false, read: true } },
|
||||||
function copyFileSyncPerm2(): void {
|
function copyFileSyncPerm2() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.copyFileSync("/from.txt", "/to.txt");
|
Deno.copyFileSync("/from.txt", "/to.txt");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -100,7 +100,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function copyFileSyncOverwrite(): void {
|
function copyFileSyncOverwrite() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const fromFilename = tempDir + "/from.txt";
|
const fromFilename = tempDir + "/from.txt";
|
||||||
const toFilename = tempDir + "/to.txt";
|
const toFilename = tempDir + "/to.txt";
|
||||||
|
@ -119,7 +119,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function copyFileSuccess(): Promise<void> {
|
async function copyFileSuccess() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const fromFilename = tempDir + "/from.txt";
|
const fromFilename = tempDir + "/from.txt";
|
||||||
const toFilename = tempDir + "/to.txt";
|
const toFilename = tempDir + "/to.txt";
|
||||||
|
@ -136,7 +136,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function copyFileByUrl(): Promise<void> {
|
async function copyFileByUrl() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const fromUrl = new URL(
|
const fromUrl = new URL(
|
||||||
`file://${Deno.build.os === "windows" ? "/" : ""}${tempDir}/from.txt`,
|
`file://${Deno.build.os === "windows" ? "/" : ""}${tempDir}/from.txt`,
|
||||||
|
@ -157,7 +157,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function copyFileFailure(): Promise<void> {
|
async function copyFileFailure() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const fromFilename = tempDir + "/from.txt";
|
const fromFilename = tempDir + "/from.txt";
|
||||||
const toFilename = tempDir + "/to.txt";
|
const toFilename = tempDir + "/to.txt";
|
||||||
|
@ -172,7 +172,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function copyFileOverwrite(): Promise<void> {
|
async function copyFileOverwrite() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const fromFilename = tempDir + "/from.txt";
|
const fromFilename = tempDir + "/from.txt";
|
||||||
const toFilename = tempDir + "/to.txt";
|
const toFilename = tempDir + "/to.txt";
|
||||||
|
@ -191,7 +191,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: false, write: true } },
|
{ perms: { read: false, write: true } },
|
||||||
async function copyFilePerm1(): Promise<void> {
|
async function copyFilePerm1() {
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.copyFile("/from.txt", "/to.txt");
|
await Deno.copyFile("/from.txt", "/to.txt");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -200,7 +200,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: false } },
|
{ perms: { read: true, write: false } },
|
||||||
async function copyFilePerm2(): Promise<void> {
|
async function copyFilePerm2() {
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.copyFile("/from.txt", "/to.txt");
|
await Deno.copyFile("/from.txt", "/to.txt");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertEquals, unitTest } from "./test_util.ts";
|
import { assertEquals, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function customEventInitializedWithDetail(): void {
|
unitTest(function customEventInitializedWithDetail() {
|
||||||
const type = "touchstart";
|
const type = "touchstart";
|
||||||
const detail = { message: "hello" };
|
const detail = { message: "hello" };
|
||||||
const customEventInit = {
|
const customEventInit = {
|
||||||
|
@ -20,7 +20,7 @@ unitTest(function customEventInitializedWithDetail(): void {
|
||||||
assertEquals(event.type, type);
|
assertEquals(event.type, type);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function toStringShouldBeWebCompatibility(): void {
|
unitTest(function toStringShouldBeWebCompatibility() {
|
||||||
const type = "touchstart";
|
const type = "touchstart";
|
||||||
const event = new CustomEvent(type, {});
|
const event = new CustomEvent(type, {});
|
||||||
assertEquals(event.toString(), "[object CustomEvent]");
|
assertEquals(event.toString(), "[object CustomEvent]");
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assert, assertEquals, assertThrows, unitTest } from "./test_util.ts";
|
import { assert, assertEquals, assertThrows, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function dirCwdNotNull(): void {
|
unitTest({ perms: { read: true } }, function dirCwdNotNull() {
|
||||||
assert(Deno.cwd() != null);
|
assert(Deno.cwd() != null);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function dirCwdChdirSuccess(): void {
|
function dirCwdChdirSuccess() {
|
||||||
const initialdir = Deno.cwd();
|
const initialdir = Deno.cwd();
|
||||||
const path = Deno.makeTempDirSync();
|
const path = Deno.makeTempDirSync();
|
||||||
Deno.chdir(path);
|
Deno.chdir(path);
|
||||||
|
@ -21,7 +21,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: true, write: true } }, function dirCwdError(): void {
|
unitTest({ perms: { read: true, write: true } }, function dirCwdError() {
|
||||||
// excluding windows since it throws resource busy, while removeSync
|
// excluding windows since it throws resource busy, while removeSync
|
||||||
if (["linux", "darwin"].includes(Deno.build.os)) {
|
if (["linux", "darwin"].includes(Deno.build.os)) {
|
||||||
const initialdir = Deno.cwd();
|
const initialdir = Deno.cwd();
|
||||||
|
@ -38,7 +38,7 @@ unitTest({ perms: { read: true, write: true } }, function dirCwdError(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, function dirCwdPermError(): void {
|
unitTest({ perms: { read: false } }, function dirCwdPermError() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.cwd();
|
Deno.cwd();
|
||||||
|
@ -50,7 +50,7 @@ unitTest({ perms: { read: false } }, function dirCwdPermError(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function dirChdirError(): void {
|
function dirChdirError() {
|
||||||
const path = Deno.makeTempDirSync() + "test";
|
const path = Deno.makeTempDirSync() + "test";
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.chdir(path);
|
Deno.chdir(path);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { assertEquals, assertStringIncludes, unitTest } from "./test_util.ts";
|
import { assertEquals, assertStringIncludes, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function customInspectFunction(): void {
|
unitTest(function customInspectFunction() {
|
||||||
const blob = new DOMException("test");
|
const blob = new DOMException("test");
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Deno.inspect(blob),
|
Deno.inspect(blob),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assert, assertEquals, assertMatch, unitTest } from "./test_util.ts";
|
import { assert, assertEquals, assertMatch, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function errorStackMessageLine(): void {
|
unitTest(function errorStackMessageLine() {
|
||||||
const e1 = new Error();
|
const e1 = new Error();
|
||||||
e1.name = "Foo";
|
e1.name = "Foo";
|
||||||
e1.message = "bar";
|
e1.message = "bar";
|
||||||
|
@ -41,8 +41,8 @@ unitTest(function errorStackMessageLine(): void {
|
||||||
assertMatch(e6.stack!, /^null: null\n/);
|
assertMatch(e6.stack!, /^null: null\n/);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function captureStackTrace(): void {
|
unitTest(function captureStackTrace() {
|
||||||
function foo(): void {
|
function foo() {
|
||||||
const error = new Error();
|
const error = new Error();
|
||||||
const stack1 = error.stack!;
|
const stack1 = error.stack!;
|
||||||
Error.captureStackTrace(error, foo);
|
Error.captureStackTrace(error, foo);
|
||||||
|
@ -55,7 +55,7 @@ unitTest(function captureStackTrace(): void {
|
||||||
|
|
||||||
// FIXME(bartlomieju): no longer works after migrating
|
// FIXME(bartlomieju): no longer works after migrating
|
||||||
// to JavaScript runtime code
|
// to JavaScript runtime code
|
||||||
unitTest({ ignore: true }, function applySourceMap(): void {
|
unitTest({ ignore: true }, function applySourceMap() {
|
||||||
const result = Deno.applySourceMap({
|
const result = Deno.applySourceMap({
|
||||||
fileName: "CLI_SNAPSHOT.js",
|
fileName: "CLI_SNAPSHOT.js",
|
||||||
lineNumber: 23,
|
lineNumber: 23,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertEquals, unitTest } from "./test_util.ts";
|
import { assertEquals, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function addEventListenerTest(): void {
|
unitTest(function addEventListenerTest() {
|
||||||
const document = new EventTarget();
|
const document = new EventTarget();
|
||||||
|
|
||||||
assertEquals(document.addEventListener("x", null, false), undefined);
|
assertEquals(document.addEventListener("x", null, false), undefined);
|
||||||
|
@ -9,12 +9,12 @@ unitTest(function addEventListenerTest(): void {
|
||||||
assertEquals(document.addEventListener("x", null), undefined);
|
assertEquals(document.addEventListener("x", null), undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function constructedEventTargetCanBeUsedAsExpected(): void {
|
unitTest(function constructedEventTargetCanBeUsedAsExpected() {
|
||||||
const target = new EventTarget();
|
const target = new EventTarget();
|
||||||
const event = new Event("foo", { bubbles: true, cancelable: false });
|
const event = new Event("foo", { bubbles: true, cancelable: false });
|
||||||
let callCount = 0;
|
let callCount = 0;
|
||||||
|
|
||||||
const listener = (e: Event): void => {
|
const listener = (e: Event) => {
|
||||||
assertEquals(e, event);
|
assertEquals(e, event);
|
||||||
++callCount;
|
++callCount;
|
||||||
};
|
};
|
||||||
|
@ -32,13 +32,13 @@ unitTest(function constructedEventTargetCanBeUsedAsExpected(): void {
|
||||||
assertEquals(callCount, 2);
|
assertEquals(callCount, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function anEventTargetCanBeSubclassed(): void {
|
unitTest(function anEventTargetCanBeSubclassed() {
|
||||||
class NicerEventTarget extends EventTarget {
|
class NicerEventTarget extends EventTarget {
|
||||||
on(
|
on(
|
||||||
type: string,
|
type: string,
|
||||||
callback: ((e: Event) => void) | null,
|
callback: ((e: Event) => void) | null,
|
||||||
options?: AddEventListenerOptions,
|
options?: AddEventListenerOptions,
|
||||||
): void {
|
) {
|
||||||
this.addEventListener(type, callback, options);
|
this.addEventListener(type, callback, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ unitTest(function anEventTargetCanBeSubclassed(): void {
|
||||||
type: string,
|
type: string,
|
||||||
callback: ((e: Event) => void) | null,
|
callback: ((e: Event) => void) | null,
|
||||||
options?: EventListenerOptions,
|
options?: EventListenerOptions,
|
||||||
): void {
|
) {
|
||||||
this.removeEventListener(type, callback, options);
|
this.removeEventListener(type, callback, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ unitTest(function anEventTargetCanBeSubclassed(): void {
|
||||||
new Event("foo", { bubbles: true, cancelable: false });
|
new Event("foo", { bubbles: true, cancelable: false });
|
||||||
let callCount = 0;
|
let callCount = 0;
|
||||||
|
|
||||||
const listener = (): void => {
|
const listener = () => {
|
||||||
++callCount;
|
++callCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,19 +66,19 @@ unitTest(function anEventTargetCanBeSubclassed(): void {
|
||||||
assertEquals(callCount, 0);
|
assertEquals(callCount, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function removingNullEventListenerShouldSucceed(): void {
|
unitTest(function removingNullEventListenerShouldSucceed() {
|
||||||
const document = new EventTarget();
|
const document = new EventTarget();
|
||||||
assertEquals(document.removeEventListener("x", null, false), undefined);
|
assertEquals(document.removeEventListener("x", null, false), undefined);
|
||||||
assertEquals(document.removeEventListener("x", null, true), undefined);
|
assertEquals(document.removeEventListener("x", null, true), undefined);
|
||||||
assertEquals(document.removeEventListener("x", null), undefined);
|
assertEquals(document.removeEventListener("x", null), undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function constructedEventTargetUseObjectPrototype(): void {
|
unitTest(function constructedEventTargetUseObjectPrototype() {
|
||||||
const target = new EventTarget();
|
const target = new EventTarget();
|
||||||
const event = new Event("toString", { bubbles: true, cancelable: false });
|
const event = new Event("toString", { bubbles: true, cancelable: false });
|
||||||
let callCount = 0;
|
let callCount = 0;
|
||||||
|
|
||||||
const listener = (e: Event): void => {
|
const listener = (e: Event) => {
|
||||||
assertEquals(e, event);
|
assertEquals(e, event);
|
||||||
++callCount;
|
++callCount;
|
||||||
};
|
};
|
||||||
|
@ -96,12 +96,12 @@ unitTest(function constructedEventTargetUseObjectPrototype(): void {
|
||||||
assertEquals(callCount, 2);
|
assertEquals(callCount, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function toStringShouldBeWebCompatible(): void {
|
unitTest(function toStringShouldBeWebCompatible() {
|
||||||
const target = new EventTarget();
|
const target = new EventTarget();
|
||||||
assertEquals(target.toString(), "[object EventTarget]");
|
assertEquals(target.toString(), "[object EventTarget]");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function dispatchEventShouldNotThrowError(): void {
|
unitTest(function dispatchEventShouldNotThrowError() {
|
||||||
let hasThrown = false;
|
let hasThrown = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -110,7 +110,7 @@ unitTest(function dispatchEventShouldNotThrowError(): void {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
cancelable: false,
|
cancelable: false,
|
||||||
});
|
});
|
||||||
const listener = (): void => {};
|
const listener = () => {};
|
||||||
target.addEventListener("hasOwnProperty", listener);
|
target.addEventListener("hasOwnProperty", listener);
|
||||||
target.dispatchEvent(event);
|
target.dispatchEvent(event);
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -120,7 +120,7 @@ unitTest(function dispatchEventShouldNotThrowError(): void {
|
||||||
assertEquals(hasThrown, false);
|
assertEquals(hasThrown, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function eventTargetThisShouldDefaultToWindow(): void {
|
unitTest(function eventTargetThisShouldDefaultToWindow() {
|
||||||
const {
|
const {
|
||||||
addEventListener,
|
addEventListener,
|
||||||
dispatchEvent,
|
dispatchEvent,
|
||||||
|
@ -128,7 +128,7 @@ unitTest(function eventTargetThisShouldDefaultToWindow(): void {
|
||||||
} = EventTarget.prototype;
|
} = EventTarget.prototype;
|
||||||
let n = 1;
|
let n = 1;
|
||||||
const event = new Event("hello");
|
const event = new Event("hello");
|
||||||
const listener = (): void => {
|
const listener = () => {
|
||||||
n = 2;
|
n = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -149,13 +149,13 @@ unitTest(function eventTargetThisShouldDefaultToWindow(): void {
|
||||||
assertEquals(n, 1);
|
assertEquals(n, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function eventTargetShouldAcceptEventListenerObject(): void {
|
unitTest(function eventTargetShouldAcceptEventListenerObject() {
|
||||||
const target = new EventTarget();
|
const target = new EventTarget();
|
||||||
const event = new Event("foo", { bubbles: true, cancelable: false });
|
const event = new Event("foo", { bubbles: true, cancelable: false });
|
||||||
let callCount = 0;
|
let callCount = 0;
|
||||||
|
|
||||||
const listener = {
|
const listener = {
|
||||||
handleEvent(e: Event): void {
|
handleEvent(e: Event) {
|
||||||
assertEquals(e, event);
|
assertEquals(e, event);
|
||||||
++callCount;
|
++callCount;
|
||||||
},
|
},
|
||||||
|
@ -174,12 +174,12 @@ unitTest(function eventTargetShouldAcceptEventListenerObject(): void {
|
||||||
assertEquals(callCount, 2);
|
assertEquals(callCount, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function eventTargetShouldAcceptAsyncFunction(): void {
|
unitTest(function eventTargetShouldAcceptAsyncFunction() {
|
||||||
const target = new EventTarget();
|
const target = new EventTarget();
|
||||||
const event = new Event("foo", { bubbles: true, cancelable: false });
|
const event = new Event("foo", { bubbles: true, cancelable: false });
|
||||||
let callCount = 0;
|
let callCount = 0;
|
||||||
|
|
||||||
const listener = (e: Event): void => {
|
const listener = (e: Event) => {
|
||||||
assertEquals(e, event);
|
assertEquals(e, event);
|
||||||
++callCount;
|
++callCount;
|
||||||
};
|
};
|
||||||
|
@ -198,13 +198,13 @@ unitTest(function eventTargetShouldAcceptAsyncFunction(): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
function eventTargetShouldAcceptAsyncFunctionForEventListenerObject(): void {
|
function eventTargetShouldAcceptAsyncFunctionForEventListenerObject() {
|
||||||
const target = new EventTarget();
|
const target = new EventTarget();
|
||||||
const event = new Event("foo", { bubbles: true, cancelable: false });
|
const event = new Event("foo", { bubbles: true, cancelable: false });
|
||||||
let callCount = 0;
|
let callCount = 0;
|
||||||
|
|
||||||
const listener = {
|
const listener = {
|
||||||
handleEvent(e: Event): void {
|
handleEvent(e: Event) {
|
||||||
assertEquals(e, event);
|
assertEquals(e, event);
|
||||||
++callCount;
|
++callCount;
|
||||||
},
|
},
|
||||||
|
@ -223,7 +223,7 @@ unitTest(
|
||||||
assertEquals(callCount, 2);
|
assertEquals(callCount, 2);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
unitTest(function eventTargetDispatchShouldSetTargetNoListener(): void {
|
unitTest(function eventTargetDispatchShouldSetTargetNoListener() {
|
||||||
const target = new EventTarget();
|
const target = new EventTarget();
|
||||||
const event = new Event("foo");
|
const event = new Event("foo");
|
||||||
assertEquals(event.target, null);
|
assertEquals(event.target, null);
|
||||||
|
@ -231,7 +231,7 @@ unitTest(function eventTargetDispatchShouldSetTargetNoListener(): void {
|
||||||
assertEquals(event.target, target);
|
assertEquals(event.target, target);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function eventTargetDispatchShouldSetTargetInListener(): void {
|
unitTest(function eventTargetDispatchShouldSetTargetInListener() {
|
||||||
const target = new EventTarget();
|
const target = new EventTarget();
|
||||||
const event = new Event("foo");
|
const event = new Event("foo");
|
||||||
assertEquals(event.target, null);
|
assertEquals(event.target, null);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function eventInitializedWithType(): void {
|
unitTest(function eventInitializedWithType() {
|
||||||
const type = "click";
|
const type = "click";
|
||||||
const event = new Event(type);
|
const event = new Event(type);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ unitTest(function eventInitializedWithType(): void {
|
||||||
assertEquals(event.cancelable, false);
|
assertEquals(event.cancelable, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function eventInitializedWithTypeAndDict(): void {
|
unitTest(function eventInitializedWithTypeAndDict() {
|
||||||
const init = "submit";
|
const init = "submit";
|
||||||
const eventInit = { bubbles: true, cancelable: true } as EventInit;
|
const eventInit = { bubbles: true, cancelable: true } as EventInit;
|
||||||
const event = new Event(init, eventInit);
|
const event = new Event(init, eventInit);
|
||||||
|
@ -31,7 +31,7 @@ unitTest(function eventInitializedWithTypeAndDict(): void {
|
||||||
assertEquals(event.cancelable, true);
|
assertEquals(event.cancelable, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function eventComposedPathSuccess(): void {
|
unitTest(function eventComposedPathSuccess() {
|
||||||
const type = "click";
|
const type = "click";
|
||||||
const event = new Event(type);
|
const event = new Event(type);
|
||||||
const composedPath = event.composedPath();
|
const composedPath = event.composedPath();
|
||||||
|
@ -39,7 +39,7 @@ unitTest(function eventComposedPathSuccess(): void {
|
||||||
assertEquals(composedPath, []);
|
assertEquals(composedPath, []);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function eventStopPropagationSuccess(): void {
|
unitTest(function eventStopPropagationSuccess() {
|
||||||
const type = "click";
|
const type = "click";
|
||||||
const event = new Event(type);
|
const event = new Event(type);
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ unitTest(function eventStopPropagationSuccess(): void {
|
||||||
assertEquals(event.cancelBubble, true);
|
assertEquals(event.cancelBubble, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function eventStopImmediatePropagationSuccess(): void {
|
unitTest(function eventStopImmediatePropagationSuccess() {
|
||||||
const type = "click";
|
const type = "click";
|
||||||
const event = new Event(type);
|
const event = new Event(type);
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ unitTest(function eventStopImmediatePropagationSuccess(): void {
|
||||||
assertEquals(event.cancelBubble, true);
|
assertEquals(event.cancelBubble, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function eventPreventDefaultSuccess(): void {
|
unitTest(function eventPreventDefaultSuccess() {
|
||||||
const type = "click";
|
const type = "click";
|
||||||
const event = new Event(type);
|
const event = new Event(type);
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ unitTest(function eventPreventDefaultSuccess(): void {
|
||||||
assertEquals(cancelableEvent.defaultPrevented, true);
|
assertEquals(cancelableEvent.defaultPrevented, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function eventInitializedWithNonStringType(): void {
|
unitTest(function eventInitializedWithNonStringType() {
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
const type: any = undefined;
|
const type: any = undefined;
|
||||||
const event = new Event(type);
|
const event = new Event(type);
|
||||||
|
@ -86,7 +86,7 @@ unitTest(function eventInitializedWithNonStringType(): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
// ref https://github.com/web-platform-tests/wpt/blob/master/dom/events/Event-isTrusted.any.js
|
// ref https://github.com/web-platform-tests/wpt/blob/master/dom/events/Event-isTrusted.any.js
|
||||||
unitTest(function eventIsTrusted(): void {
|
unitTest(function eventIsTrusted() {
|
||||||
const desc1 = Object.getOwnPropertyDescriptor(new Event("x"), "isTrusted");
|
const desc1 = Object.getOwnPropertyDescriptor(new Event("x"), "isTrusted");
|
||||||
assert(desc1);
|
assert(desc1);
|
||||||
assertEquals(typeof desc1.get, "function");
|
assertEquals(typeof desc1.get, "function");
|
||||||
|
@ -98,7 +98,7 @@ unitTest(function eventIsTrusted(): void {
|
||||||
assertEquals(desc1!.get, desc2!.get);
|
assertEquals(desc1!.get, desc2!.get);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function eventInspectOutput(): void {
|
unitTest(function eventInspectOutput() {
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
const cases: Array<[any, (event: any) => string]> = [
|
const cases: Array<[any, (event: any) => string]> = [
|
||||||
[
|
[
|
||||||
|
@ -133,7 +133,7 @@ unitTest(function eventInspectOutput(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function inspectEvent(): void {
|
unitTest(function inspectEvent() {
|
||||||
// has a customInspect implementation that previously would throw on a getter
|
// has a customInspect implementation that previously would throw on a getter
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Deno.inspect(Event.prototype),
|
Deno.inspect(Event.prototype),
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { Buffer } from "../../../test_util/std/io/buffer.ts";
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchRequiresOneArgument(): Promise<void> {
|
async function fetchRequiresOneArgument() {
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
fetch as unknown as () => Promise<void>,
|
fetch as unknown as () => Promise<void>,
|
||||||
TypeError,
|
TypeError,
|
||||||
|
@ -20,11 +20,9 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function fetchProtocolError(): Promise<
|
unitTest({ perms: { net: true } }, async function fetchProtocolError() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await fetch("file:///");
|
await fetch("file:///");
|
||||||
},
|
},
|
||||||
TypeError,
|
TypeError,
|
||||||
|
@ -58,10 +56,10 @@ function findClosedPortInRange(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchConnectionError(): Promise<void> {
|
async function fetchConnectionError() {
|
||||||
const port = findClosedPortInRange(4000, 9999);
|
const port = findClosedPortInRange(4000, 9999);
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await fetch(`http://localhost:${port}`);
|
await fetch(`http://localhost:${port}`);
|
||||||
},
|
},
|
||||||
TypeError,
|
TypeError,
|
||||||
|
@ -72,9 +70,9 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchDnsError(): Promise<void> {
|
async function fetchDnsError() {
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await fetch("http://nil/");
|
await fetch("http://nil/");
|
||||||
},
|
},
|
||||||
TypeError,
|
TypeError,
|
||||||
|
@ -85,9 +83,9 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchInvalidUriError(): Promise<void> {
|
async function fetchInvalidUriError() {
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await fetch("http://<invalid>/");
|
await fetch("http://<invalid>/");
|
||||||
},
|
},
|
||||||
TypeError,
|
TypeError,
|
||||||
|
@ -95,27 +93,25 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function fetchJsonSuccess(): Promise<
|
unitTest({ perms: { net: true } }, async function fetchJsonSuccess() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
assertEquals(json.name, "deno");
|
assertEquals(json.name, "deno");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function fetchPerm(): Promise<void> {
|
unitTest(async function fetchPerm() {
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await fetch("http://localhost:4545/cli/tests/fixture.json");
|
await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function fetchUrl(): Promise<void> {
|
unitTest({ perms: { net: true } }, async function fetchUrl() {
|
||||||
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||||
assertEquals(response.url, "http://localhost:4545/cli/tests/fixture.json");
|
assertEquals(response.url, "http://localhost:4545/cli/tests/fixture.json");
|
||||||
const _json = await response.json();
|
const _json = await response.json();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function fetchURL(): Promise<void> {
|
unitTest({ perms: { net: true } }, async function fetchURL() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
new URL("http://localhost:4545/cli/tests/fixture.json"),
|
new URL("http://localhost:4545/cli/tests/fixture.json"),
|
||||||
);
|
);
|
||||||
|
@ -123,16 +119,14 @@ unitTest({ perms: { net: true } }, async function fetchURL(): Promise<void> {
|
||||||
const _json = await response.json();
|
const _json = await response.json();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function fetchHeaders(): Promise<
|
unitTest({ perms: { net: true } }, async function fetchHeaders() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||||
const headers = response.headers;
|
const headers = response.headers;
|
||||||
assertEquals(headers.get("Content-Type"), "application/json");
|
assertEquals(headers.get("Content-Type"), "application/json");
|
||||||
const _json = await response.json();
|
const _json = await response.json();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function fetchBlob(): Promise<void> {
|
unitTest({ perms: { net: true } }, async function fetchBlob() {
|
||||||
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||||
const headers = response.headers;
|
const headers = response.headers;
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
|
@ -142,7 +136,7 @@ unitTest({ perms: { net: true } }, async function fetchBlob(): Promise<void> {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchBodyUsedReader(): Promise<void> {
|
async function fetchBodyUsedReader() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"http://localhost:4545/cli/tests/fixture.json",
|
"http://localhost:4545/cli/tests/fixture.json",
|
||||||
);
|
);
|
||||||
|
@ -160,7 +154,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchBodyUsedCancelStream(): Promise<void> {
|
async function fetchBodyUsedCancelStream() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"http://localhost:4545/cli/tests/fixture.json",
|
"http://localhost:4545/cli/tests/fixture.json",
|
||||||
);
|
);
|
||||||
|
@ -173,9 +167,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function fetchAsyncIterator(): Promise<
|
unitTest({ perms: { net: true } }, async function fetchAsyncIterator() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||||
const headers = response.headers;
|
const headers = response.headers;
|
||||||
|
|
||||||
|
@ -189,9 +181,7 @@ unitTest({ perms: { net: true } }, async function fetchAsyncIterator(): Promise<
|
||||||
assertEquals(total, Number(headers.get("Content-Length")));
|
assertEquals(total, Number(headers.get("Content-Length")));
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function fetchBodyReader(): Promise<
|
unitTest({ perms: { net: true } }, async function fetchBodyReader() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||||
const headers = response.headers;
|
const headers = response.headers;
|
||||||
assert(response.body !== null);
|
assert(response.body !== null);
|
||||||
|
@ -210,7 +200,7 @@ unitTest({ perms: { net: true } }, async function fetchBodyReader(): Promise<
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchBodyReaderBigBody(): Promise<void> {
|
async function fetchBodyReaderBigBody() {
|
||||||
const data = "a".repeat(10 << 10); // 10mb
|
const data = "a".repeat(10 << 10); // 10mb
|
||||||
const response = await fetch("http://localhost:4545/echo_server", {
|
const response = await fetch("http://localhost:4545/echo_server", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -230,9 +220,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function responseClone(): Promise<
|
unitTest({ perms: { net: true } }, async function responseClone() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||||
const response1 = response.clone();
|
const response1 = response.clone();
|
||||||
assert(response !== response1);
|
assert(response !== response1);
|
||||||
|
@ -247,7 +235,7 @@ unitTest({ perms: { net: true } }, async function responseClone(): Promise<
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchMultipartFormDataSuccess(): Promise<void> {
|
async function fetchMultipartFormDataSuccess() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"http://localhost:4545/multipart_form_data.txt",
|
"http://localhost:4545/multipart_form_data.txt",
|
||||||
);
|
);
|
||||||
|
@ -264,14 +252,14 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchMultipartFormBadContentType(): Promise<void> {
|
async function fetchMultipartFormBadContentType() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"http://localhost:4545/multipart_form_bad_content_type",
|
"http://localhost:4545/multipart_form_bad_content_type",
|
||||||
);
|
);
|
||||||
assert(response.body !== null);
|
assert(response.body !== null);
|
||||||
|
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await response.formData();
|
await response.formData();
|
||||||
},
|
},
|
||||||
TypeError,
|
TypeError,
|
||||||
|
@ -282,7 +270,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchURLEncodedFormDataSuccess(): Promise<void> {
|
async function fetchURLEncodedFormDataSuccess() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"http://localhost:4545/cli/tests/subdir/form_urlencoded.txt",
|
"http://localhost:4545/cli/tests/subdir/form_urlencoded.txt",
|
||||||
);
|
);
|
||||||
|
@ -296,7 +284,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchInitFormDataBinaryFileBody(): Promise<void> {
|
async function fetchInitFormDataBinaryFileBody() {
|
||||||
// Some random bytes
|
// Some random bytes
|
||||||
// deno-fmt-ignore
|
// deno-fmt-ignore
|
||||||
const binaryFile = new Uint8Array([108,2,0,0,145,22,162,61,157,227,166,77,138,75,180,56,119,188,177,183]);
|
const binaryFile = new Uint8Array([108,2,0,0,145,22,162,61,157,227,166,77,138,75,180,56,119,188,177,183]);
|
||||||
|
@ -315,7 +303,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchInitFormDataMultipleFilesBody(): Promise<void> {
|
async function fetchInitFormDataMultipleFilesBody() {
|
||||||
const files = [
|
const files = [
|
||||||
{
|
{
|
||||||
// deno-fmt-ignore
|
// deno-fmt-ignore
|
||||||
|
@ -371,7 +359,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchWithRedirection(): Promise<void> {
|
async function fetchWithRedirection() {
|
||||||
const response = await fetch("http://localhost:4546/README.md");
|
const response = await fetch("http://localhost:4546/README.md");
|
||||||
assertEquals(response.status, 200);
|
assertEquals(response.status, 200);
|
||||||
assertEquals(response.statusText, "OK");
|
assertEquals(response.statusText, "OK");
|
||||||
|
@ -385,7 +373,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchWithRelativeRedirection(): Promise<void> {
|
async function fetchWithRelativeRedirection() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"http://localhost:4545/cli/tests/001_hello.js",
|
"http://localhost:4545/cli/tests/001_hello.js",
|
||||||
);
|
);
|
||||||
|
@ -400,7 +388,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchWithRelativeRedirectionUrl(): Promise<void> {
|
async function fetchWithRelativeRedirectionUrl() {
|
||||||
const cases = [
|
const cases = [
|
||||||
["end", "http://localhost:4550/a/b/end"],
|
["end", "http://localhost:4550/a/b/end"],
|
||||||
["/end", "http://localhost:4550/end"],
|
["/end", "http://localhost:4550/end"],
|
||||||
|
@ -421,7 +409,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchWithInfRedirection(): Promise<void> {
|
async function fetchWithInfRedirection() {
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
() => fetch("http://localhost:4549/cli/tests"),
|
() => fetch("http://localhost:4549/cli/tests"),
|
||||||
TypeError,
|
TypeError,
|
||||||
|
@ -432,7 +420,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchInitStringBody(): Promise<void> {
|
async function fetchInitStringBody() {
|
||||||
const data = "Hello World";
|
const data = "Hello World";
|
||||||
const response = await fetch("http://localhost:4545/echo_server", {
|
const response = await fetch("http://localhost:4545/echo_server", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -446,7 +434,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchRequestInitStringBody(): Promise<void> {
|
async function fetchRequestInitStringBody() {
|
||||||
const data = "Hello World";
|
const data = "Hello World";
|
||||||
const req = new Request("http://localhost:4545/echo_server", {
|
const req = new Request("http://localhost:4545/echo_server", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -460,7 +448,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchSeparateInit(): Promise<void> {
|
async function fetchSeparateInit() {
|
||||||
// related to: https://github.com/denoland/deno/issues/10396
|
// related to: https://github.com/denoland/deno/issues/10396
|
||||||
const req = new Request("http://localhost:4545/cli/tests/001_hello.js");
|
const req = new Request("http://localhost:4545/cli/tests/001_hello.js");
|
||||||
const init = {
|
const init = {
|
||||||
|
@ -475,7 +463,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchInitTypedArrayBody(): Promise<void> {
|
async function fetchInitTypedArrayBody() {
|
||||||
const data = "Hello World";
|
const data = "Hello World";
|
||||||
const response = await fetch("http://localhost:4545/echo_server", {
|
const response = await fetch("http://localhost:4545/echo_server", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -488,7 +476,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchInitArrayBufferBody(): Promise<void> {
|
async function fetchInitArrayBufferBody() {
|
||||||
const data = "Hello World";
|
const data = "Hello World";
|
||||||
const response = await fetch("http://localhost:4545/echo_server", {
|
const response = await fetch("http://localhost:4545/echo_server", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -501,7 +489,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchInitURLSearchParamsBody(): Promise<void> {
|
async function fetchInitURLSearchParamsBody() {
|
||||||
const data = "param1=value1¶m2=value2";
|
const data = "param1=value1¶m2=value2";
|
||||||
const params = new URLSearchParams(data);
|
const params = new URLSearchParams(data);
|
||||||
const response = await fetch("http://localhost:4545/echo_server", {
|
const response = await fetch("http://localhost:4545/echo_server", {
|
||||||
|
@ -518,9 +506,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function fetchInitBlobBody(): Promise<
|
unitTest({ perms: { net: true } }, async function fetchInitBlobBody() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const data = "const a = 1";
|
const data = "const a = 1";
|
||||||
const blob = new Blob([data], {
|
const blob = new Blob([data], {
|
||||||
type: "text/javascript",
|
type: "text/javascript",
|
||||||
|
@ -536,7 +522,7 @@ unitTest({ perms: { net: true } }, async function fetchInitBlobBody(): Promise<
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchInitFormDataBody(): Promise<void> {
|
async function fetchInitFormDataBody() {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append("field", "value");
|
form.append("field", "value");
|
||||||
const response = await fetch("http://localhost:4545/echo_server", {
|
const response = await fetch("http://localhost:4545/echo_server", {
|
||||||
|
@ -550,7 +536,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchInitFormDataBlobFilenameBody(): Promise<void> {
|
async function fetchInitFormDataBlobFilenameBody() {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append("field", "value");
|
form.append("field", "value");
|
||||||
form.append("file", new Blob([new TextEncoder().encode("deno")]));
|
form.append("file", new Blob([new TextEncoder().encode("deno")]));
|
||||||
|
@ -568,7 +554,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchInitFormDataTextFileBody(): Promise<void> {
|
async function fetchInitFormDataTextFileBody() {
|
||||||
const fileContent = "deno land";
|
const fileContent = "deno land";
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append("field", "value");
|
form.append("field", "value");
|
||||||
|
@ -596,9 +582,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function fetchUserAgent(): Promise<
|
unitTest({ perms: { net: true } }, async function fetchUserAgent() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const data = "Hello World";
|
const data = "Hello World";
|
||||||
const response = await fetch("http://localhost:4545/echo_server", {
|
const response = await fetch("http://localhost:4545/echo_server", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -658,7 +642,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchRequest(): Promise<void> {
|
async function fetchRequest() {
|
||||||
const addr = "127.0.0.1:4501";
|
const addr = "127.0.0.1:4501";
|
||||||
const buf = bufferServer(addr);
|
const buf = bufferServer(addr);
|
||||||
const response = await fetch(`http://${addr}/blah`, {
|
const response = await fetch(`http://${addr}/blah`, {
|
||||||
|
@ -690,7 +674,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchPostBodyString(): Promise<void> {
|
async function fetchPostBodyString() {
|
||||||
const addr = "127.0.0.1:4502";
|
const addr = "127.0.0.1:4502";
|
||||||
const buf = bufferServer(addr);
|
const buf = bufferServer(addr);
|
||||||
const body = "hello world";
|
const body = "hello world";
|
||||||
|
@ -727,7 +711,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchPostBodyTypedArray(): Promise<void> {
|
async function fetchPostBodyTypedArray() {
|
||||||
const addr = "127.0.0.1:4503";
|
const addr = "127.0.0.1:4503";
|
||||||
const buf = bufferServer(addr);
|
const buf = bufferServer(addr);
|
||||||
const bodyStr = "hello world";
|
const bodyStr = "hello world";
|
||||||
|
@ -764,7 +748,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchWithNonAsciiRedirection(): Promise<void> {
|
async function fetchWithNonAsciiRedirection() {
|
||||||
const response = await fetch("http://localhost:4545/non_ascii_redirect", {
|
const response = await fetch("http://localhost:4545/non_ascii_redirect", {
|
||||||
redirect: "manual",
|
redirect: "manual",
|
||||||
});
|
});
|
||||||
|
@ -778,7 +762,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchWithManualRedirection(): Promise<void> {
|
async function fetchWithManualRedirection() {
|
||||||
const response = await fetch("http://localhost:4546/", {
|
const response = await fetch("http://localhost:4546/", {
|
||||||
redirect: "manual",
|
redirect: "manual",
|
||||||
}); // will redirect to http://localhost:4545/
|
}); // will redirect to http://localhost:4545/
|
||||||
|
@ -794,7 +778,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchWithErrorRedirection(): Promise<void> {
|
async function fetchWithErrorRedirection() {
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
() =>
|
() =>
|
||||||
fetch("http://localhost:4546/", {
|
fetch("http://localhost:4546/", {
|
||||||
|
@ -806,7 +790,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(function responseRedirect(): void {
|
unitTest(function responseRedirect() {
|
||||||
const redir = Response.redirect("example.com/newLocation", 301);
|
const redir = Response.redirect("example.com/newLocation", 301);
|
||||||
assertEquals(redir.status, 301);
|
assertEquals(redir.status, 301);
|
||||||
assertEquals(redir.statusText, "");
|
assertEquals(redir.statusText, "");
|
||||||
|
@ -818,7 +802,7 @@ unitTest(function responseRedirect(): void {
|
||||||
assertEquals(redir.type, "default");
|
assertEquals(redir.type, "default");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function responseWithoutBody(): Promise<void> {
|
unitTest(async function responseWithoutBody() {
|
||||||
const response = new Response();
|
const response = new Response();
|
||||||
assertEquals(await response.arrayBuffer(), new ArrayBuffer(0));
|
assertEquals(await response.arrayBuffer(), new ArrayBuffer(0));
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
|
@ -830,9 +814,7 @@ unitTest(async function responseWithoutBody(): Promise<void> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function fetchBodyReadTwice(): Promise<
|
unitTest({ perms: { net: true } }, async function fetchBodyReadTwice() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||||
|
|
||||||
// Read body
|
// Read body
|
||||||
|
@ -855,7 +837,7 @@ unitTest({ perms: { net: true } }, async function fetchBodyReadTwice(): Promise<
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchBodyReaderAfterRead(): Promise<void> {
|
async function fetchBodyReaderAfterRead() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"http://localhost:4545/cli/tests/fixture.json",
|
"http://localhost:4545/cli/tests/fixture.json",
|
||||||
);
|
);
|
||||||
|
@ -878,7 +860,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchBodyReaderWithCancelAndNewReader(): Promise<void> {
|
async function fetchBodyReaderWithCancelAndNewReader() {
|
||||||
const data = "a".repeat(1 << 10);
|
const data = "a".repeat(1 << 10);
|
||||||
const response = await fetch("http://localhost:4545/echo_server", {
|
const response = await fetch("http://localhost:4545/echo_server", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -906,7 +888,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchBodyReaderWithReadCancelAndNewReader(): Promise<void> {
|
async function fetchBodyReaderWithReadCancelAndNewReader() {
|
||||||
const data = "a".repeat(1 << 10);
|
const data = "a".repeat(1 << 10);
|
||||||
|
|
||||||
const response = await fetch("http://localhost:4545/echo_server", {
|
const response = await fetch("http://localhost:4545/echo_server", {
|
||||||
|
@ -936,7 +918,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchResourceCloseAfterStreamCancel(): Promise<void> {
|
async function fetchResourceCloseAfterStreamCancel() {
|
||||||
const res = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
const res = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||||
assert(res.body !== null);
|
assert(res.body !== null);
|
||||||
|
|
||||||
|
@ -954,7 +936,7 @@ unitTest(
|
||||||
// the software in your host machine. (os error 10053)
|
// the software in your host machine. (os error 10053)
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true }, ignore: Deno.build.os == "windows" },
|
{ perms: { net: true }, ignore: Deno.build.os == "windows" },
|
||||||
async function fetchNullBodyStatus(): Promise<void> {
|
async function fetchNullBodyStatus() {
|
||||||
const nullBodyStatus = [101, 204, 205, 304];
|
const nullBodyStatus = [101, 204, 205, 304];
|
||||||
|
|
||||||
for (const status of nullBodyStatus) {
|
for (const status of nullBodyStatus) {
|
||||||
|
@ -972,7 +954,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function fetchResponseContentLength(): Promise<void> {
|
async function fetchResponseContentLength() {
|
||||||
const body = new Uint8Array(2 ** 16);
|
const body = new Uint8Array(2 ** 16);
|
||||||
const headers = new Headers([["content-type", "application/octet-stream"]]);
|
const headers = new Headers([["content-type", "application/octet-stream"]]);
|
||||||
const res = await fetch("http://localhost:4545/echo_server", {
|
const res = await fetch("http://localhost:4545/echo_server", {
|
||||||
|
@ -989,7 +971,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(function fetchResponseConstructorNullBody(): void {
|
unitTest(function fetchResponseConstructorNullBody() {
|
||||||
const nullBodyStatus = [204, 205, 304];
|
const nullBodyStatus = [204, 205, 304];
|
||||||
|
|
||||||
for (const status of nullBodyStatus) {
|
for (const status of nullBodyStatus) {
|
||||||
|
@ -1006,7 +988,7 @@ unitTest(function fetchResponseConstructorNullBody(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fetchResponseConstructorInvalidStatus(): void {
|
unitTest(function fetchResponseConstructorInvalidStatus() {
|
||||||
const invalidStatus = [101, 600, 199, null, "", NaN];
|
const invalidStatus = [101, 600, 199, null, "", NaN];
|
||||||
|
|
||||||
for (const status of invalidStatus) {
|
for (const status of invalidStatus) {
|
||||||
|
@ -1022,7 +1004,7 @@ unitTest(function fetchResponseConstructorInvalidStatus(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fetchResponseEmptyConstructor(): void {
|
unitTest(function fetchResponseEmptyConstructor() {
|
||||||
const response = new Response();
|
const response = new Response();
|
||||||
assertEquals(response.status, 200);
|
assertEquals(response.status, 200);
|
||||||
assertEquals(response.body, null);
|
assertEquals(response.body, null);
|
||||||
|
@ -1099,7 +1081,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function fetchPostBodyReadableStream(): Promise<void> {
|
async function fetchPostBodyReadableStream() {
|
||||||
const addr = "127.0.0.1:4502";
|
const addr = "127.0.0.1:4502";
|
||||||
const buf = bufferServer(addr);
|
const buf = bufferServer(addr);
|
||||||
const stream = new TransformStream();
|
const stream = new TransformStream();
|
||||||
|
@ -1143,7 +1125,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({}, function fetchWritableRespProps(): void {
|
unitTest({}, function fetchWritableRespProps() {
|
||||||
const original = new Response("https://deno.land", {
|
const original = new Response("https://deno.land", {
|
||||||
status: 404,
|
status: 404,
|
||||||
headers: { "x-deno": "foo" },
|
headers: { "x-deno": "foo" },
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import { assert, assertEquals, unitTest } from "./test_util.ts";
|
import { assert, assertEquals, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
function testFirstArgument(arg1: any[], expectedSize: number): void {
|
function testFirstArgument(arg1: any[], expectedSize: number) {
|
||||||
const file = new File(arg1, "name");
|
const file = new File(arg1, "name");
|
||||||
assert(file instanceof File);
|
assert(file instanceof File);
|
||||||
assertEquals(file.name, "name");
|
assertEquals(file.name, "name");
|
||||||
|
@ -10,47 +10,47 @@ function testFirstArgument(arg1: any[], expectedSize: number): void {
|
||||||
assertEquals(file.type, "");
|
assertEquals(file.type, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
unitTest(function fileEmptyFileBits(): void {
|
unitTest(function fileEmptyFileBits() {
|
||||||
testFirstArgument([], 0);
|
testFirstArgument([], 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileStringFileBits(): void {
|
unitTest(function fileStringFileBits() {
|
||||||
testFirstArgument(["bits"], 4);
|
testFirstArgument(["bits"], 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileUnicodeStringFileBits(): void {
|
unitTest(function fileUnicodeStringFileBits() {
|
||||||
testFirstArgument(["𝓽𝓮𝔁𝓽"], 16);
|
testFirstArgument(["𝓽𝓮𝔁𝓽"], 16);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileStringObjectFileBits(): void {
|
unitTest(function fileStringObjectFileBits() {
|
||||||
testFirstArgument([new String("string object")], 13);
|
testFirstArgument([new String("string object")], 13);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileEmptyBlobFileBits(): void {
|
unitTest(function fileEmptyBlobFileBits() {
|
||||||
testFirstArgument([new Blob()], 0);
|
testFirstArgument([new Blob()], 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileBlobFileBits(): void {
|
unitTest(function fileBlobFileBits() {
|
||||||
testFirstArgument([new Blob(["bits"])], 4);
|
testFirstArgument([new Blob(["bits"])], 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileEmptyFileFileBits(): void {
|
unitTest(function fileEmptyFileFileBits() {
|
||||||
testFirstArgument([new File([], "world.txt")], 0);
|
testFirstArgument([new File([], "world.txt")], 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileFileFileBits(): void {
|
unitTest(function fileFileFileBits() {
|
||||||
testFirstArgument([new File(["bits"], "world.txt")], 4);
|
testFirstArgument([new File(["bits"], "world.txt")], 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileArrayBufferFileBits(): void {
|
unitTest(function fileArrayBufferFileBits() {
|
||||||
testFirstArgument([new ArrayBuffer(8)], 8);
|
testFirstArgument([new ArrayBuffer(8)], 8);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileTypedArrayFileBits(): void {
|
unitTest(function fileTypedArrayFileBits() {
|
||||||
testFirstArgument([new Uint8Array([0x50, 0x41, 0x53, 0x53])], 4);
|
testFirstArgument([new Uint8Array([0x50, 0x41, 0x53, 0x53])], 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileVariousFileBits(): void {
|
unitTest(function fileVariousFileBits() {
|
||||||
testFirstArgument(
|
testFirstArgument(
|
||||||
[
|
[
|
||||||
"bits",
|
"bits",
|
||||||
|
@ -64,45 +64,45 @@ unitTest(function fileVariousFileBits(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileNumberInFileBits(): void {
|
unitTest(function fileNumberInFileBits() {
|
||||||
testFirstArgument([12], 2);
|
testFirstArgument([12], 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileArrayInFileBits(): void {
|
unitTest(function fileArrayInFileBits() {
|
||||||
testFirstArgument([[1, 2, 3]], 5);
|
testFirstArgument([[1, 2, 3]], 5);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileObjectInFileBits(): void {
|
unitTest(function fileObjectInFileBits() {
|
||||||
// "[object Object]"
|
// "[object Object]"
|
||||||
testFirstArgument([{}], 15);
|
testFirstArgument([{}], 15);
|
||||||
});
|
});
|
||||||
|
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
function testSecondArgument(arg2: any, expectedFileName: string): void {
|
function testSecondArgument(arg2: any, expectedFileName: string) {
|
||||||
const file = new File(["bits"], arg2);
|
const file = new File(["bits"], arg2);
|
||||||
assert(file instanceof File);
|
assert(file instanceof File);
|
||||||
assertEquals(file.name, expectedFileName);
|
assertEquals(file.name, expectedFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
unitTest(function fileUsingFileName(): void {
|
unitTest(function fileUsingFileName() {
|
||||||
testSecondArgument("dummy", "dummy");
|
testSecondArgument("dummy", "dummy");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileUsingNullFileName(): void {
|
unitTest(function fileUsingNullFileName() {
|
||||||
testSecondArgument(null, "null");
|
testSecondArgument(null, "null");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileUsingNumberFileName(): void {
|
unitTest(function fileUsingNumberFileName() {
|
||||||
testSecondArgument(1, "1");
|
testSecondArgument(1, "1");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function fileUsingEmptyStringFileName(): void {
|
unitTest(function fileUsingEmptyStringFileName() {
|
||||||
testSecondArgument("", "");
|
testSecondArgument("", "");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function fileTruncateSyncSuccess(): void {
|
function fileTruncateSyncSuccess() {
|
||||||
const filename = Deno.makeTempDirSync() + "/test_fileTruncateSync.txt";
|
const filename = Deno.makeTempDirSync() + "/test_fileTruncateSync.txt";
|
||||||
const file = Deno.openSync(filename, {
|
const file = Deno.openSync(filename, {
|
||||||
create: true,
|
create: true,
|
||||||
|
@ -124,7 +124,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function fileTruncateSuccess(): Promise<void> {
|
async function fileTruncateSuccess() {
|
||||||
const filename = Deno.makeTempDirSync() + "/test_fileTruncate.txt";
|
const filename = Deno.makeTempDirSync() + "/test_fileTruncate.txt";
|
||||||
const file = await Deno.open(filename, {
|
const file = await Deno.open(filename, {
|
||||||
create: true,
|
create: true,
|
||||||
|
@ -144,7 +144,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function fileStatSyncSuccess(): void {
|
unitTest({ perms: { read: true } }, function fileStatSyncSuccess() {
|
||||||
const file = Deno.openSync("README.md");
|
const file = Deno.openSync("README.md");
|
||||||
const fileInfo = file.statSync();
|
const fileInfo = file.statSync();
|
||||||
assert(fileInfo.isFile);
|
assert(fileInfo.isFile);
|
||||||
|
@ -159,9 +159,7 @@ unitTest({ perms: { read: true } }, function fileStatSyncSuccess(): void {
|
||||||
file.close();
|
file.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function fileStatSuccess(): Promise<
|
unitTest({ perms: { read: true } }, async function fileStatSuccess() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const file = await Deno.open("README.md");
|
const file = await Deno.open("README.md");
|
||||||
const fileInfo = await file.stat();
|
const fileInfo = await file.stat();
|
||||||
assert(fileInfo.isFile);
|
assert(fileInfo.isFile);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertEquals, unitTest } from "./test_util.ts";
|
import { assertEquals, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function fileReaderConstruct(): void {
|
unitTest(function fileReaderConstruct() {
|
||||||
const fr = new FileReader();
|
const fr = new FileReader();
|
||||||
assertEquals(fr.readyState, FileReader.EMPTY);
|
assertEquals(fr.readyState, FileReader.EMPTY);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ unitTest(function fileReaderConstruct(): void {
|
||||||
assertEquals(FileReader.DONE, 2);
|
assertEquals(FileReader.DONE, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function fileReaderLoadBlob(): Promise<void> {
|
unitTest(async function fileReaderLoadBlob() {
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
const fr = new FileReader();
|
const fr = new FileReader();
|
||||||
const b1 = new Blob(["Hello World"]);
|
const b1 = new Blob(["Hello World"]);
|
||||||
|
@ -44,18 +44,18 @@ unitTest(async function fileReaderLoadBlob(): Promise<void> {
|
||||||
hasDispatchedEvents.progress += 1;
|
hasDispatchedEvents.progress += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
fr.onloadstart = (): void => {
|
fr.onloadstart = () => {
|
||||||
hasOnEvents.loadstart = true;
|
hasOnEvents.loadstart = true;
|
||||||
};
|
};
|
||||||
fr.onprogress = (): void => {
|
fr.onprogress = () => {
|
||||||
assertEquals(fr.readyState, FileReader.LOADING);
|
assertEquals(fr.readyState, FileReader.LOADING);
|
||||||
|
|
||||||
hasOnEvents.progress += 1;
|
hasOnEvents.progress += 1;
|
||||||
};
|
};
|
||||||
fr.onload = (): void => {
|
fr.onload = () => {
|
||||||
hasOnEvents.load = true;
|
hasOnEvents.load = true;
|
||||||
};
|
};
|
||||||
fr.onloadend = (ev): void => {
|
fr.onloadend = (ev) => {
|
||||||
hasOnEvents.loadend = true;
|
hasOnEvents.loadend = true;
|
||||||
result = fr.result as string;
|
result = fr.result as string;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ unitTest(async function fileReaderLoadBlob(): Promise<void> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function fileReaderLoadBlobDouble(): Promise<void> {
|
unitTest(async function fileReaderLoadBlobDouble() {
|
||||||
// impl note from https://w3c.github.io/FileAPI/
|
// impl note from https://w3c.github.io/FileAPI/
|
||||||
// Event handler for the load or error events could have started another load,
|
// Event handler for the load or error events could have started another load,
|
||||||
// if that happens the loadend event for the first load is not fired
|
// if that happens the loadend event for the first load is not fired
|
||||||
|
@ -89,7 +89,7 @@ unitTest(async function fileReaderLoadBlobDouble(): Promise<void> {
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
let result: string | null = null;
|
let result: string | null = null;
|
||||||
|
|
||||||
fr.onload = (): void => {
|
fr.onload = () => {
|
||||||
result = fr.result as string;
|
result = fr.result as string;
|
||||||
assertEquals(result === "First load" || result === "Second load", true);
|
assertEquals(result === "First load" || result === "Second load", true);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ unitTest(async function fileReaderLoadBlobDouble(): Promise<void> {
|
||||||
fr.readAsText(b2);
|
fr.readAsText(b2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fr.onloadend = (): void => {
|
fr.onloadend = () => {
|
||||||
assertEquals(result, "Second load");
|
assertEquals(result, "Second load");
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -107,13 +107,13 @@ unitTest(async function fileReaderLoadBlobDouble(): Promise<void> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function fileReaderLoadBlobArrayBuffer(): Promise<void> {
|
unitTest(async function fileReaderLoadBlobArrayBuffer() {
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
const fr = new FileReader();
|
const fr = new FileReader();
|
||||||
const b1 = new Blob(["Hello World"]);
|
const b1 = new Blob(["Hello World"]);
|
||||||
let result: ArrayBuffer | null = null;
|
let result: ArrayBuffer | null = null;
|
||||||
|
|
||||||
fr.onloadend = (ev): void => {
|
fr.onloadend = (ev) => {
|
||||||
assertEquals(fr.result instanceof ArrayBuffer, true);
|
assertEquals(fr.result instanceof ArrayBuffer, true);
|
||||||
result = fr.result as ArrayBuffer;
|
result = fr.result as ArrayBuffer;
|
||||||
|
|
||||||
|
@ -129,13 +129,13 @@ unitTest(async function fileReaderLoadBlobArrayBuffer(): Promise<void> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function fileReaderLoadBlobDataUrl(): Promise<void> {
|
unitTest(async function fileReaderLoadBlobDataUrl() {
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
const fr = new FileReader();
|
const fr = new FileReader();
|
||||||
const b1 = new Blob(["Hello World"]);
|
const b1 = new Blob(["Hello World"]);
|
||||||
let result: string | null = null;
|
let result: string | null = null;
|
||||||
|
|
||||||
fr.onloadend = (ev): void => {
|
fr.onloadend = (ev) => {
|
||||||
result = fr.result as string;
|
result = fr.result as string;
|
||||||
assertEquals(
|
assertEquals(
|
||||||
result,
|
result,
|
||||||
|
@ -149,7 +149,7 @@ unitTest(async function fileReaderLoadBlobDataUrl(): Promise<void> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function fileReaderLoadBlobAbort(): Promise<void> {
|
unitTest(async function fileReaderLoadBlobAbort() {
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
const fr = new FileReader();
|
const fr = new FileReader();
|
||||||
const b1 = new Blob(["Hello World"]);
|
const b1 = new Blob(["Hello World"]);
|
||||||
|
@ -160,10 +160,10 @@ unitTest(async function fileReaderLoadBlobAbort(): Promise<void> {
|
||||||
abort: false,
|
abort: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
fr.onload = (): void => {
|
fr.onload = () => {
|
||||||
hasOnEvents.load = true;
|
hasOnEvents.load = true;
|
||||||
};
|
};
|
||||||
fr.onloadend = (ev): void => {
|
fr.onloadend = (ev) => {
|
||||||
hasOnEvents.loadend = true;
|
hasOnEvents.loadend = true;
|
||||||
|
|
||||||
assertEquals(hasOnEvents.load, false);
|
assertEquals(hasOnEvents.load, false);
|
||||||
|
@ -175,7 +175,7 @@ unitTest(async function fileReaderLoadBlobAbort(): Promise<void> {
|
||||||
assertEquals(ev.lengthComputable, false);
|
assertEquals(ev.lengthComputable, false);
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
fr.onabort = (): void => {
|
fr.onabort = () => {
|
||||||
hasOnEvents.abort = true;
|
hasOnEvents.abort = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ unitTest(async function fileReaderLoadBlobAbort(): Promise<void> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function fileReaderLoadBlobAbort(): Promise<void> {
|
unitTest(async function fileReaderLoadBlobAbort() {
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
const fr = new FileReader();
|
const fr = new FileReader();
|
||||||
const b1 = new Blob(["Hello World"]);
|
const b1 = new Blob(["Hello World"]);
|
||||||
|
@ -195,10 +195,10 @@ unitTest(async function fileReaderLoadBlobAbort(): Promise<void> {
|
||||||
abort: false,
|
abort: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
fr.onload = (): void => {
|
fr.onload = () => {
|
||||||
hasOnEvents.load = true;
|
hasOnEvents.load = true;
|
||||||
};
|
};
|
||||||
fr.onloadend = (ev): void => {
|
fr.onloadend = (ev) => {
|
||||||
hasOnEvents.loadend = true;
|
hasOnEvents.loadend = true;
|
||||||
|
|
||||||
assertEquals(hasOnEvents.load, false);
|
assertEquals(hasOnEvents.load, false);
|
||||||
|
@ -210,7 +210,7 @@ unitTest(async function fileReaderLoadBlobAbort(): Promise<void> {
|
||||||
assertEquals(ev.lengthComputable, false);
|
assertEquals(ev.lengthComputable, false);
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
fr.onabort = (): void => {
|
fr.onabort = () => {
|
||||||
hasOnEvents.abort = true;
|
hasOnEvents.abort = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ unitTest(async function fileReaderLoadBlobAbort(): Promise<void> {
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
async function fileReaderDispatchesEventsInCorrectOrder(): Promise<void> {
|
async function fileReaderDispatchesEventsInCorrectOrder() {
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
const fr = new FileReader();
|
const fr = new FileReader();
|
||||||
const b1 = new Blob(["Hello World"]);
|
const b1 = new Blob(["Hello World"]);
|
||||||
|
@ -228,7 +228,7 @@ unitTest(
|
||||||
fr.addEventListener("loadend", () => {
|
fr.addEventListener("loadend", () => {
|
||||||
out += "1";
|
out += "1";
|
||||||
});
|
});
|
||||||
fr.onloadend = (_ev): void => {
|
fr.onloadend = (_ev) => {
|
||||||
out += "2";
|
out += "2";
|
||||||
};
|
};
|
||||||
fr.addEventListener("loadend", () => {
|
fr.addEventListener("loadend", () => {
|
||||||
|
|
|
@ -10,15 +10,13 @@ import {
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
import { copy } from "../../../test_util/std/io/util.ts";
|
import { copy } from "../../../test_util/std/io/util.ts";
|
||||||
|
|
||||||
unitTest(function filesStdioFileDescriptors(): void {
|
unitTest(function filesStdioFileDescriptors() {
|
||||||
assertEquals(Deno.stdin.rid, 0);
|
assertEquals(Deno.stdin.rid, 0);
|
||||||
assertEquals(Deno.stdout.rid, 1);
|
assertEquals(Deno.stdout.rid, 1);
|
||||||
assertEquals(Deno.stderr.rid, 2);
|
assertEquals(Deno.stderr.rid, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function filesCopyToStdout(): Promise<
|
unitTest({ perms: { read: true } }, async function filesCopyToStdout() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const filename = "cli/tests/fixture.json";
|
const filename = "cli/tests/fixture.json";
|
||||||
const file = await Deno.open(filename);
|
const file = await Deno.open(filename);
|
||||||
assert(file.rid > 2);
|
assert(file.rid > 2);
|
||||||
|
@ -28,7 +26,7 @@ unitTest({ perms: { read: true } }, async function filesCopyToStdout(): Promise<
|
||||||
file.close();
|
file.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function filesIter(): Promise<void> {
|
unitTest({ perms: { read: true } }, async function filesIter() {
|
||||||
const filename = "cli/tests/hello.txt";
|
const filename = "cli/tests/hello.txt";
|
||||||
const file = await Deno.open(filename);
|
const file = await Deno.open(filename);
|
||||||
|
|
||||||
|
@ -43,7 +41,7 @@ unitTest({ perms: { read: true } }, async function filesIter(): Promise<void> {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true } },
|
{ perms: { read: true } },
|
||||||
async function filesIterCustomBufSize(): Promise<void> {
|
async function filesIterCustomBufSize() {
|
||||||
const filename = "cli/tests/hello.txt";
|
const filename = "cli/tests/hello.txt";
|
||||||
const file = await Deno.open(filename);
|
const file = await Deno.open(filename);
|
||||||
|
|
||||||
|
@ -60,7 +58,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function filesIterSync(): void {
|
unitTest({ perms: { read: true } }, function filesIterSync() {
|
||||||
const filename = "cli/tests/hello.txt";
|
const filename = "cli/tests/hello.txt";
|
||||||
const file = Deno.openSync(filename);
|
const file = Deno.openSync(filename);
|
||||||
|
|
||||||
|
@ -75,7 +73,7 @@ unitTest({ perms: { read: true } }, function filesIterSync(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true } },
|
{ perms: { read: true } },
|
||||||
function filesIterSyncCustomBufSize(): void {
|
function filesIterSyncCustomBufSize() {
|
||||||
const filename = "cli/tests/hello.txt";
|
const filename = "cli/tests/hello.txt";
|
||||||
const file = Deno.openSync(filename);
|
const file = Deno.openSync(filename);
|
||||||
|
|
||||||
|
@ -92,7 +90,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(async function readerIter(): Promise<void> {
|
unitTest(async function readerIter() {
|
||||||
// ref: https://github.com/denoland/deno/issues/2330
|
// ref: https://github.com/denoland/deno/issues/2330
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
|
|
||||||
|
@ -127,7 +125,7 @@ unitTest(async function readerIter(): Promise<void> {
|
||||||
assertEquals(totalSize, 12);
|
assertEquals(totalSize, 12);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function readerIterSync(): Promise<void> {
|
unitTest(async function readerIterSync() {
|
||||||
// ref: https://github.com/denoland/deno/issues/2330
|
// ref: https://github.com/denoland/deno/issues/2330
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
|
|
||||||
|
@ -166,7 +164,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { read: true, write: true },
|
perms: { read: true, write: true },
|
||||||
},
|
},
|
||||||
function openSyncMode(): void {
|
function openSyncMode() {
|
||||||
const path = Deno.makeTempDirSync() + "/test_openSync.txt";
|
const path = Deno.makeTempDirSync() + "/test_openSync.txt";
|
||||||
const file = Deno.openSync(path, {
|
const file = Deno.openSync(path, {
|
||||||
write: true,
|
write: true,
|
||||||
|
@ -185,7 +183,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { read: true, write: true },
|
perms: { read: true, write: true },
|
||||||
},
|
},
|
||||||
async function openMode(): Promise<void> {
|
async function openMode() {
|
||||||
const path = (await Deno.makeTempDir()) + "/test_open.txt";
|
const path = (await Deno.makeTempDir()) + "/test_open.txt";
|
||||||
const file = await Deno.open(path, {
|
const file = await Deno.open(path, {
|
||||||
write: true,
|
write: true,
|
||||||
|
@ -204,7 +202,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { read: true, write: true },
|
perms: { read: true, write: true },
|
||||||
},
|
},
|
||||||
function openSyncUrl(): void {
|
function openSyncUrl() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const fileUrl = new URL(
|
const fileUrl = new URL(
|
||||||
`file://${
|
`file://${
|
||||||
|
@ -230,7 +228,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { read: true, write: true },
|
perms: { read: true, write: true },
|
||||||
},
|
},
|
||||||
async function openUrl(): Promise<void> {
|
async function openUrl() {
|
||||||
const tempDir = await Deno.makeTempDir();
|
const tempDir = await Deno.makeTempDir();
|
||||||
const fileUrl = new URL(
|
const fileUrl = new URL(
|
||||||
`file://${
|
`file://${
|
||||||
|
@ -254,7 +252,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: false } },
|
{ perms: { write: false } },
|
||||||
async function writePermFailure(): Promise<void> {
|
async function writePermFailure() {
|
||||||
const filename = "tests/hello.txt";
|
const filename = "tests/hello.txt";
|
||||||
const openOptions: Deno.OpenOptions[] = [{ write: true }, { append: true }];
|
const openOptions: Deno.OpenOptions[] = [{ write: true }, { append: true }];
|
||||||
for (const options of openOptions) {
|
for (const options of openOptions) {
|
||||||
|
@ -265,10 +263,10 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(async function openOptions(): Promise<void> {
|
unitTest(async function openOptions() {
|
||||||
const filename = "cli/tests/fixture.json";
|
const filename = "cli/tests/fixture.json";
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await Deno.open(filename, { write: false });
|
await Deno.open(filename, { write: false });
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
|
@ -276,7 +274,7 @@ unitTest(async function openOptions(): Promise<void> {
|
||||||
);
|
);
|
||||||
|
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await Deno.open(filename, { truncate: true, write: false });
|
await Deno.open(filename, { truncate: true, write: false });
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
|
@ -284,7 +282,7 @@ unitTest(async function openOptions(): Promise<void> {
|
||||||
);
|
);
|
||||||
|
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await Deno.open(filename, { create: true, write: false });
|
await Deno.open(filename, { create: true, write: false });
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
|
@ -292,7 +290,7 @@ unitTest(async function openOptions(): Promise<void> {
|
||||||
);
|
);
|
||||||
|
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await Deno.open(filename, { createNew: true, append: false });
|
await Deno.open(filename, { createNew: true, append: false });
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
|
@ -300,9 +298,7 @@ unitTest(async function openOptions(): Promise<void> {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, async function readPermFailure(): Promise<
|
unitTest({ perms: { read: false } }, async function readPermFailure() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.open("package.json", { read: true });
|
await Deno.open("package.json", { read: true });
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -310,7 +306,7 @@ unitTest({ perms: { read: false } }, async function readPermFailure(): Promise<
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true } },
|
{ perms: { write: true } },
|
||||||
async function writeNullBufferFailure(): Promise<void> {
|
async function writeNullBufferFailure() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const filename = tempDir + "hello.txt";
|
const filename = tempDir + "hello.txt";
|
||||||
const w = {
|
const w = {
|
||||||
|
@ -322,7 +318,7 @@ unitTest(
|
||||||
|
|
||||||
// writing null should throw an error
|
// writing null should throw an error
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
await file.write(null as any);
|
await file.write(null as any);
|
||||||
},
|
},
|
||||||
|
@ -334,7 +330,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
async function readNullBufferFailure(): Promise<void> {
|
async function readNullBufferFailure() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const filename = tempDir + "hello.txt";
|
const filename = tempDir + "hello.txt";
|
||||||
const file = await Deno.open(filename, {
|
const file = await Deno.open(filename, {
|
||||||
|
@ -362,7 +358,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: false, read: false } },
|
{ perms: { write: false, read: false } },
|
||||||
async function readWritePermFailure(): Promise<void> {
|
async function readWritePermFailure() {
|
||||||
const filename = "tests/hello.txt";
|
const filename = "tests/hello.txt";
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.open(filename, { read: true });
|
await Deno.open(filename, { read: true });
|
||||||
|
@ -372,7 +368,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function createFile(): Promise<void> {
|
async function createFile() {
|
||||||
const tempDir = await Deno.makeTempDir();
|
const tempDir = await Deno.makeTempDir();
|
||||||
const filename = tempDir + "/test.txt";
|
const filename = tempDir + "/test.txt";
|
||||||
const f = await Deno.create(filename);
|
const f = await Deno.create(filename);
|
||||||
|
@ -393,7 +389,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function createFileWithUrl(): Promise<void> {
|
async function createFileWithUrl() {
|
||||||
const tempDir = await Deno.makeTempDir();
|
const tempDir = await Deno.makeTempDir();
|
||||||
const fileUrl = new URL(
|
const fileUrl = new URL(
|
||||||
`file://${Deno.build.os === "windows" ? "/" : ""}${tempDir}/test.txt`,
|
`file://${Deno.build.os === "windows" ? "/" : ""}${tempDir}/test.txt`,
|
||||||
|
@ -415,7 +411,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function createSyncFile(): Promise<void> {
|
async function createSyncFile() {
|
||||||
const tempDir = await Deno.makeTempDir();
|
const tempDir = await Deno.makeTempDir();
|
||||||
const filename = tempDir + "/test.txt";
|
const filename = tempDir + "/test.txt";
|
||||||
const f = Deno.createSync(filename);
|
const f = Deno.createSync(filename);
|
||||||
|
@ -436,7 +432,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function createSyncFileWithUrl(): Promise<void> {
|
async function createSyncFileWithUrl() {
|
||||||
const tempDir = await Deno.makeTempDir();
|
const tempDir = await Deno.makeTempDir();
|
||||||
const fileUrl = new URL(
|
const fileUrl = new URL(
|
||||||
`file://${Deno.build.os === "windows" ? "/" : ""}${tempDir}/test.txt`,
|
`file://${Deno.build.os === "windows" ? "/" : ""}${tempDir}/test.txt`,
|
||||||
|
@ -458,7 +454,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function openModeWrite(): Promise<void> {
|
async function openModeWrite() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const filename = tempDir + "hello.txt";
|
const filename = tempDir + "hello.txt";
|
||||||
|
@ -501,7 +497,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function openModeWriteRead(): Promise<void> {
|
async function openModeWriteRead() {
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const filename = tempDir + "hello.txt";
|
const filename = tempDir + "hello.txt";
|
||||||
|
@ -535,7 +531,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function seekStart(): Promise<void> {
|
unitTest({ perms: { read: true } }, async function seekStart() {
|
||||||
const filename = "cli/tests/hello.txt";
|
const filename = "cli/tests/hello.txt";
|
||||||
const file = await Deno.open(filename);
|
const file = await Deno.open(filename);
|
||||||
const seekPosition = 6;
|
const seekPosition = 6;
|
||||||
|
@ -552,7 +548,7 @@ unitTest({ perms: { read: true } }, async function seekStart(): Promise<void> {
|
||||||
file.close();
|
file.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function seekSyncStart(): void {
|
unitTest({ perms: { read: true } }, function seekSyncStart() {
|
||||||
const filename = "cli/tests/hello.txt";
|
const filename = "cli/tests/hello.txt";
|
||||||
const file = Deno.openSync(filename);
|
const file = Deno.openSync(filename);
|
||||||
const seekPosition = 6;
|
const seekPosition = 6;
|
||||||
|
@ -569,9 +565,7 @@ unitTest({ perms: { read: true } }, function seekSyncStart(): void {
|
||||||
file.close();
|
file.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function seekCurrent(): Promise<
|
unitTest({ perms: { read: true } }, async function seekCurrent() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const filename = "cli/tests/hello.txt";
|
const filename = "cli/tests/hello.txt";
|
||||||
const file = await Deno.open(filename);
|
const file = await Deno.open(filename);
|
||||||
// Deliberately move 1 step forward
|
// Deliberately move 1 step forward
|
||||||
|
@ -588,7 +582,7 @@ unitTest({ perms: { read: true } }, async function seekCurrent(): Promise<
|
||||||
file.close();
|
file.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function seekSyncCurrent(): void {
|
unitTest({ perms: { read: true } }, function seekSyncCurrent() {
|
||||||
const filename = "cli/tests/hello.txt";
|
const filename = "cli/tests/hello.txt";
|
||||||
const file = Deno.openSync(filename);
|
const file = Deno.openSync(filename);
|
||||||
// Deliberately move 1 step forward
|
// Deliberately move 1 step forward
|
||||||
|
@ -605,7 +599,7 @@ unitTest({ perms: { read: true } }, function seekSyncCurrent(): void {
|
||||||
file.close();
|
file.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function seekEnd(): Promise<void> {
|
unitTest({ perms: { read: true } }, async function seekEnd() {
|
||||||
const filename = "cli/tests/hello.txt";
|
const filename = "cli/tests/hello.txt";
|
||||||
const file = await Deno.open(filename);
|
const file = await Deno.open(filename);
|
||||||
const seekPosition = -6;
|
const seekPosition = -6;
|
||||||
|
@ -619,7 +613,7 @@ unitTest({ perms: { read: true } }, async function seekEnd(): Promise<void> {
|
||||||
file.close();
|
file.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function seekSyncEnd(): void {
|
unitTest({ perms: { read: true } }, function seekSyncEnd() {
|
||||||
const filename = "cli/tests/hello.txt";
|
const filename = "cli/tests/hello.txt";
|
||||||
const file = Deno.openSync(filename);
|
const file = Deno.openSync(filename);
|
||||||
const seekPosition = -6;
|
const seekPosition = -6;
|
||||||
|
@ -633,11 +627,11 @@ unitTest({ perms: { read: true } }, function seekSyncEnd(): void {
|
||||||
file.close();
|
file.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function seekMode(): Promise<void> {
|
unitTest({ perms: { read: true } }, async function seekMode() {
|
||||||
const filename = "cli/tests/hello.txt";
|
const filename = "cli/tests/hello.txt";
|
||||||
const file = await Deno.open(filename);
|
const file = await Deno.open(filename);
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await file.seek(1, -1);
|
await file.seek(1, -1);
|
||||||
},
|
},
|
||||||
TypeError,
|
TypeError,
|
||||||
|
|
|
@ -38,7 +38,7 @@ async function getTwoEvents(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function watchFsBasic(): Promise<void> {
|
async function watchFsBasic() {
|
||||||
const testDir = await Deno.makeTempDir();
|
const testDir = await Deno.makeTempDir();
|
||||||
const iter = Deno.watchFs(testDir);
|
const iter = Deno.watchFs(testDir);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ unitTest(
|
||||||
// This should be removed at 2.0
|
// This should be removed at 2.0
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function watchFsReturn(): Promise<void> {
|
async function watchFsReturn() {
|
||||||
const testDir = await Deno.makeTempDir();
|
const testDir = await Deno.makeTempDir();
|
||||||
const iter = Deno.watchFs(testDir);
|
const iter = Deno.watchFs(testDir);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function watchFsClose(): Promise<void> {
|
async function watchFsClose() {
|
||||||
const testDir = await Deno.makeTempDir();
|
const testDir = await Deno.makeTempDir();
|
||||||
const iter = Deno.watchFs(testDir);
|
const iter = Deno.watchFs(testDir);
|
||||||
|
|
||||||
|
|
|
@ -1,49 +1,49 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertNotEquals, assertStrictEquals, unitTest } from "./test_util.ts";
|
import { assertNotEquals, assertStrictEquals, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function getRandomValuesInt8Array(): void {
|
unitTest(function getRandomValuesInt8Array() {
|
||||||
const arr = new Int8Array(32);
|
const arr = new Int8Array(32);
|
||||||
crypto.getRandomValues(arr);
|
crypto.getRandomValues(arr);
|
||||||
assertNotEquals(arr, new Int8Array(32));
|
assertNotEquals(arr, new Int8Array(32));
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function getRandomValuesUint8Array(): void {
|
unitTest(function getRandomValuesUint8Array() {
|
||||||
const arr = new Uint8Array(32);
|
const arr = new Uint8Array(32);
|
||||||
crypto.getRandomValues(arr);
|
crypto.getRandomValues(arr);
|
||||||
assertNotEquals(arr, new Uint8Array(32));
|
assertNotEquals(arr, new Uint8Array(32));
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function getRandomValuesUint8ClampedArray(): void {
|
unitTest(function getRandomValuesUint8ClampedArray() {
|
||||||
const arr = new Uint8ClampedArray(32);
|
const arr = new Uint8ClampedArray(32);
|
||||||
crypto.getRandomValues(arr);
|
crypto.getRandomValues(arr);
|
||||||
assertNotEquals(arr, new Uint8ClampedArray(32));
|
assertNotEquals(arr, new Uint8ClampedArray(32));
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function getRandomValuesInt16Array(): void {
|
unitTest(function getRandomValuesInt16Array() {
|
||||||
const arr = new Int16Array(4);
|
const arr = new Int16Array(4);
|
||||||
crypto.getRandomValues(arr);
|
crypto.getRandomValues(arr);
|
||||||
assertNotEquals(arr, new Int16Array(4));
|
assertNotEquals(arr, new Int16Array(4));
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function getRandomValuesUint16Array(): void {
|
unitTest(function getRandomValuesUint16Array() {
|
||||||
const arr = new Uint16Array(4);
|
const arr = new Uint16Array(4);
|
||||||
crypto.getRandomValues(arr);
|
crypto.getRandomValues(arr);
|
||||||
assertNotEquals(arr, new Uint16Array(4));
|
assertNotEquals(arr, new Uint16Array(4));
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function getRandomValuesInt32Array(): void {
|
unitTest(function getRandomValuesInt32Array() {
|
||||||
const arr = new Int32Array(8);
|
const arr = new Int32Array(8);
|
||||||
crypto.getRandomValues(arr);
|
crypto.getRandomValues(arr);
|
||||||
assertNotEquals(arr, new Int32Array(8));
|
assertNotEquals(arr, new Int32Array(8));
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function getRandomValuesUint32Array(): void {
|
unitTest(function getRandomValuesUint32Array() {
|
||||||
const arr = new Uint32Array(8);
|
const arr = new Uint32Array(8);
|
||||||
crypto.getRandomValues(arr);
|
crypto.getRandomValues(arr);
|
||||||
assertNotEquals(arr, new Uint32Array(8));
|
assertNotEquals(arr, new Uint32Array(8));
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function getRandomValuesReturnValue(): void {
|
unitTest(function getRandomValuesReturnValue() {
|
||||||
const arr = new Uint32Array(8);
|
const arr = new Uint32Array(8);
|
||||||
const rtn = crypto.getRandomValues(arr);
|
const rtn = crypto.getRandomValues(arr);
|
||||||
assertNotEquals(arr, new Uint32Array(8));
|
assertNotEquals(arr, new Uint32Array(8));
|
||||||
|
|
|
@ -1,72 +1,72 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assert, unitTest } from "./test_util.ts";
|
import { assert, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function globalThisExists(): void {
|
unitTest(function globalThisExists() {
|
||||||
assert(globalThis != null);
|
assert(globalThis != null);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function noInternalGlobals(): void {
|
unitTest(function noInternalGlobals() {
|
||||||
// globalThis.__bootstrap should not be there.
|
// globalThis.__bootstrap should not be there.
|
||||||
for (const key of Object.keys(globalThis)) {
|
for (const key of Object.keys(globalThis)) {
|
||||||
assert(!key.startsWith("_"));
|
assert(!key.startsWith("_"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function windowExists(): void {
|
unitTest(function windowExists() {
|
||||||
assert(window != null);
|
assert(window != null);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function selfExists(): void {
|
unitTest(function selfExists() {
|
||||||
assert(self != null);
|
assert(self != null);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function windowWindowExists(): void {
|
unitTest(function windowWindowExists() {
|
||||||
assert(window.window === window);
|
assert(window.window === window);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function windowSelfExists(): void {
|
unitTest(function windowSelfExists() {
|
||||||
assert(window.self === window);
|
assert(window.self === window);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function globalThisEqualsWindow(): void {
|
unitTest(function globalThisEqualsWindow() {
|
||||||
assert(globalThis === window);
|
assert(globalThis === window);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function globalThisEqualsSelf(): void {
|
unitTest(function globalThisEqualsSelf() {
|
||||||
assert(globalThis === self);
|
assert(globalThis === self);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function globalThisInstanceofWindow(): void {
|
unitTest(function globalThisInstanceofWindow() {
|
||||||
assert(globalThis instanceof Window);
|
assert(globalThis instanceof Window);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function globalThisConstructorLength(): void {
|
unitTest(function globalThisConstructorLength() {
|
||||||
assert(globalThis.constructor.length === 0);
|
assert(globalThis.constructor.length === 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function globalThisInstanceofEventTarget(): void {
|
unitTest(function globalThisInstanceofEventTarget() {
|
||||||
assert(globalThis instanceof EventTarget);
|
assert(globalThis instanceof EventTarget);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function navigatorInstanceofNavigator(): void {
|
unitTest(function navigatorInstanceofNavigator() {
|
||||||
// TODO(nayeemrmn): Add `Navigator` to deno_lint globals.
|
// TODO(nayeemrmn): Add `Navigator` to deno_lint globals.
|
||||||
// deno-lint-ignore no-undef
|
// deno-lint-ignore no-undef
|
||||||
assert(navigator instanceof Navigator);
|
assert(navigator instanceof Navigator);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function DenoNamespaceExists(): void {
|
unitTest(function DenoNamespaceExists() {
|
||||||
assert(Deno != null);
|
assert(Deno != null);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function DenoNamespaceEqualsWindowDeno(): void {
|
unitTest(function DenoNamespaceEqualsWindowDeno() {
|
||||||
assert(Deno === window.Deno);
|
assert(Deno === window.Deno);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function DenoNamespaceIsNotFrozen(): void {
|
unitTest(function DenoNamespaceIsNotFrozen() {
|
||||||
assert(!Object.isFrozen(Deno));
|
assert(!Object.isFrozen(Deno));
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function webAssemblyExists(): void {
|
unitTest(function webAssemblyExists() {
|
||||||
assert(typeof WebAssembly.compile === "function");
|
assert(typeof WebAssembly.compile === "function");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ unitTest(function DenoNamespaceConfigurable() {
|
||||||
assert(!desc.writable);
|
assert(!desc.writable);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function DenoCoreNamespaceIsImmutable(): void {
|
unitTest(function DenoCoreNamespaceIsImmutable() {
|
||||||
const { print } = Deno.core;
|
const { print } = Deno.core;
|
||||||
try {
|
try {
|
||||||
Deno.core.print = 1;
|
Deno.core.print = 1;
|
||||||
|
@ -100,18 +100,18 @@ unitTest(function DenoCoreNamespaceIsImmutable(): void {
|
||||||
assert(print === Deno.core.print);
|
assert(print === Deno.core.print);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function windowQueueMicrotask(): Promise<void> {
|
unitTest(async function windowQueueMicrotask() {
|
||||||
let resolve1: () => void | undefined;
|
let resolve1: () => void | undefined;
|
||||||
let resolve2: () => void | undefined;
|
let resolve2: () => void | undefined;
|
||||||
let microtaskDone = false;
|
let microtaskDone = false;
|
||||||
const p1 = new Promise<void>((res): void => {
|
const p1 = new Promise<void>((res) => {
|
||||||
resolve1 = (): void => {
|
resolve1 = () => {
|
||||||
microtaskDone = true;
|
microtaskDone = true;
|
||||||
res();
|
res();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const p2 = new Promise<void>((res): void => {
|
const p2 = new Promise<void>((res) => {
|
||||||
resolve2 = (): void => {
|
resolve2 = () => {
|
||||||
assert(microtaskDone);
|
assert(microtaskDone);
|
||||||
res();
|
res();
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,14 +5,14 @@ const {
|
||||||
// @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol
|
// @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol
|
||||||
} = Deno[Deno.internal];
|
} = Deno[Deno.internal];
|
||||||
|
|
||||||
unitTest(function headersHasCorrectNameProp(): void {
|
unitTest(function headersHasCorrectNameProp() {
|
||||||
assertEquals(Headers.name, "Headers");
|
assertEquals(Headers.name, "Headers");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Logic heavily copied from web-platform-tests, make
|
// Logic heavily copied from web-platform-tests, make
|
||||||
// sure pass mostly header basic test
|
// sure pass mostly header basic test
|
||||||
// ref: https://github.com/web-platform-tests/wpt/blob/7c50c216081d6ea3c9afe553ee7b64534020a1b2/fetch/api/headers/headers-basic.html
|
// ref: https://github.com/web-platform-tests/wpt/blob/7c50c216081d6ea3c9afe553ee7b64534020a1b2/fetch/api/headers/headers-basic.html
|
||||||
unitTest(function newHeaderTest(): void {
|
unitTest(function newHeaderTest() {
|
||||||
new Headers();
|
new Headers();
|
||||||
new Headers(undefined);
|
new Headers(undefined);
|
||||||
new Headers({});
|
new Headers({});
|
||||||
|
@ -38,7 +38,7 @@ for (const name in headerDict) {
|
||||||
headerSeq.push([name, headerDict[name]]);
|
headerSeq.push([name, headerDict[name]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
unitTest(function newHeaderWithSequence(): void {
|
unitTest(function newHeaderWithSequence() {
|
||||||
const headers = new Headers(headerSeq);
|
const headers = new Headers(headerSeq);
|
||||||
for (const name in headerDict) {
|
for (const name in headerDict) {
|
||||||
assertEquals(headers.get(name), String(headerDict[name]));
|
assertEquals(headers.get(name), String(headerDict[name]));
|
||||||
|
@ -46,14 +46,14 @@ unitTest(function newHeaderWithSequence(): void {
|
||||||
assertEquals(headers.get("length"), null);
|
assertEquals(headers.get("length"), null);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function newHeaderWithRecord(): void {
|
unitTest(function newHeaderWithRecord() {
|
||||||
const headers = new Headers(headerDict);
|
const headers = new Headers(headerDict);
|
||||||
for (const name in headerDict) {
|
for (const name in headerDict) {
|
||||||
assertEquals(headers.get(name), String(headerDict[name]));
|
assertEquals(headers.get(name), String(headerDict[name]));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function newHeaderWithHeadersInstance(): void {
|
unitTest(function newHeaderWithHeadersInstance() {
|
||||||
const headers = new Headers(headerDict);
|
const headers = new Headers(headerDict);
|
||||||
const headers2 = new Headers(headers);
|
const headers2 = new Headers(headers);
|
||||||
for (const name in headerDict) {
|
for (const name in headerDict) {
|
||||||
|
@ -61,7 +61,7 @@ unitTest(function newHeaderWithHeadersInstance(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headerAppendSuccess(): void {
|
unitTest(function headerAppendSuccess() {
|
||||||
const headers = new Headers();
|
const headers = new Headers();
|
||||||
for (const name in headerDict) {
|
for (const name in headerDict) {
|
||||||
headers.append(name, headerDict[name]);
|
headers.append(name, headerDict[name]);
|
||||||
|
@ -69,7 +69,7 @@ unitTest(function headerAppendSuccess(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headerSetSuccess(): void {
|
unitTest(function headerSetSuccess() {
|
||||||
const headers = new Headers();
|
const headers = new Headers();
|
||||||
for (const name in headerDict) {
|
for (const name in headerDict) {
|
||||||
headers.set(name, headerDict[name]);
|
headers.set(name, headerDict[name]);
|
||||||
|
@ -77,7 +77,7 @@ unitTest(function headerSetSuccess(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headerHasSuccess(): void {
|
unitTest(function headerHasSuccess() {
|
||||||
const headers = new Headers(headerDict);
|
const headers = new Headers(headerDict);
|
||||||
for (const name in headerDict) {
|
for (const name in headerDict) {
|
||||||
assert(headers.has(name), "headers has name " + name);
|
assert(headers.has(name), "headers has name " + name);
|
||||||
|
@ -88,7 +88,7 @@ unitTest(function headerHasSuccess(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headerDeleteSuccess(): void {
|
unitTest(function headerDeleteSuccess() {
|
||||||
const headers = new Headers(headerDict);
|
const headers = new Headers(headerDict);
|
||||||
for (const name in headerDict) {
|
for (const name in headerDict) {
|
||||||
assert(headers.has(name), "headers have a header: " + name);
|
assert(headers.has(name), "headers have a header: " + name);
|
||||||
|
@ -97,7 +97,7 @@ unitTest(function headerDeleteSuccess(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headerGetSuccess(): void {
|
unitTest(function headerGetSuccess() {
|
||||||
const headers = new Headers(headerDict);
|
const headers = new Headers(headerDict);
|
||||||
for (const name in headerDict) {
|
for (const name in headerDict) {
|
||||||
assertEquals(headers.get(name), String(headerDict[name]));
|
assertEquals(headers.get(name), String(headerDict[name]));
|
||||||
|
@ -105,7 +105,7 @@ unitTest(function headerGetSuccess(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headerEntriesSuccess(): void {
|
unitTest(function headerEntriesSuccess() {
|
||||||
const headers = new Headers(headerDict);
|
const headers = new Headers(headerDict);
|
||||||
const iterators = headers.entries();
|
const iterators = headers.entries();
|
||||||
for (const it of iterators) {
|
for (const it of iterators) {
|
||||||
|
@ -116,7 +116,7 @@ unitTest(function headerEntriesSuccess(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headerKeysSuccess(): void {
|
unitTest(function headerKeysSuccess() {
|
||||||
const headers = new Headers(headerDict);
|
const headers = new Headers(headerDict);
|
||||||
const iterators = headers.keys();
|
const iterators = headers.keys();
|
||||||
for (const it of iterators) {
|
for (const it of iterators) {
|
||||||
|
@ -124,7 +124,7 @@ unitTest(function headerKeysSuccess(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headerValuesSuccess(): void {
|
unitTest(function headerValuesSuccess() {
|
||||||
const headers = new Headers(headerDict);
|
const headers = new Headers(headerDict);
|
||||||
const iterators = headers.values();
|
const iterators = headers.values();
|
||||||
const entries = headers.entries();
|
const entries = headers.entries();
|
||||||
|
@ -146,16 +146,16 @@ const headerEntriesDict: Record<string, string> = {
|
||||||
"Content-Types": "value6",
|
"Content-Types": "value6",
|
||||||
};
|
};
|
||||||
|
|
||||||
unitTest(function headerForEachSuccess(): void {
|
unitTest(function headerForEachSuccess() {
|
||||||
const headers = new Headers(headerEntriesDict);
|
const headers = new Headers(headerEntriesDict);
|
||||||
const keys = Object.keys(headerEntriesDict);
|
const keys = Object.keys(headerEntriesDict);
|
||||||
keys.forEach((key): void => {
|
keys.forEach((key) => {
|
||||||
const value = headerEntriesDict[key];
|
const value = headerEntriesDict[key];
|
||||||
const newkey = key.toLowerCase();
|
const newkey = key.toLowerCase();
|
||||||
headerEntriesDict[newkey] = value;
|
headerEntriesDict[newkey] = value;
|
||||||
});
|
});
|
||||||
let callNum = 0;
|
let callNum = 0;
|
||||||
headers.forEach((value, key, container): void => {
|
headers.forEach((value, key, container) => {
|
||||||
assertEquals(headers, container);
|
assertEquals(headers, container);
|
||||||
assertEquals(value, headerEntriesDict[key]);
|
assertEquals(value, headerEntriesDict[key]);
|
||||||
callNum++;
|
callNum++;
|
||||||
|
@ -163,7 +163,7 @@ unitTest(function headerForEachSuccess(): void {
|
||||||
assertEquals(callNum, keys.length);
|
assertEquals(callNum, keys.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headerSymbolIteratorSuccess(): void {
|
unitTest(function headerSymbolIteratorSuccess() {
|
||||||
assert(Symbol.iterator in Headers.prototype);
|
assert(Symbol.iterator in Headers.prototype);
|
||||||
const headers = new Headers(headerEntriesDict);
|
const headers = new Headers(headerEntriesDict);
|
||||||
for (const header of headers) {
|
for (const header of headers) {
|
||||||
|
@ -174,7 +174,7 @@ unitTest(function headerSymbolIteratorSuccess(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headerTypesAvailable(): void {
|
unitTest(function headerTypesAvailable() {
|
||||||
function newHeaders(): Headers {
|
function newHeaders(): Headers {
|
||||||
return new Headers();
|
return new Headers();
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ unitTest(function headerTypesAvailable(): void {
|
||||||
|
|
||||||
// Modified from https://github.com/bitinn/node-fetch/blob/7d3293200a91ad52b5ca7962f9d6fd1c04983edb/test/test.js#L2001-L2014
|
// Modified from https://github.com/bitinn/node-fetch/blob/7d3293200a91ad52b5ca7962f9d6fd1c04983edb/test/test.js#L2001-L2014
|
||||||
// Copyright (c) 2016 David Frank. MIT License.
|
// Copyright (c) 2016 David Frank. MIT License.
|
||||||
unitTest(function headerIllegalReject(): void {
|
unitTest(function headerIllegalReject() {
|
||||||
let errorCount = 0;
|
let errorCount = 0;
|
||||||
try {
|
try {
|
||||||
new Headers({ "He y": "ok" });
|
new Headers({ "He y": "ok" });
|
||||||
|
@ -238,7 +238,7 @@ unitTest(function headerIllegalReject(): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
// If pair does not contain exactly two items,then throw a TypeError.
|
// If pair does not contain exactly two items,then throw a TypeError.
|
||||||
unitTest(function headerParamsShouldThrowTypeError(): void {
|
unitTest(function headerParamsShouldThrowTypeError() {
|
||||||
let hasThrown = 0;
|
let hasThrown = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -255,12 +255,12 @@ unitTest(function headerParamsShouldThrowTypeError(): void {
|
||||||
assertEquals(hasThrown, 2);
|
assertEquals(hasThrown, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headerParamsArgumentsCheck(): void {
|
unitTest(function headerParamsArgumentsCheck() {
|
||||||
const methodRequireOneParam = ["delete", "get", "has", "forEach"] as const;
|
const methodRequireOneParam = ["delete", "get", "has", "forEach"] as const;
|
||||||
|
|
||||||
const methodRequireTwoParams = ["append", "set"] as const;
|
const methodRequireTwoParams = ["append", "set"] as const;
|
||||||
|
|
||||||
methodRequireOneParam.forEach((method): void => {
|
methodRequireOneParam.forEach((method) => {
|
||||||
const headers = new Headers();
|
const headers = new Headers();
|
||||||
let hasThrown = 0;
|
let hasThrown = 0;
|
||||||
try {
|
try {
|
||||||
|
@ -277,7 +277,7 @@ unitTest(function headerParamsArgumentsCheck(): void {
|
||||||
assertEquals(hasThrown, 2);
|
assertEquals(hasThrown, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
methodRequireTwoParams.forEach((method): void => {
|
methodRequireTwoParams.forEach((method) => {
|
||||||
const headers = new Headers();
|
const headers = new Headers();
|
||||||
let hasThrown = 0;
|
let hasThrown = 0;
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ unitTest(function headerParamsArgumentsCheck(): void {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headersInitMultiple(): void {
|
unitTest(function headersInitMultiple() {
|
||||||
const headers = new Headers([
|
const headers = new Headers([
|
||||||
["Set-Cookie", "foo=bar"],
|
["Set-Cookie", "foo=bar"],
|
||||||
["Set-Cookie", "bar=baz"],
|
["Set-Cookie", "bar=baz"],
|
||||||
|
@ -325,7 +325,7 @@ unitTest(function headersInitMultiple(): void {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headersAppendMultiple(): void {
|
unitTest(function headersAppendMultiple() {
|
||||||
const headers = new Headers([
|
const headers = new Headers([
|
||||||
["Set-Cookie", "foo=bar"],
|
["Set-Cookie", "foo=bar"],
|
||||||
["X-Deno", "foo"],
|
["X-Deno", "foo"],
|
||||||
|
@ -340,7 +340,7 @@ unitTest(function headersAppendMultiple(): void {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headersAppendDuplicateSetCookieKey(): void {
|
unitTest(function headersAppendDuplicateSetCookieKey() {
|
||||||
const headers = new Headers([["Set-Cookie", "foo=bar"]]);
|
const headers = new Headers([["Set-Cookie", "foo=bar"]]);
|
||||||
headers.append("set-Cookie", "foo=baz");
|
headers.append("set-Cookie", "foo=baz");
|
||||||
headers.append("Set-cookie", "baz=bar");
|
headers.append("Set-cookie", "baz=bar");
|
||||||
|
@ -352,7 +352,7 @@ unitTest(function headersAppendDuplicateSetCookieKey(): void {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function headersGetSetCookie(): void {
|
unitTest(function headersGetSetCookie() {
|
||||||
const headers = new Headers([
|
const headers = new Headers([
|
||||||
["Set-Cookie", "foo=bar"],
|
["Set-Cookie", "foo=bar"],
|
||||||
["set-Cookie", "bar=qat"],
|
["set-Cookie", "bar=qat"],
|
||||||
|
@ -360,7 +360,7 @@ unitTest(function headersGetSetCookie(): void {
|
||||||
assertEquals(headers.get("SET-COOKIE"), "foo=bar, bar=qat");
|
assertEquals(headers.get("SET-COOKIE"), "foo=bar, bar=qat");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function toStringShouldBeWebCompatibility(): void {
|
unitTest(function toStringShouldBeWebCompatibility() {
|
||||||
const headers = new Headers();
|
const headers = new Headers();
|
||||||
assertEquals(headers.toString(), "[object Headers]");
|
assertEquals(headers.toString(), "[object Headers]");
|
||||||
});
|
});
|
||||||
|
@ -369,7 +369,7 @@ function stringify(...args: unknown[]): string {
|
||||||
return inspectArgs(args).replace(/\n$/, "");
|
return inspectArgs(args).replace(/\n$/, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
unitTest(function customInspectReturnsCorrectHeadersFormat(): void {
|
unitTest(function customInspectReturnsCorrectHeadersFormat() {
|
||||||
const blankHeaders = new Headers();
|
const blankHeaders = new Headers();
|
||||||
assertEquals(stringify(blankHeaders), "Headers {}");
|
assertEquals(stringify(blankHeaders), "Headers {}");
|
||||||
const singleHeader = new Headers([["Content-Type", "application/json"]]);
|
const singleHeader = new Headers([["Content-Type", "application/json"]]);
|
||||||
|
|
|
@ -200,7 +200,7 @@ unitTest({ perms: { net: true } }, async function httpServerInvalidMethod() {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function httpServerWithTls(): Promise<void> {
|
async function httpServerWithTls() {
|
||||||
const hostname = "localhost";
|
const hostname = "localhost";
|
||||||
const port = 4501;
|
const port = 4501;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assert, unitTest } from "./test_util.ts";
|
import { assert, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function internalsExists(): void {
|
unitTest(function internalsExists() {
|
||||||
const {
|
const {
|
||||||
inspectArgs,
|
inspectArgs,
|
||||||
// @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol
|
// @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { assert, assertEquals, assertThrows, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function linkSyncSuccess(): void {
|
function linkSyncSuccess() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldData = "Hardlink";
|
const oldData = "Hardlink";
|
||||||
const oldName = testDir + "/oldname";
|
const oldName = testDir + "/oldname";
|
||||||
|
@ -42,7 +42,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function linkSyncExists(): void {
|
function linkSyncExists() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldName = testDir + "/oldname";
|
const oldName = testDir + "/oldname";
|
||||||
const newName = testDir + "/newname";
|
const newName = testDir + "/newname";
|
||||||
|
@ -58,7 +58,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function linkSyncNotFound(): void {
|
function linkSyncNotFound() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldName = testDir + "/oldname";
|
const oldName = testDir + "/oldname";
|
||||||
const newName = testDir + "/newname";
|
const newName = testDir + "/newname";
|
||||||
|
@ -71,7 +71,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: false, write: true } },
|
{ perms: { read: false, write: true } },
|
||||||
function linkSyncReadPerm(): void {
|
function linkSyncReadPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.linkSync("oldbaddir", "newbaddir");
|
Deno.linkSync("oldbaddir", "newbaddir");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -80,7 +80,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: false } },
|
{ perms: { read: true, write: false } },
|
||||||
function linkSyncWritePerm(): void {
|
function linkSyncWritePerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.linkSync("oldbaddir", "newbaddir");
|
Deno.linkSync("oldbaddir", "newbaddir");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -89,7 +89,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function linkSuccess(): Promise<void> {
|
async function linkSuccess() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldData = "Hardlink";
|
const oldData = "Hardlink";
|
||||||
const oldName = testDir + "/oldname";
|
const oldName = testDir + "/oldname";
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest({ perms: { write: true } }, function makeTempDirSyncSuccess(): void {
|
unitTest({ perms: { write: true } }, function makeTempDirSyncSuccess() {
|
||||||
const dir1 = Deno.makeTempDirSync({ prefix: "hello", suffix: "world" });
|
const dir1 = Deno.makeTempDirSync({ prefix: "hello", suffix: "world" });
|
||||||
const dir2 = Deno.makeTempDirSync({ prefix: "hello", suffix: "world" });
|
const dir2 = Deno.makeTempDirSync({ prefix: "hello", suffix: "world" });
|
||||||
// Check that both dirs are different.
|
// Check that both dirs are different.
|
||||||
|
@ -30,7 +30,7 @@ unitTest({ perms: { write: true } }, function makeTempDirSyncSuccess(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function makeTempDirSyncMode(): void {
|
function makeTempDirSyncMode() {
|
||||||
const path = Deno.makeTempDirSync();
|
const path = Deno.makeTempDirSync();
|
||||||
const pathInfo = Deno.statSync(path);
|
const pathInfo = Deno.statSync(path);
|
||||||
if (Deno.build.os !== "windows") {
|
if (Deno.build.os !== "windows") {
|
||||||
|
@ -39,7 +39,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(function makeTempDirSyncPerm(): void {
|
unitTest(function makeTempDirSyncPerm() {
|
||||||
// makeTempDirSync should require write permissions (for now).
|
// makeTempDirSync should require write permissions (for now).
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.makeTempDirSync({ dir: "/baddir" });
|
Deno.makeTempDirSync({ dir: "/baddir" });
|
||||||
|
@ -48,7 +48,7 @@ unitTest(function makeTempDirSyncPerm(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true } },
|
{ perms: { write: true } },
|
||||||
async function makeTempDirSuccess(): Promise<void> {
|
async function makeTempDirSuccess() {
|
||||||
const dir1 = await Deno.makeTempDir({ prefix: "hello", suffix: "world" });
|
const dir1 = await Deno.makeTempDir({ prefix: "hello", suffix: "world" });
|
||||||
const dir2 = await Deno.makeTempDir({ prefix: "hello", suffix: "world" });
|
const dir2 = await Deno.makeTempDir({ prefix: "hello", suffix: "world" });
|
||||||
// Check that both dirs are different.
|
// Check that both dirs are different.
|
||||||
|
@ -72,7 +72,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function makeTempDirMode(): Promise<void> {
|
async function makeTempDirMode() {
|
||||||
const path = await Deno.makeTempDir();
|
const path = await Deno.makeTempDir();
|
||||||
const pathInfo = Deno.statSync(path);
|
const pathInfo = Deno.statSync(path);
|
||||||
if (Deno.build.os !== "windows") {
|
if (Deno.build.os !== "windows") {
|
||||||
|
@ -81,7 +81,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { write: true } }, function makeTempFileSyncSuccess(): void {
|
unitTest({ perms: { write: true } }, function makeTempFileSyncSuccess() {
|
||||||
const file1 = Deno.makeTempFileSync({ prefix: "hello", suffix: "world" });
|
const file1 = Deno.makeTempFileSync({ prefix: "hello", suffix: "world" });
|
||||||
const file2 = Deno.makeTempFileSync({ prefix: "hello", suffix: "world" });
|
const file2 = Deno.makeTempFileSync({ prefix: "hello", suffix: "world" });
|
||||||
// Check that both dirs are different.
|
// Check that both dirs are different.
|
||||||
|
@ -105,7 +105,7 @@ unitTest({ perms: { write: true } }, function makeTempFileSyncSuccess(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function makeTempFileSyncMode(): void {
|
function makeTempFileSyncMode() {
|
||||||
const path = Deno.makeTempFileSync();
|
const path = Deno.makeTempFileSync();
|
||||||
const pathInfo = Deno.statSync(path);
|
const pathInfo = Deno.statSync(path);
|
||||||
if (Deno.build.os !== "windows") {
|
if (Deno.build.os !== "windows") {
|
||||||
|
@ -114,7 +114,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(function makeTempFileSyncPerm(): void {
|
unitTest(function makeTempFileSyncPerm() {
|
||||||
// makeTempFileSync should require write permissions (for now).
|
// makeTempFileSync should require write permissions (for now).
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.makeTempFileSync({ dir: "/baddir" });
|
Deno.makeTempFileSync({ dir: "/baddir" });
|
||||||
|
@ -123,7 +123,7 @@ unitTest(function makeTempFileSyncPerm(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true } },
|
{ perms: { write: true } },
|
||||||
async function makeTempFileSuccess(): Promise<void> {
|
async function makeTempFileSuccess() {
|
||||||
const file1 = await Deno.makeTempFile({ prefix: "hello", suffix: "world" });
|
const file1 = await Deno.makeTempFile({ prefix: "hello", suffix: "world" });
|
||||||
const file2 = await Deno.makeTempFile({ prefix: "hello", suffix: "world" });
|
const file2 = await Deno.makeTempFile({ prefix: "hello", suffix: "world" });
|
||||||
// Check that both dirs are different.
|
// Check that both dirs are different.
|
||||||
|
@ -148,7 +148,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function makeTempFileMode(): Promise<void> {
|
async function makeTempFileMode() {
|
||||||
const path = await Deno.makeTempFile();
|
const path = await Deno.makeTempFile();
|
||||||
const pathInfo = Deno.statSync(path);
|
const pathInfo = Deno.statSync(path);
|
||||||
if (Deno.build.os !== "windows") {
|
if (Deno.build.os !== "windows") {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assert, unitTest } from "./test_util.ts";
|
import { assert, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(async function metrics(): Promise<void> {
|
unitTest(async function metrics() {
|
||||||
// Write to stdout to ensure a "data" message gets sent instead of just
|
// Write to stdout to ensure a "data" message gets sent instead of just
|
||||||
// control messages.
|
// control messages.
|
||||||
const dataMsg = new Uint8Array([13, 13, 13]); // "\r\r\r",
|
const dataMsg = new Uint8Array([13, 13, 13]); // "\r\r\r",
|
||||||
|
@ -41,7 +41,7 @@ unitTest(async function metrics(): Promise<void> {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true } },
|
{ perms: { write: true } },
|
||||||
function metricsUpdatedIfNoResponseSync(): void {
|
function metricsUpdatedIfNoResponseSync() {
|
||||||
const filename = Deno.makeTempDirSync() + "/test.txt";
|
const filename = Deno.makeTempDirSync() + "/test.txt";
|
||||||
|
|
||||||
const data = new Uint8Array([41, 42, 43]);
|
const data = new Uint8Array([41, 42, 43]);
|
||||||
|
@ -55,7 +55,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true } },
|
{ perms: { write: true } },
|
||||||
async function metricsUpdatedIfNoResponseAsync(): Promise<void> {
|
async function metricsUpdatedIfNoResponseAsync() {
|
||||||
const filename = Deno.makeTempDirSync() + "/test.txt";
|
const filename = Deno.makeTempDirSync() + "/test.txt";
|
||||||
|
|
||||||
const data = new Uint8Array([41, 42, 43]);
|
const data = new Uint8Array([41, 42, 43]);
|
||||||
|
@ -69,7 +69,7 @@ unitTest(
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test that ops from extensions have metrics (via OpMiddleware)
|
// Test that ops from extensions have metrics (via OpMiddleware)
|
||||||
unitTest(function metricsForOpCrates(): void {
|
unitTest(function metricsForOpCrates() {
|
||||||
const _ = new URL("https://deno.land");
|
const _ = new URL("https://deno.land");
|
||||||
|
|
||||||
const m1 = Deno.metrics().ops["op_url_parse"];
|
const m1 = Deno.metrics().ops["op_url_parse"];
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
function assertDirectory(path: string, mode?: number): void {
|
function assertDirectory(path: string, mode?: number) {
|
||||||
const info = Deno.lstatSync(path);
|
const info = Deno.lstatSync(path);
|
||||||
assert(info.isDirectory);
|
assert(info.isDirectory);
|
||||||
if (Deno.build.os !== "windows" && mode !== undefined) {
|
if (Deno.build.os !== "windows" && mode !== undefined) {
|
||||||
|
@ -18,7 +18,7 @@ function assertDirectory(path: string, mode?: number): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function mkdirSyncSuccess(): void {
|
function mkdirSyncSuccess() {
|
||||||
const path = Deno.makeTempDirSync() + "/dir";
|
const path = Deno.makeTempDirSync() + "/dir";
|
||||||
Deno.mkdirSync(path);
|
Deno.mkdirSync(path);
|
||||||
assertDirectory(path);
|
assertDirectory(path);
|
||||||
|
@ -27,14 +27,14 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function mkdirSyncMode(): void {
|
function mkdirSyncMode() {
|
||||||
const path = Deno.makeTempDirSync() + "/dir";
|
const path = Deno.makeTempDirSync() + "/dir";
|
||||||
Deno.mkdirSync(path, { mode: 0o737 });
|
Deno.mkdirSync(path, { mode: 0o737 });
|
||||||
assertDirectory(path, 0o737);
|
assertDirectory(path, 0o737);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { write: false } }, function mkdirSyncPerm(): void {
|
unitTest({ perms: { write: false } }, function mkdirSyncPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.mkdirSync("/baddir");
|
Deno.mkdirSync("/baddir");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -42,7 +42,7 @@ unitTest({ perms: { write: false } }, function mkdirSyncPerm(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function mkdirSuccess(): Promise<void> {
|
async function mkdirSuccess() {
|
||||||
const path = Deno.makeTempDirSync() + "/dir";
|
const path = Deno.makeTempDirSync() + "/dir";
|
||||||
await Deno.mkdir(path);
|
await Deno.mkdir(path);
|
||||||
assertDirectory(path);
|
assertDirectory(path);
|
||||||
|
@ -51,22 +51,20 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function mkdirMode(): Promise<void> {
|
async function mkdirMode() {
|
||||||
const path = Deno.makeTempDirSync() + "/dir";
|
const path = Deno.makeTempDirSync() + "/dir";
|
||||||
await Deno.mkdir(path, { mode: 0o737 });
|
await Deno.mkdir(path, { mode: 0o737 });
|
||||||
assertDirectory(path, 0o737);
|
assertDirectory(path, 0o737);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { write: true } }, function mkdirErrSyncIfExists(): void {
|
unitTest({ perms: { write: true } }, function mkdirErrSyncIfExists() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.mkdirSync(".");
|
Deno.mkdirSync(".");
|
||||||
}, Deno.errors.AlreadyExists);
|
}, Deno.errors.AlreadyExists);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { write: true } }, async function mkdirErrIfExists(): Promise<
|
unitTest({ perms: { write: true } }, async function mkdirErrIfExists() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.mkdir(".");
|
await Deno.mkdir(".");
|
||||||
}, Deno.errors.AlreadyExists);
|
}, Deno.errors.AlreadyExists);
|
||||||
|
@ -74,7 +72,7 @@ unitTest({ perms: { write: true } }, async function mkdirErrIfExists(): Promise<
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function mkdirSyncRecursive(): void {
|
function mkdirSyncRecursive() {
|
||||||
const path = Deno.makeTempDirSync() + "/nested/directory";
|
const path = Deno.makeTempDirSync() + "/nested/directory";
|
||||||
Deno.mkdirSync(path, { recursive: true });
|
Deno.mkdirSync(path, { recursive: true });
|
||||||
assertDirectory(path);
|
assertDirectory(path);
|
||||||
|
@ -83,7 +81,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function mkdirRecursive(): Promise<void> {
|
async function mkdirRecursive() {
|
||||||
const path = Deno.makeTempDirSync() + "/nested/directory";
|
const path = Deno.makeTempDirSync() + "/nested/directory";
|
||||||
await Deno.mkdir(path, { recursive: true });
|
await Deno.mkdir(path, { recursive: true });
|
||||||
assertDirectory(path);
|
assertDirectory(path);
|
||||||
|
@ -92,7 +90,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function mkdirSyncRecursiveMode(): void {
|
function mkdirSyncRecursiveMode() {
|
||||||
const nested = Deno.makeTempDirSync() + "/nested";
|
const nested = Deno.makeTempDirSync() + "/nested";
|
||||||
const path = nested + "/dir";
|
const path = nested + "/dir";
|
||||||
Deno.mkdirSync(path, { mode: 0o737, recursive: true });
|
Deno.mkdirSync(path, { mode: 0o737, recursive: true });
|
||||||
|
@ -103,7 +101,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function mkdirRecursiveMode(): Promise<void> {
|
async function mkdirRecursiveMode() {
|
||||||
const nested = Deno.makeTempDirSync() + "/nested";
|
const nested = Deno.makeTempDirSync() + "/nested";
|
||||||
const path = nested + "/dir";
|
const path = nested + "/dir";
|
||||||
await Deno.mkdir(path, { mode: 0o737, recursive: true });
|
await Deno.mkdir(path, { mode: 0o737, recursive: true });
|
||||||
|
@ -114,7 +112,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function mkdirSyncRecursiveIfExists(): void {
|
function mkdirSyncRecursiveIfExists() {
|
||||||
const path = Deno.makeTempDirSync() + "/dir";
|
const path = Deno.makeTempDirSync() + "/dir";
|
||||||
Deno.mkdirSync(path, { mode: 0o737 });
|
Deno.mkdirSync(path, { mode: 0o737 });
|
||||||
Deno.mkdirSync(path, { recursive: true });
|
Deno.mkdirSync(path, { recursive: true });
|
||||||
|
@ -132,7 +130,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function mkdirRecursiveIfExists(): Promise<void> {
|
async function mkdirRecursiveIfExists() {
|
||||||
const path = Deno.makeTempDirSync() + "/dir";
|
const path = Deno.makeTempDirSync() + "/dir";
|
||||||
await Deno.mkdir(path, { mode: 0o737 });
|
await Deno.mkdir(path, { mode: 0o737 });
|
||||||
await Deno.mkdir(path, { recursive: true });
|
await Deno.mkdir(path, { recursive: true });
|
||||||
|
@ -150,7 +148,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function mkdirSyncErrors(): void {
|
function mkdirSyncErrors() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const emptydir = testDir + "/empty";
|
const emptydir = testDir + "/empty";
|
||||||
const fulldir = testDir + "/dir";
|
const fulldir = testDir + "/dir";
|
||||||
|
@ -159,16 +157,16 @@ unitTest(
|
||||||
Deno.mkdirSync(fulldir);
|
Deno.mkdirSync(fulldir);
|
||||||
Deno.createSync(file).close();
|
Deno.createSync(file).close();
|
||||||
|
|
||||||
assertThrows((): void => {
|
assertThrows(() => {
|
||||||
Deno.mkdirSync(emptydir, { recursive: false });
|
Deno.mkdirSync(emptydir, { recursive: false });
|
||||||
}, Deno.errors.AlreadyExists);
|
}, Deno.errors.AlreadyExists);
|
||||||
assertThrows((): void => {
|
assertThrows(() => {
|
||||||
Deno.mkdirSync(fulldir, { recursive: false });
|
Deno.mkdirSync(fulldir, { recursive: false });
|
||||||
}, Deno.errors.AlreadyExists);
|
}, Deno.errors.AlreadyExists);
|
||||||
assertThrows((): void => {
|
assertThrows(() => {
|
||||||
Deno.mkdirSync(file, { recursive: false });
|
Deno.mkdirSync(file, { recursive: false });
|
||||||
}, Deno.errors.AlreadyExists);
|
}, Deno.errors.AlreadyExists);
|
||||||
assertThrows((): void => {
|
assertThrows(() => {
|
||||||
Deno.mkdirSync(file, { recursive: true });
|
Deno.mkdirSync(file, { recursive: true });
|
||||||
}, Deno.errors.AlreadyExists);
|
}, Deno.errors.AlreadyExists);
|
||||||
|
|
||||||
|
@ -180,19 +178,19 @@ unitTest(
|
||||||
Deno.symlinkSync(emptydir, dirLink);
|
Deno.symlinkSync(emptydir, dirLink);
|
||||||
Deno.symlinkSync(testDir + "/nonexistent", danglingLink);
|
Deno.symlinkSync(testDir + "/nonexistent", danglingLink);
|
||||||
|
|
||||||
assertThrows((): void => {
|
assertThrows(() => {
|
||||||
Deno.mkdirSync(dirLink, { recursive: false });
|
Deno.mkdirSync(dirLink, { recursive: false });
|
||||||
}, Deno.errors.AlreadyExists);
|
}, Deno.errors.AlreadyExists);
|
||||||
assertThrows((): void => {
|
assertThrows(() => {
|
||||||
Deno.mkdirSync(fileLink, { recursive: false });
|
Deno.mkdirSync(fileLink, { recursive: false });
|
||||||
}, Deno.errors.AlreadyExists);
|
}, Deno.errors.AlreadyExists);
|
||||||
assertThrows((): void => {
|
assertThrows(() => {
|
||||||
Deno.mkdirSync(fileLink, { recursive: true });
|
Deno.mkdirSync(fileLink, { recursive: true });
|
||||||
}, Deno.errors.AlreadyExists);
|
}, Deno.errors.AlreadyExists);
|
||||||
assertThrows((): void => {
|
assertThrows(() => {
|
||||||
Deno.mkdirSync(danglingLink, { recursive: false });
|
Deno.mkdirSync(danglingLink, { recursive: false });
|
||||||
}, Deno.errors.AlreadyExists);
|
}, Deno.errors.AlreadyExists);
|
||||||
assertThrows((): void => {
|
assertThrows(() => {
|
||||||
Deno.mkdirSync(danglingLink, { recursive: true });
|
Deno.mkdirSync(danglingLink, { recursive: true });
|
||||||
}, Deno.errors.AlreadyExists);
|
}, Deno.errors.AlreadyExists);
|
||||||
}
|
}
|
||||||
|
@ -201,7 +199,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function mkdirSyncRelativeUrlPath(): void {
|
function mkdirSyncRelativeUrlPath() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const nestedDir = testDir + "/nested";
|
const nestedDir = testDir + "/nested";
|
||||||
// Add trailing slash so base path is treated as a directory. pathToAbsoluteFileUrl removes trailing slashes.
|
// Add trailing slash so base path is treated as a directory. pathToAbsoluteFileUrl removes trailing slashes.
|
||||||
|
@ -216,7 +214,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function mkdirRelativeUrlPath(): Promise<void> {
|
async function mkdirRelativeUrlPath() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const nestedDir = testDir + "/nested";
|
const nestedDir = testDir + "/nested";
|
||||||
// Add trailing slash so base path is treated as a directory. pathToAbsoluteFileUrl removes trailing slashes.
|
// Add trailing slash so base path is treated as a directory. pathToAbsoluteFileUrl removes trailing slashes.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assert, unitTest } from "./test_util.ts";
|
import { assert, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function navigatorNumCpus(): void {
|
unitTest(function navigatorNumCpus() {
|
||||||
assert(navigator.hardwareConcurrency > 0);
|
assert(navigator.hardwareConcurrency > 0);
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, function netTcpListenClose(): void {
|
unitTest({ perms: { net: true } }, function netTcpListenClose() {
|
||||||
const listener = Deno.listen({ hostname: "127.0.0.1", port: 3500 });
|
const listener = Deno.listen({ hostname: "127.0.0.1", port: 3500 });
|
||||||
assert(listener.addr.transport === "tcp");
|
assert(listener.addr.transport === "tcp");
|
||||||
assertEquals(listener.addr.hostname, "127.0.0.1");
|
assertEquals(listener.addr.hostname, "127.0.0.1");
|
||||||
|
@ -23,7 +23,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
function netUdpListenClose(): void {
|
function netUdpListenClose() {
|
||||||
const socket = Deno.listenDatagram({
|
const socket = Deno.listenDatagram({
|
||||||
hostname: "127.0.0.1",
|
hostname: "127.0.0.1",
|
||||||
port: 3500,
|
port: 3500,
|
||||||
|
@ -38,7 +38,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
function netUnixListenClose(): void {
|
function netUnixListenClose() {
|
||||||
const filePath = Deno.makeTempFileSync();
|
const filePath = Deno.makeTempFileSync();
|
||||||
const socket = Deno.listen({
|
const socket = Deno.listen({
|
||||||
path: filePath,
|
path: filePath,
|
||||||
|
@ -52,7 +52,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
function netUnixPacketListenClose(): void {
|
function netUnixPacketListenClose() {
|
||||||
const filePath = Deno.makeTempFileSync();
|
const filePath = Deno.makeTempFileSync();
|
||||||
const socket = Deno.listenDatagram({
|
const socket = Deno.listenDatagram({
|
||||||
path: filePath,
|
path: filePath,
|
||||||
|
@ -66,7 +66,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true } },
|
||||||
function netUnixListenWritePermission(): void {
|
function netUnixListenWritePermission() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
const filePath = Deno.makeTempFileSync();
|
const filePath = Deno.makeTempFileSync();
|
||||||
const socket = Deno.listen({
|
const socket = Deno.listen({
|
||||||
|
@ -82,7 +82,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true } },
|
||||||
function netUnixPacketListenWritePermission(): void {
|
function netUnixPacketListenWritePermission() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
const filePath = Deno.makeTempFileSync();
|
const filePath = Deno.makeTempFileSync();
|
||||||
const socket = Deno.listenDatagram({
|
const socket = Deno.listenDatagram({
|
||||||
|
@ -100,12 +100,12 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function netTcpCloseWhileAccept(): Promise<void> {
|
async function netTcpCloseWhileAccept() {
|
||||||
const listener = Deno.listen({ port: 4501 });
|
const listener = Deno.listen({ port: 4501 });
|
||||||
const p = listener.accept();
|
const p = listener.accept();
|
||||||
listener.close();
|
listener.close();
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await p;
|
await p;
|
||||||
},
|
},
|
||||||
Deno.errors.BadResource,
|
Deno.errors.BadResource,
|
||||||
|
@ -116,7 +116,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
async function netUnixCloseWhileAccept(): Promise<void> {
|
async function netUnixCloseWhileAccept() {
|
||||||
const filePath = await Deno.makeTempFile();
|
const filePath = await Deno.makeTempFile();
|
||||||
const listener = Deno.listen({
|
const listener = Deno.listen({
|
||||||
path: filePath,
|
path: filePath,
|
||||||
|
@ -125,7 +125,7 @@ unitTest(
|
||||||
const p = listener.accept();
|
const p = listener.accept();
|
||||||
listener.close();
|
listener.close();
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await p;
|
await p;
|
||||||
},
|
},
|
||||||
Deno.errors.BadResource,
|
Deno.errors.BadResource,
|
||||||
|
@ -136,10 +136,10 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function netTcpConcurrentAccept(): Promise<void> {
|
async function netTcpConcurrentAccept() {
|
||||||
const listener = Deno.listen({ port: 4502 });
|
const listener = Deno.listen({ port: 4502 });
|
||||||
let acceptErrCount = 0;
|
let acceptErrCount = 0;
|
||||||
const checkErr = (e: Error): void => {
|
const checkErr = (e: Error) => {
|
||||||
if (e.message === "Listener has been closed") {
|
if (e.message === "Listener has been closed") {
|
||||||
assertEquals(acceptErrCount, 1);
|
assertEquals(acceptErrCount, 1);
|
||||||
} else if (e.message === "Another accept task is ongoing") {
|
} else if (e.message === "Another accept task is ongoing") {
|
||||||
|
@ -160,11 +160,11 @@ unitTest(
|
||||||
// TODO(jsouto): Enable when tokio updates mio to v0.7!
|
// TODO(jsouto): Enable when tokio updates mio to v0.7!
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: true, perms: { read: true, write: true } },
|
{ ignore: true, perms: { read: true, write: true } },
|
||||||
async function netUnixConcurrentAccept(): Promise<void> {
|
async function netUnixConcurrentAccept() {
|
||||||
const filePath = await Deno.makeTempFile();
|
const filePath = await Deno.makeTempFile();
|
||||||
const listener = Deno.listen({ transport: "unix", path: filePath });
|
const listener = Deno.listen({ transport: "unix", path: filePath });
|
||||||
let acceptErrCount = 0;
|
let acceptErrCount = 0;
|
||||||
const checkErr = (e: Error): void => {
|
const checkErr = (e: Error) => {
|
||||||
if (e.message === "Listener has been closed") {
|
if (e.message === "Listener has been closed") {
|
||||||
assertEquals(acceptErrCount, 1);
|
assertEquals(acceptErrCount, 1);
|
||||||
} else if (e.message === "Another accept task is ongoing") {
|
} else if (e.message === "Another accept task is ongoing") {
|
||||||
|
@ -182,12 +182,10 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function netTcpDialListen(): Promise<
|
unitTest({ perms: { net: true } }, async function netTcpDialListen() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const listener = Deno.listen({ port: 3500 });
|
const listener = Deno.listen({ port: 3500 });
|
||||||
listener.accept().then(
|
listener.accept().then(
|
||||||
async (conn): Promise<void> => {
|
async (conn) => {
|
||||||
assert(conn.remoteAddr != null);
|
assert(conn.remoteAddr != null);
|
||||||
assert(conn.localAddr.transport === "tcp");
|
assert(conn.localAddr.transport === "tcp");
|
||||||
assertEquals(conn.localAddr.hostname, "127.0.0.1");
|
assertEquals(conn.localAddr.hostname, "127.0.0.1");
|
||||||
|
@ -221,11 +219,11 @@ unitTest({ perms: { net: true } }, async function netTcpDialListen(): Promise<
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
async function netUnixDialListen(): Promise<void> {
|
async function netUnixDialListen() {
|
||||||
const filePath = await Deno.makeTempFile();
|
const filePath = await Deno.makeTempFile();
|
||||||
const listener = Deno.listen({ path: filePath, transport: "unix" });
|
const listener = Deno.listen({ path: filePath, transport: "unix" });
|
||||||
listener.accept().then(
|
listener.accept().then(
|
||||||
async (conn): Promise<void> => {
|
async (conn) => {
|
||||||
assert(conn.remoteAddr != null);
|
assert(conn.remoteAddr != null);
|
||||||
assert(conn.localAddr.transport === "unix");
|
assert(conn.localAddr.transport === "unix");
|
||||||
assertEquals(conn.localAddr.path, filePath);
|
assertEquals(conn.localAddr.path, filePath);
|
||||||
|
@ -257,7 +255,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function netUdpSendReceive(): Promise<void> {
|
async function netUdpSendReceive() {
|
||||||
const alice = Deno.listenDatagram({ port: 3500, transport: "udp" });
|
const alice = Deno.listenDatagram({ port: 3500, transport: "udp" });
|
||||||
assert(alice.addr.transport === "udp");
|
assert(alice.addr.transport === "udp");
|
||||||
assertEquals(alice.addr.port, 3500);
|
assertEquals(alice.addr.port, 3500);
|
||||||
|
@ -287,7 +285,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function netUdpConcurrentSendReceive(): Promise<void> {
|
async function netUdpConcurrentSendReceive() {
|
||||||
const socket = Deno.listenDatagram({ port: 3500, transport: "udp" });
|
const socket = Deno.listenDatagram({ port: 3500, transport: "udp" });
|
||||||
assert(socket.addr.transport === "udp");
|
assert(socket.addr.transport === "udp");
|
||||||
assertEquals(socket.addr.port, 3500);
|
assertEquals(socket.addr.port, 3500);
|
||||||
|
@ -311,7 +309,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function netUdpBorrowMutError(): Promise<void> {
|
async function netUdpBorrowMutError() {
|
||||||
const socket = Deno.listenDatagram({
|
const socket = Deno.listenDatagram({
|
||||||
port: 4501,
|
port: 4501,
|
||||||
transport: "udp",
|
transport: "udp",
|
||||||
|
@ -326,7 +324,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
async function netUnixPacketSendReceive(): Promise<void> {
|
async function netUnixPacketSendReceive() {
|
||||||
const filePath = await Deno.makeTempFile();
|
const filePath = await Deno.makeTempFile();
|
||||||
const alice = Deno.listenDatagram({
|
const alice = Deno.listenDatagram({
|
||||||
path: filePath,
|
path: filePath,
|
||||||
|
@ -361,7 +359,7 @@ unitTest(
|
||||||
// TODO(piscisaureus): Enable after Tokio v0.3/v1.0 upgrade.
|
// TODO(piscisaureus): Enable after Tokio v0.3/v1.0 upgrade.
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: true, perms: { read: true, write: true } },
|
{ ignore: true, perms: { read: true, write: true } },
|
||||||
async function netUnixPacketConcurrentSendReceive(): Promise<void> {
|
async function netUnixPacketConcurrentSendReceive() {
|
||||||
const filePath = await Deno.makeTempFile();
|
const filePath = await Deno.makeTempFile();
|
||||||
const socket = Deno.listenDatagram({
|
const socket = Deno.listenDatagram({
|
||||||
path: filePath,
|
path: filePath,
|
||||||
|
@ -388,10 +386,10 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function netTcpListenIteratorBreakClosesResource(): Promise<void> {
|
async function netTcpListenIteratorBreakClosesResource() {
|
||||||
const promise = deferred();
|
const promise = deferred();
|
||||||
|
|
||||||
async function iterate(listener: Deno.Listener): Promise<void> {
|
async function iterate(listener: Deno.Listener) {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
for await (const conn of listener) {
|
for await (const conn of listener) {
|
||||||
|
@ -422,7 +420,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function netTcpListenCloseWhileIterating(): Promise<void> {
|
async function netTcpListenCloseWhileIterating() {
|
||||||
const listener = Deno.listen({ port: 8001 });
|
const listener = Deno.listen({ port: 8001 });
|
||||||
const nextWhileClosing = listener[Symbol.asyncIterator]().next();
|
const nextWhileClosing = listener[Symbol.asyncIterator]().next();
|
||||||
listener.close();
|
listener.close();
|
||||||
|
@ -435,7 +433,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { net: true } },
|
{ perms: { net: true } },
|
||||||
async function netUdpListenCloseWhileIterating(): Promise<void> {
|
async function netUdpListenCloseWhileIterating() {
|
||||||
const socket = Deno.listenDatagram({ port: 8000, transport: "udp" });
|
const socket = Deno.listenDatagram({ port: 8000, transport: "udp" });
|
||||||
const nextWhileClosing = socket[Symbol.asyncIterator]().next();
|
const nextWhileClosing = socket[Symbol.asyncIterator]().next();
|
||||||
socket.close();
|
socket.close();
|
||||||
|
@ -448,7 +446,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
async function netUnixListenCloseWhileIterating(): Promise<void> {
|
async function netUnixListenCloseWhileIterating() {
|
||||||
const filePath = Deno.makeTempFileSync();
|
const filePath = Deno.makeTempFileSync();
|
||||||
const socket = Deno.listen({ path: filePath, transport: "unix" });
|
const socket = Deno.listen({ path: filePath, transport: "unix" });
|
||||||
const nextWhileClosing = socket[Symbol.asyncIterator]().next();
|
const nextWhileClosing = socket[Symbol.asyncIterator]().next();
|
||||||
|
@ -462,7 +460,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
async function netUnixPacketListenCloseWhileIterating(): Promise<void> {
|
async function netUnixPacketListenCloseWhileIterating() {
|
||||||
const filePath = Deno.makeTempFileSync();
|
const filePath = Deno.makeTempFileSync();
|
||||||
const socket = Deno.listenDatagram({
|
const socket = Deno.listenDatagram({
|
||||||
path: filePath,
|
path: filePath,
|
||||||
|
@ -483,10 +481,10 @@ unitTest(
|
||||||
ignore: true,
|
ignore: true,
|
||||||
perms: { net: true },
|
perms: { net: true },
|
||||||
},
|
},
|
||||||
async function netListenAsyncIterator(): Promise<void> {
|
async function netListenAsyncIterator() {
|
||||||
const addr = { hostname: "127.0.0.1", port: 3500 };
|
const addr = { hostname: "127.0.0.1", port: 3500 };
|
||||||
const listener = Deno.listen(addr);
|
const listener = Deno.listen(addr);
|
||||||
const runAsyncIterator = async (): Promise<void> => {
|
const runAsyncIterator = async () => {
|
||||||
for await (const conn of listener) {
|
for await (const conn of listener) {
|
||||||
await conn.write(new Uint8Array([1, 2, 3]));
|
await conn.write(new Uint8Array([1, 2, 3]));
|
||||||
conn.close();
|
conn.close();
|
||||||
|
@ -552,7 +550,7 @@ unitTest(
|
||||||
async function netHangsOnClose() {
|
async function netHangsOnClose() {
|
||||||
let acceptedConn: Deno.Conn;
|
let acceptedConn: Deno.Conn;
|
||||||
|
|
||||||
async function iteratorReq(listener: Deno.Listener): Promise<void> {
|
async function iteratorReq(listener: Deno.Listener) {
|
||||||
const p = new Uint8Array(10);
|
const p = new Uint8Array(10);
|
||||||
const conn = await listener.accept();
|
const conn = await listener.accept();
|
||||||
acceptedConn = conn;
|
acceptedConn = conn;
|
||||||
|
|
|
@ -21,7 +21,7 @@ declare global {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unitTest(async function opsAsyncBadResource(): Promise<void> {
|
unitTest(async function opsAsyncBadResource() {
|
||||||
try {
|
try {
|
||||||
const nonExistingRid = 9999;
|
const nonExistingRid = 9999;
|
||||||
await Deno.core.opAsync(
|
await Deno.core.opAsync(
|
||||||
|
@ -36,7 +36,7 @@ unitTest(async function opsAsyncBadResource(): Promise<void> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function opsSyncBadResource(): void {
|
unitTest(function opsSyncBadResource() {
|
||||||
try {
|
try {
|
||||||
const nonExistingRid = 9999;
|
const nonExistingRid = 9999;
|
||||||
Deno.core.opSync("op_read_sync", nonExistingRid, new Uint8Array(0));
|
Deno.core.opSync("op_read_sync", nonExistingRid, new Uint8Array(0));
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest({ perms: { env: true } }, function envSuccess(): void {
|
unitTest({ perms: { env: true } }, function envSuccess() {
|
||||||
Deno.env.set("TEST_VAR", "A");
|
Deno.env.set("TEST_VAR", "A");
|
||||||
const env = Deno.env.toObject();
|
const env = Deno.env.toObject();
|
||||||
Deno.env.set("TEST_VAR", "B");
|
Deno.env.set("TEST_VAR", "B");
|
||||||
|
@ -15,19 +15,19 @@ unitTest({ perms: { env: true } }, function envSuccess(): void {
|
||||||
assertNotEquals(Deno.env.get("TEST_VAR"), env["TEST_VAR"]);
|
assertNotEquals(Deno.env.get("TEST_VAR"), env["TEST_VAR"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { env: true } }, function envNotFound(): void {
|
unitTest({ perms: { env: true } }, function envNotFound() {
|
||||||
const r = Deno.env.get("env_var_does_not_exist!");
|
const r = Deno.env.get("env_var_does_not_exist!");
|
||||||
assertEquals(r, undefined);
|
assertEquals(r, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { env: true } }, function deleteEnv(): void {
|
unitTest({ perms: { env: true } }, function deleteEnv() {
|
||||||
Deno.env.set("TEST_VAR", "A");
|
Deno.env.set("TEST_VAR", "A");
|
||||||
assertEquals(Deno.env.get("TEST_VAR"), "A");
|
assertEquals(Deno.env.get("TEST_VAR"), "A");
|
||||||
assertEquals(Deno.env.delete("TEST_VAR"), undefined);
|
assertEquals(Deno.env.delete("TEST_VAR"), undefined);
|
||||||
assertEquals(Deno.env.get("TEST_VAR"), undefined);
|
assertEquals(Deno.env.get("TEST_VAR"), undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { env: true } }, function avoidEmptyNamedEnv(): void {
|
unitTest({ perms: { env: true } }, function avoidEmptyNamedEnv() {
|
||||||
assertThrows(() => Deno.env.set("", "v"), TypeError);
|
assertThrows(() => Deno.env.set("", "v"), TypeError);
|
||||||
assertThrows(() => Deno.env.set("a=a", "v"), TypeError);
|
assertThrows(() => Deno.env.set("a=a", "v"), TypeError);
|
||||||
assertThrows(() => Deno.env.set("a\0a", "v"), TypeError);
|
assertThrows(() => Deno.env.set("a\0a", "v"), TypeError);
|
||||||
|
@ -42,13 +42,13 @@ unitTest({ perms: { env: true } }, function avoidEmptyNamedEnv(): void {
|
||||||
assertThrows(() => Deno.env.delete("a\0a"), TypeError);
|
assertThrows(() => Deno.env.delete("a\0a"), TypeError);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function envPermissionDenied1(): void {
|
unitTest(function envPermissionDenied1() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.env.toObject();
|
Deno.env.toObject();
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function envPermissionDenied2(): void {
|
unitTest(function envPermissionDenied2() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.env.get("PATH");
|
Deno.env.get("PATH");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -70,7 +70,7 @@ unitTest(
|
||||||
const checkChildEnv = async (
|
const checkChildEnv = async (
|
||||||
inputEnv: Record<string, string>,
|
inputEnv: Record<string, string>,
|
||||||
expectedEnv: Record<string, string>,
|
expectedEnv: Record<string, string>,
|
||||||
): Promise<void> => {
|
) => {
|
||||||
const src = `
|
const src = `
|
||||||
console.log(
|
console.log(
|
||||||
${JSON.stringify(Object.keys(expectedEnv))}.map(k => Deno.env.get(k))
|
${JSON.stringify(Object.keys(expectedEnv))}.map(k => Deno.env.get(k))
|
||||||
|
@ -122,17 +122,17 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(function osPid(): void {
|
unitTest(function osPid() {
|
||||||
assert(Deno.pid > 0);
|
assert(Deno.pid > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function osPpid(): void {
|
unitTest(function osPpid() {
|
||||||
assert(Deno.ppid > 0);
|
assert(Deno.ppid > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, read: true } },
|
{ perms: { run: true, read: true } },
|
||||||
async function osPpidIsEqualToPidOfParentProcess(): Promise<void> {
|
async function osPpidIsEqualToPidOfParentProcess() {
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
const process = Deno.run({
|
const process = Deno.run({
|
||||||
cmd: [Deno.execPath(), "eval", "-p", "--unstable", "Deno.ppid"],
|
cmd: [Deno.execPath(), "eval", "-p", "--unstable", "Deno.ppid"],
|
||||||
|
@ -148,11 +148,11 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function execPath(): void {
|
unitTest({ perms: { read: true } }, function execPath() {
|
||||||
assertNotEquals(Deno.execPath(), "");
|
assertNotEquals(Deno.execPath(), "");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, function execPathPerm(): void {
|
unitTest({ perms: { read: false } }, function execPathPerm() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.execPath();
|
Deno.execPath();
|
||||||
|
@ -162,38 +162,38 @@ unitTest({ perms: { read: false } }, function execPathPerm(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { env: true } }, function loadavgSuccess(): void {
|
unitTest({ perms: { env: true } }, function loadavgSuccess() {
|
||||||
const load = Deno.loadavg();
|
const load = Deno.loadavg();
|
||||||
assertEquals(load.length, 3);
|
assertEquals(load.length, 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { env: false } }, function loadavgPerm(): void {
|
unitTest({ perms: { env: false } }, function loadavgPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.loadavg();
|
Deno.loadavg();
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { env: true } }, function hostnameDir(): void {
|
unitTest({ perms: { env: true } }, function hostnameDir() {
|
||||||
assertNotEquals(Deno.hostname(), "");
|
assertNotEquals(Deno.hostname(), "");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { env: false } }, function hostnamePerm(): void {
|
unitTest({ perms: { env: false } }, function hostnamePerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.hostname();
|
Deno.hostname();
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { env: true } }, function releaseDir(): void {
|
unitTest({ perms: { env: true } }, function releaseDir() {
|
||||||
assertNotEquals(Deno.osRelease(), "");
|
assertNotEquals(Deno.osRelease(), "");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { env: false } }, function releasePerm(): void {
|
unitTest({ perms: { env: false } }, function releasePerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.osRelease();
|
Deno.osRelease();
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { env: true } }, function systemMemoryInfo(): void {
|
unitTest({ perms: { env: true } }, function systemMemoryInfo() {
|
||||||
const info = Deno.systemMemoryInfo();
|
const info = Deno.systemMemoryInfo();
|
||||||
assert(info.total >= 0);
|
assert(info.total >= 0);
|
||||||
assert(info.free >= 0);
|
assert(info.free >= 0);
|
||||||
|
|
|
@ -5,7 +5,7 @@ const { pathFromURL } = Deno[Deno.internal];
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows" },
|
{ ignore: Deno.build.os === "windows" },
|
||||||
function pathFromURLPosix(): void {
|
function pathFromURLPosix() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
pathFromURL(new URL("file:///test/directory")),
|
pathFromURL(new URL("file:///test/directory")),
|
||||||
"/test/directory",
|
"/test/directory",
|
||||||
|
@ -17,7 +17,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os !== "windows" },
|
{ ignore: Deno.build.os !== "windows" },
|
||||||
function pathFromURLWin32(): void {
|
function pathFromURLWin32() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
pathFromURL(new URL("file:///c:/windows/test")),
|
pathFromURL(new URL("file:///c:/windows/test")),
|
||||||
"c:\\windows\\test",
|
"c:\\windows\\test",
|
||||||
|
|
|
@ -8,12 +8,10 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest({ perms: { hrtime: false } }, async function performanceNow(): Promise<
|
unitTest({ perms: { hrtime: false } }, async function performanceNow() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const resolvable = deferred();
|
const resolvable = deferred();
|
||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
setTimeout((): void => {
|
setTimeout(() => {
|
||||||
const end = performance.now();
|
const end = performance.now();
|
||||||
assert(end - start >= 10);
|
assert(end - start >= 10);
|
||||||
resolvable.resolve();
|
resolvable.resolve();
|
||||||
|
@ -82,7 +80,7 @@ unitTest(function performanceMeasure() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function performanceCustomInspectFunction(): void {
|
unitTest(function performanceCustomInspectFunction() {
|
||||||
assertStringIncludes(Deno.inspect(performance), "Performance");
|
assertStringIncludes(Deno.inspect(performance), "Performance");
|
||||||
assertStringIncludes(
|
assertStringIncludes(
|
||||||
Deno.inspect(Performance.prototype),
|
Deno.inspect(Performance.prototype),
|
||||||
|
@ -90,7 +88,7 @@ unitTest(function performanceCustomInspectFunction(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function performanceMarkCustomInspectFunction(): void {
|
unitTest(function performanceMarkCustomInspectFunction() {
|
||||||
const mark1 = performance.mark("mark1");
|
const mark1 = performance.mark("mark1");
|
||||||
assertStringIncludes(Deno.inspect(mark1), "PerformanceMark");
|
assertStringIncludes(Deno.inspect(mark1), "PerformanceMark");
|
||||||
assertStringIncludes(
|
assertStringIncludes(
|
||||||
|
@ -99,7 +97,7 @@ unitTest(function performanceMarkCustomInspectFunction(): void {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function performanceMeasureCustomInspectFunction(): void {
|
unitTest(function performanceMeasureCustomInspectFunction() {
|
||||||
const measure1 = performance.measure("measure1");
|
const measure1 = performance.measure("measure1");
|
||||||
assertStringIncludes(Deno.inspect(measure1), "PerformanceMeasure");
|
assertStringIncludes(Deno.inspect(measure1), "PerformanceMeasure");
|
||||||
assertStringIncludes(
|
assertStringIncludes(
|
||||||
|
|
|
@ -7,14 +7,14 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(async function permissionInvalidName(): Promise<void> {
|
unitTest(async function permissionInvalidName() {
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
await Deno.permissions.query({ name: "foo" as any });
|
await Deno.permissions.query({ name: "foo" as any });
|
||||||
}, TypeError);
|
}, TypeError);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function permissionNetInvalidHost(): Promise<void> {
|
unitTest(async function permissionNetInvalidHost() {
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.permissions.query({ name: "net", host: ":" });
|
await Deno.permissions.query({ name: "net", host: ":" });
|
||||||
}, URIError);
|
}, URIError);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function runPermissions(): void {
|
unitTest({ perms: { read: true } }, function runPermissions() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.run({ cmd: [Deno.execPath(), "eval", "console.log('hello world')"] });
|
Deno.run({ cmd: [Deno.execPath(), "eval", "console.log('hello world')"] });
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -15,7 +15,7 @@ unitTest({ perms: { read: true } }, function runPermissions(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, read: true } },
|
{ perms: { run: true, read: true } },
|
||||||
async function runSuccess(): Promise<void> {
|
async function runSuccess() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
|
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
|
@ -32,7 +32,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, read: true } },
|
{ perms: { run: true, read: true } },
|
||||||
async function runUrl(): Promise<void> {
|
async function runUrl() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
new URL(`file:///${Deno.execPath()}`),
|
new URL(`file:///${Deno.execPath()}`),
|
||||||
|
@ -73,7 +73,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, read: true } },
|
{ perms: { run: true, read: true } },
|
||||||
function runInvalidStdio(): void {
|
function runInvalidStdio() {
|
||||||
assertThrows(() =>
|
assertThrows(() =>
|
||||||
Deno.run({
|
Deno.run({
|
||||||
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
|
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
|
||||||
|
@ -100,7 +100,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, read: true } },
|
{ perms: { run: true, read: true } },
|
||||||
async function runCommandFailedWithCode(): Promise<void> {
|
async function runCommandFailedWithCode() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [Deno.execPath(), "eval", "Deno.exit(41 + 1)"],
|
cmd: [Deno.execPath(), "eval", "Deno.exit(41 + 1)"],
|
||||||
});
|
});
|
||||||
|
@ -118,7 +118,7 @@ unitTest(
|
||||||
ignore: Deno.build.os === "windows",
|
ignore: Deno.build.os === "windows",
|
||||||
perms: { run: true, read: true },
|
perms: { run: true, read: true },
|
||||||
},
|
},
|
||||||
async function runCommandFailedWithSignal(): Promise<void> {
|
async function runCommandFailedWithSignal() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [Deno.execPath(), "eval", "--unstable", "Deno.kill(Deno.pid, 9)"],
|
cmd: [Deno.execPath(), "eval", "--unstable", "Deno.kill(Deno.pid, 9)"],
|
||||||
});
|
});
|
||||||
|
@ -130,7 +130,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { run: true } }, function runNotFound(): void {
|
unitTest({ perms: { run: true } }, function runNotFound() {
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
Deno.run({ cmd: ["this file hopefully doesn't exist"] });
|
Deno.run({ cmd: ["this file hopefully doesn't exist"] });
|
||||||
|
@ -143,7 +143,7 @@ unitTest({ perms: { run: true } }, function runNotFound(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, run: true, read: true } },
|
{ perms: { write: true, run: true, read: true } },
|
||||||
async function runWithCwdIsAsync(): Promise<void> {
|
async function runWithCwdIsAsync() {
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const cwd = await Deno.makeTempDir({ prefix: "deno_command_test" });
|
const cwd = await Deno.makeTempDir({ prefix: "deno_command_test" });
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, read: true } },
|
{ perms: { run: true, read: true } },
|
||||||
async function runOutput(): Promise<void> {
|
async function runOutput() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
|
@ -325,7 +325,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, write: true, read: true } },
|
{ perms: { run: true, write: true, read: true } },
|
||||||
async function runRedirectStdoutStderr(): Promise<void> {
|
async function runRedirectStdoutStderr() {
|
||||||
const tempDir = await Deno.makeTempDir();
|
const tempDir = await Deno.makeTempDir();
|
||||||
const fileName = tempDir + "/redirected_stdio.txt";
|
const fileName = tempDir + "/redirected_stdio.txt";
|
||||||
const file = await Deno.open(fileName, {
|
const file = await Deno.open(fileName, {
|
||||||
|
@ -358,7 +358,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, write: true, read: true } },
|
{ perms: { run: true, write: true, read: true } },
|
||||||
async function runRedirectStdin(): Promise<void> {
|
async function runRedirectStdin() {
|
||||||
const tempDir = await Deno.makeTempDir();
|
const tempDir = await Deno.makeTempDir();
|
||||||
const fileName = tempDir + "/redirected_stdio.txt";
|
const fileName = tempDir + "/redirected_stdio.txt";
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
|
@ -383,7 +383,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, read: true } },
|
{ perms: { run: true, read: true } },
|
||||||
async function runEnv(): Promise<void> {
|
async function runEnv() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
|
@ -405,7 +405,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, read: true } },
|
{ perms: { run: true, read: true } },
|
||||||
async function runClose(): Promise<void> {
|
async function runClose() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
|
@ -428,7 +428,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, read: true } },
|
{ perms: { run: true, read: true } },
|
||||||
async function runKillAfterStatus(): Promise<void> {
|
async function runKillAfterStatus() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [Deno.execPath(), "eval", 'console.log("hello")'],
|
cmd: [Deno.execPath(), "eval", 'console.log("hello")'],
|
||||||
});
|
});
|
||||||
|
@ -454,7 +454,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(function signalNumbers(): void {
|
unitTest(function signalNumbers() {
|
||||||
if (Deno.build.os === "darwin") {
|
if (Deno.build.os === "darwin") {
|
||||||
assertEquals(Deno.Signal.SIGSTOP, 17);
|
assertEquals(Deno.Signal.SIGSTOP, 17);
|
||||||
} else if (Deno.build.os === "linux") {
|
} else if (Deno.build.os === "linux") {
|
||||||
|
@ -462,7 +462,7 @@ unitTest(function signalNumbers(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function killPermissions(): void {
|
unitTest(function killPermissions() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
// Unlike the other test cases, we don't have permission to spawn a
|
// Unlike the other test cases, we don't have permission to spawn a
|
||||||
// subprocess we can safely kill. Instead we send SIGCONT to the current
|
// subprocess we can safely kill. Instead we send SIGCONT to the current
|
||||||
|
@ -474,7 +474,7 @@ unitTest(function killPermissions(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, read: true } },
|
{ perms: { run: true, read: true } },
|
||||||
async function killSuccess(): Promise<void> {
|
async function killSuccess() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [Deno.execPath(), "eval", "setTimeout(() => {}, 10000)"],
|
cmd: [Deno.execPath(), "eval", "setTimeout(() => {}, 10000)"],
|
||||||
});
|
});
|
||||||
|
@ -497,7 +497,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { run: true, read: true } }, function killFailed(): void {
|
unitTest({ perms: { run: true, read: true } }, function killFailed() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [Deno.execPath(), "eval", "setTimeout(() => {}, 10000)"],
|
cmd: [Deno.execPath(), "eval", "setTimeout(() => {}, 10000)"],
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertEquals, unitTest } from "./test_util.ts";
|
import { assertEquals, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function progressEventConstruct(): void {
|
unitTest(function progressEventConstruct() {
|
||||||
const progressEventDefs = new ProgressEvent("progressEventType", {});
|
const progressEventDefs = new ProgressEvent("progressEventType", {});
|
||||||
assertEquals(progressEventDefs.lengthComputable, false);
|
assertEquals(progressEventDefs.lengthComputable, false);
|
||||||
assertEquals(progressEventDefs.loaded, 0);
|
assertEquals(progressEventDefs.loaded, 0);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
function assertSameContent(files: Deno.DirEntry[]): void {
|
function assertSameContent(files: Deno.DirEntry[]) {
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|
||||||
for (const entry of files) {
|
for (const entry of files) {
|
||||||
|
@ -21,37 +21,35 @@ function assertSameContent(files: Deno.DirEntry[]): void {
|
||||||
assertEquals(counter, 1);
|
assertEquals(counter, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readDirSyncSuccess(): void {
|
unitTest({ perms: { read: true } }, function readDirSyncSuccess() {
|
||||||
const files = [...Deno.readDirSync("cli/tests/")];
|
const files = [...Deno.readDirSync("cli/tests/")];
|
||||||
assertSameContent(files);
|
assertSameContent(files);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readDirSyncWithUrl(): void {
|
unitTest({ perms: { read: true } }, function readDirSyncWithUrl() {
|
||||||
const files = [...Deno.readDirSync(pathToAbsoluteFileUrl("cli/tests"))];
|
const files = [...Deno.readDirSync(pathToAbsoluteFileUrl("cli/tests"))];
|
||||||
assertSameContent(files);
|
assertSameContent(files);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, function readDirSyncPerm(): void {
|
unitTest({ perms: { read: false } }, function readDirSyncPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.readDirSync("tests/");
|
Deno.readDirSync("tests/");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readDirSyncNotDir(): void {
|
unitTest({ perms: { read: true } }, function readDirSyncNotDir() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.readDirSync("cli/tests/fixture.json");
|
Deno.readDirSync("cli/tests/fixture.json");
|
||||||
}, Error);
|
}, Error);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readDirSyncNotFound(): void {
|
unitTest({ perms: { read: true } }, function readDirSyncNotFound() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.readDirSync("bad_dir_name");
|
Deno.readDirSync("bad_dir_name");
|
||||||
}, Deno.errors.NotFound);
|
}, Deno.errors.NotFound);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function readDirSuccess(): Promise<
|
unitTest({ perms: { read: true } }, async function readDirSuccess() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const files = [];
|
const files = [];
|
||||||
for await (const dirEntry of Deno.readDir("cli/tests/")) {
|
for await (const dirEntry of Deno.readDir("cli/tests/")) {
|
||||||
files.push(dirEntry);
|
files.push(dirEntry);
|
||||||
|
@ -59,9 +57,7 @@ unitTest({ perms: { read: true } }, async function readDirSuccess(): Promise<
|
||||||
assertSameContent(files);
|
assertSameContent(files);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function readDirWithUrl(): Promise<
|
unitTest({ perms: { read: true } }, async function readDirWithUrl() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const files = [];
|
const files = [];
|
||||||
for await (
|
for await (
|
||||||
const dirEntry of Deno.readDir(pathToAbsoluteFileUrl("cli/tests"))
|
const dirEntry of Deno.readDir(pathToAbsoluteFileUrl("cli/tests"))
|
||||||
|
@ -71,9 +67,7 @@ unitTest({ perms: { read: true } }, async function readDirWithUrl(): Promise<
|
||||||
assertSameContent(files);
|
assertSameContent(files);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, async function readDirPerm(): Promise<
|
unitTest({ perms: { read: false } }, async function readDirPerm() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.readDir("tests/")[Symbol.asyncIterator]().next();
|
await Deno.readDir("tests/")[Symbol.asyncIterator]().next();
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -92,7 +86,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true }, ignore: Deno.build.os == "windows" },
|
{ perms: { read: true }, ignore: Deno.build.os == "windows" },
|
||||||
function readDirDevFdSync(): void {
|
function readDirDevFdSync() {
|
||||||
for (const _ of Deno.readDirSync("/dev/fd")) {
|
for (const _ of Deno.readDirSync("/dev/fd")) {
|
||||||
// We don't actually care whats in here; just that we don't panic on non regular file entries
|
// We don't actually care whats in here; just that we don't panic on non regular file entries
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readFileSyncSuccess(): void {
|
unitTest({ perms: { read: true } }, function readFileSyncSuccess() {
|
||||||
const data = Deno.readFileSync("cli/tests/fixture.json");
|
const data = Deno.readFileSync("cli/tests/fixture.json");
|
||||||
assert(data.byteLength > 0);
|
assert(data.byteLength > 0);
|
||||||
const decoder = new TextDecoder("utf-8");
|
const decoder = new TextDecoder("utf-8");
|
||||||
|
@ -17,7 +17,7 @@ unitTest({ perms: { read: true } }, function readFileSyncSuccess(): void {
|
||||||
assertEquals(pkg.name, "deno");
|
assertEquals(pkg.name, "deno");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readFileSyncUrl(): void {
|
unitTest({ perms: { read: true } }, function readFileSyncUrl() {
|
||||||
const data = Deno.readFileSync(
|
const data = Deno.readFileSync(
|
||||||
pathToAbsoluteFileUrl("cli/tests/fixture.json"),
|
pathToAbsoluteFileUrl("cli/tests/fixture.json"),
|
||||||
);
|
);
|
||||||
|
@ -28,21 +28,19 @@ unitTest({ perms: { read: true } }, function readFileSyncUrl(): void {
|
||||||
assertEquals(pkg.name, "deno");
|
assertEquals(pkg.name, "deno");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, function readFileSyncPerm(): void {
|
unitTest({ perms: { read: false } }, function readFileSyncPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.readFileSync("cli/tests/fixture.json");
|
Deno.readFileSync("cli/tests/fixture.json");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readFileSyncNotFound(): void {
|
unitTest({ perms: { read: true } }, function readFileSyncNotFound() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.readFileSync("bad_filename");
|
Deno.readFileSync("bad_filename");
|
||||||
}, Deno.errors.NotFound);
|
}, Deno.errors.NotFound);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function readFileUrl(): Promise<
|
unitTest({ perms: { read: true } }, async function readFileUrl() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const data = await Deno.readFile(
|
const data = await Deno.readFile(
|
||||||
pathToAbsoluteFileUrl("cli/tests/fixture.json"),
|
pathToAbsoluteFileUrl("cli/tests/fixture.json"),
|
||||||
);
|
);
|
||||||
|
@ -53,9 +51,7 @@ unitTest({ perms: { read: true } }, async function readFileUrl(): Promise<
|
||||||
assertEquals(pkg.name, "deno");
|
assertEquals(pkg.name, "deno");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function readFileSuccess(): Promise<
|
unitTest({ perms: { read: true } }, async function readFileSuccess() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const data = await Deno.readFile("cli/tests/fixture.json");
|
const data = await Deno.readFile("cli/tests/fixture.json");
|
||||||
assert(data.byteLength > 0);
|
assert(data.byteLength > 0);
|
||||||
const decoder = new TextDecoder("utf-8");
|
const decoder = new TextDecoder("utf-8");
|
||||||
|
@ -64,15 +60,13 @@ unitTest({ perms: { read: true } }, async function readFileSuccess(): Promise<
|
||||||
assertEquals(pkg.name, "deno");
|
assertEquals(pkg.name, "deno");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, async function readFilePerm(): Promise<
|
unitTest({ perms: { read: false } }, async function readFilePerm() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.readFile("cli/tests/fixture.json");
|
await Deno.readFile("cli/tests/fixture.json");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readFileSyncLoop(): void {
|
unitTest({ perms: { read: true } }, function readFileSyncLoop() {
|
||||||
for (let i = 0; i < 256; i++) {
|
for (let i = 0; i < 256; i++) {
|
||||||
Deno.readFileSync("cli/tests/fixture.json");
|
Deno.readFileSync("cli/tests/fixture.json");
|
||||||
}
|
}
|
||||||
|
@ -80,7 +74,7 @@ unitTest({ perms: { read: true } }, function readFileSyncLoop(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true } },
|
{ perms: { read: true } },
|
||||||
async function readFileDoesNotLeakResources(): Promise<void> {
|
async function readFileDoesNotLeakResources() {
|
||||||
const resourcesBefore = Deno.resources();
|
const resourcesBefore = Deno.resources();
|
||||||
await assertThrowsAsync(async () => await Deno.readFile("cli"));
|
await assertThrowsAsync(async () => await Deno.readFile("cli"));
|
||||||
assertEquals(resourcesBefore, Deno.resources());
|
assertEquals(resourcesBefore, Deno.resources());
|
||||||
|
@ -89,7 +83,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true } },
|
{ perms: { read: true } },
|
||||||
function readFileSyncDoesNotLeakResources(): void {
|
function readFileSyncDoesNotLeakResources() {
|
||||||
const resourcesBefore = Deno.resources();
|
const resourcesBefore = Deno.resources();
|
||||||
assertThrows(() => Deno.readFileSync("cli"));
|
assertThrows(() => Deno.readFileSync("cli"));
|
||||||
assertEquals(resourcesBefore, Deno.resources());
|
assertEquals(resourcesBefore, Deno.resources());
|
||||||
|
@ -98,7 +92,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true } },
|
{ perms: { read: true } },
|
||||||
async function readFileWithAbortSignal(): Promise<void> {
|
async function readFileWithAbortSignal() {
|
||||||
const ac = new AbortController();
|
const ac = new AbortController();
|
||||||
queueMicrotask(() => ac.abort());
|
queueMicrotask(() => ac.abort());
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
|
@ -109,7 +103,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true } },
|
{ perms: { read: true } },
|
||||||
async function readTextileWithAbortSignal(): Promise<void> {
|
async function readTextileWithAbortSignal() {
|
||||||
const ac = new AbortController();
|
const ac = new AbortController();
|
||||||
queueMicrotask(() => ac.abort());
|
queueMicrotask(() => ac.abort());
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
function readLinkSyncSuccess(): void {
|
function readLinkSyncSuccess() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const target = testDir +
|
const target = testDir +
|
||||||
(Deno.build.os == "windows" ? "\\target" : "/target");
|
(Deno.build.os == "windows" ? "\\target" : "/target");
|
||||||
|
@ -24,7 +24,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
function readLinkSyncUrlSuccess(): void {
|
function readLinkSyncUrlSuccess() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const target = testDir +
|
const target = testDir +
|
||||||
(Deno.build.os == "windows" ? "\\target" : "/target");
|
(Deno.build.os == "windows" ? "\\target" : "/target");
|
||||||
|
@ -37,13 +37,13 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, function readLinkSyncPerm(): void {
|
unitTest({ perms: { read: false } }, function readLinkSyncPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.readLinkSync("/symlink");
|
Deno.readLinkSync("/symlink");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readLinkSyncNotFound(): void {
|
unitTest({ perms: { read: true } }, function readLinkSyncNotFound() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.readLinkSync("bad_filename");
|
Deno.readLinkSync("bad_filename");
|
||||||
}, Deno.errors.NotFound);
|
}, Deno.errors.NotFound);
|
||||||
|
@ -51,7 +51,7 @@ unitTest({ perms: { read: true } }, function readLinkSyncNotFound(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
async function readLinkSuccess(): Promise<void> {
|
async function readLinkSuccess() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const target = testDir +
|
const target = testDir +
|
||||||
(Deno.build.os == "windows" ? "\\target" : "/target");
|
(Deno.build.os == "windows" ? "\\target" : "/target");
|
||||||
|
@ -66,7 +66,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
async function readLinkUrlSuccess(): Promise<void> {
|
async function readLinkUrlSuccess() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const target = testDir +
|
const target = testDir +
|
||||||
(Deno.build.os == "windows" ? "\\target" : "/target");
|
(Deno.build.os == "windows" ? "\\target" : "/target");
|
||||||
|
@ -79,9 +79,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, async function readLinkPerm(): Promise<
|
unitTest({ perms: { read: false } }, async function readLinkPerm() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.readLink("/symlink");
|
await Deno.readLink("/symlink");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
|
|
@ -7,14 +7,14 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readTextFileSyncSuccess(): void {
|
unitTest({ perms: { read: true } }, function readTextFileSyncSuccess() {
|
||||||
const data = Deno.readTextFileSync("cli/tests/fixture.json");
|
const data = Deno.readTextFileSync("cli/tests/fixture.json");
|
||||||
assert(data.length > 0);
|
assert(data.length > 0);
|
||||||
const pkg = JSON.parse(data);
|
const pkg = JSON.parse(data);
|
||||||
assertEquals(pkg.name, "deno");
|
assertEquals(pkg.name, "deno");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readTextFileSyncByUrl(): void {
|
unitTest({ perms: { read: true } }, function readTextFileSyncByUrl() {
|
||||||
const data = Deno.readTextFileSync(
|
const data = Deno.readTextFileSync(
|
||||||
pathToAbsoluteFileUrl("cli/tests/fixture.json"),
|
pathToAbsoluteFileUrl("cli/tests/fixture.json"),
|
||||||
);
|
);
|
||||||
|
@ -23,13 +23,13 @@ unitTest({ perms: { read: true } }, function readTextFileSyncByUrl(): void {
|
||||||
assertEquals(pkg.name, "deno");
|
assertEquals(pkg.name, "deno");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, function readTextFileSyncPerm(): void {
|
unitTest({ perms: { read: false } }, function readTextFileSyncPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.readTextFileSync("cli/tests/fixture.json");
|
Deno.readTextFileSync("cli/tests/fixture.json");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readTextFileSyncNotFound(): void {
|
unitTest({ perms: { read: true } }, function readTextFileSyncNotFound() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.readTextFileSync("bad_filename");
|
Deno.readTextFileSync("bad_filename");
|
||||||
}, Deno.errors.NotFound);
|
}, Deno.errors.NotFound);
|
||||||
|
@ -37,7 +37,7 @@ unitTest({ perms: { read: true } }, function readTextFileSyncNotFound(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true } },
|
{ perms: { read: true } },
|
||||||
async function readTextFileSuccess(): Promise<void> {
|
async function readTextFileSuccess() {
|
||||||
const data = await Deno.readTextFile("cli/tests/fixture.json");
|
const data = await Deno.readTextFile("cli/tests/fixture.json");
|
||||||
assert(data.length > 0);
|
assert(data.length > 0);
|
||||||
const pkg = JSON.parse(data);
|
const pkg = JSON.parse(data);
|
||||||
|
@ -45,9 +45,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function readTextFileByUrl(): Promise<
|
unitTest({ perms: { read: true } }, async function readTextFileByUrl() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const data = await Deno.readTextFile(
|
const data = await Deno.readTextFile(
|
||||||
pathToAbsoluteFileUrl("cli/tests/fixture.json"),
|
pathToAbsoluteFileUrl("cli/tests/fixture.json"),
|
||||||
);
|
);
|
||||||
|
@ -56,15 +54,13 @@ unitTest({ perms: { read: true } }, async function readTextFileByUrl(): Promise<
|
||||||
assertEquals(pkg.name, "deno");
|
assertEquals(pkg.name, "deno");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, async function readTextFilePerm(): Promise<
|
unitTest({ perms: { read: false } }, async function readTextFilePerm() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.readTextFile("cli/tests/fixture.json");
|
await Deno.readTextFile("cli/tests/fixture.json");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function readTextFileSyncLoop(): void {
|
unitTest({ perms: { read: true } }, function readTextFileSyncLoop() {
|
||||||
for (let i = 0; i < 256; i++) {
|
for (let i = 0; i < 256; i++) {
|
||||||
Deno.readTextFileSync("cli/tests/fixture.json");
|
Deno.readTextFileSync("cli/tests/fixture.json");
|
||||||
}
|
}
|
||||||
|
@ -72,7 +68,7 @@ unitTest({ perms: { read: true } }, function readTextFileSyncLoop(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true } },
|
{ perms: { read: true } },
|
||||||
async function readTextFileDoesNotLeakResources(): Promise<void> {
|
async function readTextFileDoesNotLeakResources() {
|
||||||
const resourcesBefore = Deno.resources();
|
const resourcesBefore = Deno.resources();
|
||||||
await assertThrowsAsync(async () => await Deno.readTextFile("cli"));
|
await assertThrowsAsync(async () => await Deno.readTextFile("cli"));
|
||||||
assertEquals(resourcesBefore, Deno.resources());
|
assertEquals(resourcesBefore, Deno.resources());
|
||||||
|
@ -81,7 +77,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true } },
|
{ perms: { read: true } },
|
||||||
function readTextFileSyncDoesNotLeakResources(): void {
|
function readTextFileSyncDoesNotLeakResources() {
|
||||||
const resourcesBefore = Deno.resources();
|
const resourcesBefore = Deno.resources();
|
||||||
assertThrows(() => Deno.readTextFileSync("cli"));
|
assertThrows(() => Deno.readTextFileSync("cli"));
|
||||||
assertEquals(resourcesBefore, Deno.resources());
|
assertEquals(resourcesBefore, Deno.resources());
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function realPathSyncSuccess(): void {
|
unitTest({ perms: { read: true } }, function realPathSyncSuccess() {
|
||||||
const relative = "cli/tests/fixture.json";
|
const relative = "cli/tests/fixture.json";
|
||||||
const realPath = Deno.realPathSync(relative);
|
const realPath = Deno.realPathSync(relative);
|
||||||
if (Deno.build.os !== "windows") {
|
if (Deno.build.os !== "windows") {
|
||||||
|
@ -21,7 +21,7 @@ unitTest({ perms: { read: true } }, function realPathSyncSuccess(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function realPathSyncUrl(): void {
|
unitTest({ perms: { read: true } }, function realPathSyncUrl() {
|
||||||
const relative = "cli/tests/fixture.json";
|
const relative = "cli/tests/fixture.json";
|
||||||
const url = pathToAbsoluteFileUrl(relative);
|
const url = pathToAbsoluteFileUrl(relative);
|
||||||
assertEquals(Deno.realPathSync(relative), Deno.realPathSync(url));
|
assertEquals(Deno.realPathSync(relative), Deno.realPathSync(url));
|
||||||
|
@ -31,7 +31,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { read: true, write: true },
|
perms: { read: true, write: true },
|
||||||
},
|
},
|
||||||
function realPathSyncSymlink(): void {
|
function realPathSyncSymlink() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const target = testDir + "/target";
|
const target = testDir + "/target";
|
||||||
const symlink = testDir + "/symln";
|
const symlink = testDir + "/symln";
|
||||||
|
@ -48,21 +48,19 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, function realPathSyncPerm(): void {
|
unitTest({ perms: { read: false } }, function realPathSyncPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.realPathSync("some_file");
|
Deno.realPathSync("some_file");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function realPathSyncNotFound(): void {
|
unitTest({ perms: { read: true } }, function realPathSyncNotFound() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.realPathSync("bad_filename");
|
Deno.realPathSync("bad_filename");
|
||||||
}, Deno.errors.NotFound);
|
}, Deno.errors.NotFound);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function realPathSuccess(): Promise<
|
unitTest({ perms: { read: true } }, async function realPathSuccess() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const relativePath = "cli/tests/fixture.json";
|
const relativePath = "cli/tests/fixture.json";
|
||||||
const realPath = await Deno.realPath(relativePath);
|
const realPath = await Deno.realPath(relativePath);
|
||||||
if (Deno.build.os !== "windows") {
|
if (Deno.build.os !== "windows") {
|
||||||
|
@ -76,7 +74,7 @@ unitTest({ perms: { read: true } }, async function realPathSuccess(): Promise<
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true } },
|
{ perms: { read: true } },
|
||||||
async function realPathUrl(): Promise<void> {
|
async function realPathUrl() {
|
||||||
const relative = "cli/tests/fixture.json";
|
const relative = "cli/tests/fixture.json";
|
||||||
const url = pathToAbsoluteFileUrl(relative);
|
const url = pathToAbsoluteFileUrl(relative);
|
||||||
assertEquals(await Deno.realPath(relative), await Deno.realPath(url));
|
assertEquals(await Deno.realPath(relative), await Deno.realPath(url));
|
||||||
|
@ -87,7 +85,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { read: true, write: true },
|
perms: { read: true, write: true },
|
||||||
},
|
},
|
||||||
async function realPathSymlink(): Promise<void> {
|
async function realPathSymlink() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const target = testDir + "/target";
|
const target = testDir + "/target";
|
||||||
const symlink = testDir + "/symln";
|
const symlink = testDir + "/symln";
|
||||||
|
@ -104,17 +102,13 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, async function realPathPerm(): Promise<
|
unitTest({ perms: { read: false } }, async function realPathPerm() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.realPath("some_file");
|
await Deno.realPath("some_file");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function realPathNotFound(): Promise<
|
unitTest({ perms: { read: true } }, async function realPathNotFound() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.realPath("bad_filename");
|
await Deno.realPath("bad_filename");
|
||||||
}, Deno.errors.NotFound);
|
}, Deno.errors.NotFound);
|
||||||
|
|
|
@ -10,7 +10,7 @@ const REMOVE_METHODS = ["remove", "removeSync"] as const;
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
async function removeDirSuccess(): Promise<void> {
|
async function removeDirSuccess() {
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
// REMOVE EMPTY DIRECTORY
|
// REMOVE EMPTY DIRECTORY
|
||||||
const path = Deno.makeTempDirSync() + "/subdir";
|
const path = Deno.makeTempDirSync() + "/subdir";
|
||||||
|
@ -28,7 +28,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
async function removeFileSuccess(): Promise<void> {
|
async function removeFileSuccess() {
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
// REMOVE FILE
|
// REMOVE FILE
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
|
@ -48,7 +48,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
async function removeFileByUrl(): Promise<void> {
|
async function removeFileByUrl() {
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
// REMOVE FILE
|
// REMOVE FILE
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
|
@ -73,7 +73,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
async function removeFail(): Promise<void> {
|
async function removeFail() {
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
// NON-EMPTY DIRECTORY
|
// NON-EMPTY DIRECTORY
|
||||||
const path = Deno.makeTempDirSync() + "/dir/subdir";
|
const path = Deno.makeTempDirSync() + "/dir/subdir";
|
||||||
|
@ -100,7 +100,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
async function removeDanglingSymlinkSuccess(): Promise<void> {
|
async function removeDanglingSymlinkSuccess() {
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
const danglingSymlinkPath = Deno.makeTempDirSync() + "/dangling_symlink";
|
const danglingSymlinkPath = Deno.makeTempDirSync() + "/dangling_symlink";
|
||||||
if (Deno.build.os === "windows") {
|
if (Deno.build.os === "windows") {
|
||||||
|
@ -122,7 +122,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
async function removeValidSymlinkSuccess(): Promise<void> {
|
async function removeValidSymlinkSuccess() {
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const data = encoder.encode("Test");
|
const data = encoder.encode("Test");
|
||||||
|
@ -146,9 +146,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { write: false } }, async function removePerm(): Promise<
|
unitTest({ perms: { write: false } }, async function removePerm() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno[method]("/baddir");
|
await Deno[method]("/baddir");
|
||||||
|
@ -158,7 +156,7 @@ unitTest({ perms: { write: false } }, async function removePerm(): Promise<
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
async function removeAllDirSuccess(): Promise<void> {
|
async function removeAllDirSuccess() {
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
// REMOVE EMPTY DIRECTORY
|
// REMOVE EMPTY DIRECTORY
|
||||||
let path = Deno.makeTempDirSync() + "/dir/subdir";
|
let path = Deno.makeTempDirSync() + "/dir/subdir";
|
||||||
|
@ -195,7 +193,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { write: true, read: true } },
|
{ perms: { write: true, read: true } },
|
||||||
async function removeAllFileSuccess(): Promise<void> {
|
async function removeAllFileSuccess() {
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
// REMOVE FILE
|
// REMOVE FILE
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
|
@ -214,9 +212,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { write: true } }, async function removeAllFail(): Promise<
|
unitTest({ perms: { write: true } }, async function removeAllFail() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
// NON-EXISTENT DIRECTORY/FILE
|
// NON-EXISTENT DIRECTORY/FILE
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
|
@ -226,9 +222,7 @@ unitTest({ perms: { write: true } }, async function removeAllFail(): Promise<
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { write: false } }, async function removeAllPerm(): Promise<
|
unitTest({ perms: { write: false } }, async function removeAllPerm() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno[method]("/baddir", { recursive: true });
|
await Deno[method]("/baddir", { recursive: true });
|
||||||
|
@ -241,7 +235,7 @@ unitTest(
|
||||||
ignore: Deno.build.os === "windows",
|
ignore: Deno.build.os === "windows",
|
||||||
perms: { write: true, read: true },
|
perms: { write: true, read: true },
|
||||||
},
|
},
|
||||||
async function removeUnixSocketSuccess(): Promise<void> {
|
async function removeUnixSocketSuccess() {
|
||||||
for (const method of REMOVE_METHODS) {
|
for (const method of REMOVE_METHODS) {
|
||||||
// MAKE TEMPORARY UNIX SOCKET
|
// MAKE TEMPORARY UNIX SOCKET
|
||||||
const path = Deno.makeTempDirSync() + "/test.sock";
|
const path = Deno.makeTempDirSync() + "/test.sock";
|
||||||
|
@ -260,7 +254,7 @@ unitTest(
|
||||||
if (Deno.build.os === "windows") {
|
if (Deno.build.os === "windows") {
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, write: true, read: true } },
|
{ perms: { run: true, write: true, read: true } },
|
||||||
async function removeFileSymlink(): Promise<void> {
|
async function removeFileSymlink() {
|
||||||
const symlink = Deno.run({
|
const symlink = Deno.run({
|
||||||
cmd: ["cmd", "/c", "mklink", "file_link", "bar"],
|
cmd: ["cmd", "/c", "mklink", "file_link", "bar"],
|
||||||
stdout: "null",
|
stdout: "null",
|
||||||
|
@ -277,7 +271,7 @@ if (Deno.build.os === "windows") {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { run: true, write: true, read: true } },
|
{ perms: { run: true, write: true, read: true } },
|
||||||
async function removeDirSymlink(): Promise<void> {
|
async function removeDirSymlink() {
|
||||||
const symlink = Deno.run({
|
const symlink = Deno.run({
|
||||||
cmd: ["cmd", "/c", "mklink", "/d", "dir_link", "bar"],
|
cmd: ["cmd", "/c", "mklink", "/d", "dir_link", "bar"],
|
||||||
stdout: "null",
|
stdout: "null",
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
function assertMissing(path: string): void {
|
function assertMissing(path: string) {
|
||||||
let caughtErr = false;
|
let caughtErr = false;
|
||||||
let info;
|
let info;
|
||||||
try {
|
try {
|
||||||
|
@ -20,12 +20,12 @@ function assertMissing(path: string): void {
|
||||||
assertEquals(info, undefined);
|
assertEquals(info, undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertFile(path: string): void {
|
function assertFile(path: string) {
|
||||||
const info = Deno.lstatSync(path);
|
const info = Deno.lstatSync(path);
|
||||||
assert(info.isFile);
|
assert(info.isFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertDirectory(path: string, mode?: number): void {
|
function assertDirectory(path: string, mode?: number) {
|
||||||
const info = Deno.lstatSync(path);
|
const info = Deno.lstatSync(path);
|
||||||
assert(info.isDirectory);
|
assert(info.isDirectory);
|
||||||
if (Deno.build.os !== "windows" && mode !== undefined) {
|
if (Deno.build.os !== "windows" && mode !== undefined) {
|
||||||
|
@ -35,7 +35,7 @@ function assertDirectory(path: string, mode?: number): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function renameSyncSuccess(): void {
|
function renameSyncSuccess() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldpath = testDir + "/oldpath";
|
const oldpath = testDir + "/oldpath";
|
||||||
const newpath = testDir + "/newpath";
|
const newpath = testDir + "/newpath";
|
||||||
|
@ -48,7 +48,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function renameSyncWithURL(): void {
|
function renameSyncWithURL() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldpath = testDir + "/oldpath";
|
const oldpath = testDir + "/oldpath";
|
||||||
const newpath = testDir + "/newpath";
|
const newpath = testDir + "/newpath";
|
||||||
|
@ -64,7 +64,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: false, write: true } },
|
{ perms: { read: false, write: true } },
|
||||||
function renameSyncReadPerm(): void {
|
function renameSyncReadPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
const oldpath = "/oldbaddir";
|
const oldpath = "/oldbaddir";
|
||||||
const newpath = "/newbaddir";
|
const newpath = "/newbaddir";
|
||||||
|
@ -75,7 +75,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: false } },
|
{ perms: { read: true, write: false } },
|
||||||
function renameSyncWritePerm(): void {
|
function renameSyncWritePerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
const oldpath = "/oldbaddir";
|
const oldpath = "/oldbaddir";
|
||||||
const newpath = "/newbaddir";
|
const newpath = "/newbaddir";
|
||||||
|
@ -86,7 +86,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function renameSuccess(): Promise<void> {
|
async function renameSuccess() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldpath = testDir + "/oldpath";
|
const oldpath = testDir + "/oldpath";
|
||||||
const newpath = testDir + "/newpath";
|
const newpath = testDir + "/newpath";
|
||||||
|
@ -99,7 +99,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function renameWithURL(): Promise<void> {
|
async function renameWithURL() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldpath = testDir + "/oldpath";
|
const oldpath = testDir + "/oldpath";
|
||||||
const newpath = testDir + "/newpath";
|
const newpath = testDir + "/newpath";
|
||||||
|
@ -119,7 +119,7 @@ function readFileString(filename: string): string {
|
||||||
return dec.decode(dataRead);
|
return dec.decode(dataRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeFileString(filename: string, s: string): void {
|
function writeFileString(filename: string, s: string) {
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const data = enc.encode(s);
|
const data = enc.encode(s);
|
||||||
Deno.writeFileSync(filename, data, { mode: 0o666 });
|
Deno.writeFileSync(filename, data, { mode: 0o666 });
|
||||||
|
@ -127,7 +127,7 @@ function writeFileString(filename: string, s: string): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
function renameSyncErrorsUnix(): void {
|
function renameSyncErrorsUnix() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldfile = testDir + "/oldfile";
|
const oldfile = testDir + "/oldfile";
|
||||||
const olddir = testDir + "/olddir";
|
const olddir = testDir + "/olddir";
|
||||||
|
@ -141,21 +141,21 @@ unitTest(
|
||||||
writeFileString(file, "world");
|
writeFileString(file, "world");
|
||||||
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
(): void => {
|
() => {
|
||||||
Deno.renameSync(oldfile, emptydir);
|
Deno.renameSync(oldfile, emptydir);
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"Is a directory",
|
"Is a directory",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
(): void => {
|
() => {
|
||||||
Deno.renameSync(olddir, fulldir);
|
Deno.renameSync(olddir, fulldir);
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"Directory not empty",
|
"Directory not empty",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
(): void => {
|
() => {
|
||||||
Deno.renameSync(olddir, file);
|
Deno.renameSync(olddir, file);
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
|
@ -170,21 +170,21 @@ unitTest(
|
||||||
Deno.symlinkSync(testDir + "/nonexistent", danglingLink);
|
Deno.symlinkSync(testDir + "/nonexistent", danglingLink);
|
||||||
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
(): void => {
|
() => {
|
||||||
Deno.renameSync(olddir, fileLink);
|
Deno.renameSync(olddir, fileLink);
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"Not a directory",
|
"Not a directory",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
(): void => {
|
() => {
|
||||||
Deno.renameSync(olddir, dirLink);
|
Deno.renameSync(olddir, dirLink);
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"Not a directory",
|
"Not a directory",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
(): void => {
|
() => {
|
||||||
Deno.renameSync(olddir, danglingLink);
|
Deno.renameSync(olddir, danglingLink);
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
|
@ -202,7 +202,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os !== "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os !== "windows", perms: { read: true, write: true } },
|
||||||
function renameSyncErrorsWin(): void {
|
function renameSyncErrorsWin() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldfile = testDir + "/oldfile";
|
const oldfile = testDir + "/oldfile";
|
||||||
const olddir = testDir + "/olddir";
|
const olddir = testDir + "/olddir";
|
||||||
|
@ -216,21 +216,21 @@ unitTest(
|
||||||
writeFileString(file, "world");
|
writeFileString(file, "world");
|
||||||
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
(): void => {
|
() => {
|
||||||
Deno.renameSync(oldfile, emptydir);
|
Deno.renameSync(oldfile, emptydir);
|
||||||
},
|
},
|
||||||
Deno.errors.PermissionDenied,
|
Deno.errors.PermissionDenied,
|
||||||
"Access is denied",
|
"Access is denied",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
(): void => {
|
() => {
|
||||||
Deno.renameSync(olddir, fulldir);
|
Deno.renameSync(olddir, fulldir);
|
||||||
},
|
},
|
||||||
Deno.errors.PermissionDenied,
|
Deno.errors.PermissionDenied,
|
||||||
"Access is denied",
|
"Access is denied",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
(): void => {
|
() => {
|
||||||
Deno.renameSync(olddir, emptydir);
|
Deno.renameSync(olddir, emptydir);
|
||||||
},
|
},
|
||||||
Deno.errors.PermissionDenied,
|
Deno.errors.PermissionDenied,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertEquals, assertStringIncludes, unitTest } from "./test_util.ts";
|
import { assertEquals, assertStringIncludes, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(async function fromInit(): Promise<void> {
|
unitTest(async function fromInit() {
|
||||||
const req = new Request("http://foo/", {
|
const req = new Request("http://foo/", {
|
||||||
body: "ahoyhoy",
|
body: "ahoyhoy",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -15,7 +15,7 @@ unitTest(async function fromInit(): Promise<void> {
|
||||||
assertEquals(req.headers.get("test-header"), "value");
|
assertEquals(req.headers.get("test-header"), "value");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function requestNonString(): void {
|
unitTest(function requestNonString() {
|
||||||
const nonString = {
|
const nonString = {
|
||||||
toString() {
|
toString() {
|
||||||
return "http://foo/";
|
return "http://foo/";
|
||||||
|
@ -26,18 +26,18 @@ unitTest(function requestNonString(): void {
|
||||||
assertEquals(new Request(nonString).url, "http://foo/");
|
assertEquals(new Request(nonString).url, "http://foo/");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function methodNonString(): void {
|
unitTest(function methodNonString() {
|
||||||
assertEquals(new Request("http://foo/", { method: undefined }).method, "GET");
|
assertEquals(new Request("http://foo/", { method: undefined }).method, "GET");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function requestRelativeUrl(): void {
|
unitTest(function requestRelativeUrl() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
new Request("relative-url").url,
|
new Request("relative-url").url,
|
||||||
"http://js-unit-tests/foo/relative-url",
|
"http://js-unit-tests/foo/relative-url",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function cloneRequestBodyStream(): Promise<void> {
|
unitTest(async function cloneRequestBodyStream() {
|
||||||
// hack to get a stream
|
// hack to get a stream
|
||||||
const stream =
|
const stream =
|
||||||
new Request("http://foo/", { body: "a test body", method: "POST" }).body;
|
new Request("http://foo/", { body: "a test body", method: "POST" }).body;
|
||||||
|
@ -54,7 +54,7 @@ unitTest(async function cloneRequestBodyStream(): Promise<void> {
|
||||||
assertEquals(b1, b2);
|
assertEquals(b1, b2);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function customInspectFunction(): void {
|
unitTest(function customInspectFunction() {
|
||||||
const request = new Request("https://example.com");
|
const request = new Request("https://example.com");
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Deno.inspect(request),
|
Deno.inspect(request),
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assert, assertEquals, assertThrows, unitTest } from "./test_util.ts";
|
import { assert, assertEquals, assertThrows, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function resourcesCloseBadArgs(): void {
|
unitTest(function resourcesCloseBadArgs() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.close((null as unknown) as number);
|
Deno.close((null as unknown) as number);
|
||||||
}, TypeError);
|
}, TypeError);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function resourcesStdio(): void {
|
unitTest(function resourcesStdio() {
|
||||||
const res = Deno.resources();
|
const res = Deno.resources();
|
||||||
|
|
||||||
assertEquals(res[0], "stdin");
|
assertEquals(res[0], "stdin");
|
||||||
|
@ -15,9 +15,7 @@ unitTest(function resourcesStdio(): void {
|
||||||
assertEquals(res[2], "stderr");
|
assertEquals(res[2], "stderr");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, async function resourcesNet(): Promise<
|
unitTest({ perms: { net: true } }, async function resourcesNet() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const listener = Deno.listen({ port: 4501 });
|
const listener = Deno.listen({ port: 4501 });
|
||||||
const dialerConn = await Deno.connect({ port: 4501 });
|
const dialerConn = await Deno.connect({ port: 4501 });
|
||||||
const listenerConn = await listener.accept();
|
const listenerConn = await listener.accept();
|
||||||
|
@ -37,9 +35,7 @@ unitTest({ perms: { net: true } }, async function resourcesNet(): Promise<
|
||||||
listener.close();
|
listener.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function resourcesFile(): Promise<
|
unitTest({ perms: { read: true } }, async function resourcesFile() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const resourcesBefore = Deno.resources();
|
const resourcesBefore = Deno.resources();
|
||||||
const f = await Deno.open("cli/tests/hello.txt");
|
const f = await Deno.open("cli/tests/hello.txt");
|
||||||
const resourcesAfter = Deno.resources();
|
const resourcesAfter = Deno.resources();
|
||||||
|
|
|
@ -56,7 +56,7 @@ unitTest(async function responseFormData() {
|
||||||
assertEquals([...formData], [...input]);
|
assertEquals([...formData], [...input]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function customInspectFunction(): void {
|
unitTest(function customInspectFunction() {
|
||||||
const response = new Response();
|
const response = new Response();
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Deno.inspect(response),
|
Deno.inspect(response),
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os !== "windows" },
|
{ ignore: Deno.build.os !== "windows" },
|
||||||
function signalsNotImplemented(): void {
|
function signalsNotImplemented() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signal(1);
|
Deno.signal(1);
|
||||||
|
@ -100,7 +100,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { run: true, net: true } },
|
{ ignore: Deno.build.os === "windows", perms: { run: true, net: true } },
|
||||||
async function signalStreamTest(): Promise<void> {
|
async function signalStreamTest() {
|
||||||
const resolvable = deferred();
|
const resolvable = deferred();
|
||||||
// This prevents the program from exiting.
|
// This prevents the program from exiting.
|
||||||
const t = setInterval(() => {}, 1000);
|
const t = setInterval(() => {}, 1000);
|
||||||
|
@ -132,7 +132,7 @@ unitTest(
|
||||||
// This tests that pending op_signal_poll doesn't block the runtime from exiting the process.
|
// This tests that pending op_signal_poll doesn't block the runtime from exiting the process.
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { run: true, read: true } },
|
{ ignore: Deno.build.os === "windows", perms: { run: true, read: true } },
|
||||||
async function signalStreamExitTest(): Promise<void> {
|
async function signalStreamExitTest() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
|
@ -149,7 +149,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { run: true } },
|
{ ignore: Deno.build.os === "windows", perms: { run: true } },
|
||||||
async function signalPromiseTest(): Promise<void> {
|
async function signalPromiseTest() {
|
||||||
const resolvable = deferred();
|
const resolvable = deferred();
|
||||||
// This prevents the program from exiting.
|
// This prevents the program from exiting.
|
||||||
const t = setInterval(() => {}, 1000);
|
const t = setInterval(() => {}, 1000);
|
||||||
|
@ -170,7 +170,7 @@ unitTest(
|
||||||
// https://github.com/denoland/deno/issues/9806
|
// https://github.com/denoland/deno/issues/9806
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { run: true } },
|
{ ignore: Deno.build.os === "windows", perms: { run: true } },
|
||||||
async function signalPromiseTest2(): Promise<void> {
|
async function signalPromiseTest2() {
|
||||||
const resolvable = deferred();
|
const resolvable = deferred();
|
||||||
// This prevents the program from exiting.
|
// This prevents the program from exiting.
|
||||||
const t = setInterval(() => {}, 1000);
|
const t = setInterval(() => {}, 1000);
|
||||||
|
@ -198,7 +198,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { run: true } },
|
{ ignore: Deno.build.os === "windows", perms: { run: true } },
|
||||||
function signalShorthandsTest(): void {
|
function signalShorthandsTest() {
|
||||||
let s: Deno.SignalStream;
|
let s: Deno.SignalStream;
|
||||||
s = Deno.signals.alarm(); // for SIGALRM
|
s = Deno.signals.alarm(); // for SIGALRM
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function fstatSyncSuccess(): void {
|
unitTest({ perms: { read: true } }, function fstatSyncSuccess() {
|
||||||
const file = Deno.openSync("README.md");
|
const file = Deno.openSync("README.md");
|
||||||
const fileInfo = Deno.fstatSync(file.rid);
|
const fileInfo = Deno.fstatSync(file.rid);
|
||||||
assert(fileInfo.isFile);
|
assert(fileInfo.isFile);
|
||||||
|
@ -23,9 +23,7 @@ unitTest({ perms: { read: true } }, function fstatSyncSuccess(): void {
|
||||||
Deno.close(file.rid);
|
Deno.close(file.rid);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function fstatSuccess(): Promise<
|
unitTest({ perms: { read: true } }, async function fstatSuccess() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const file = await Deno.open("README.md");
|
const file = await Deno.open("README.md");
|
||||||
const fileInfo = await Deno.fstat(file.rid);
|
const fileInfo = await Deno.fstat(file.rid);
|
||||||
assert(fileInfo.isFile);
|
assert(fileInfo.isFile);
|
||||||
|
@ -42,7 +40,7 @@ unitTest({ perms: { read: true } }, async function fstatSuccess(): Promise<
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function statSyncSuccess(): void {
|
function statSyncSuccess() {
|
||||||
const packageInfo = Deno.statSync("README.md");
|
const packageInfo = Deno.statSync("README.md");
|
||||||
assert(packageInfo.isFile);
|
assert(packageInfo.isFile);
|
||||||
assert(!packageInfo.isSymlink);
|
assert(!packageInfo.isSymlink);
|
||||||
|
@ -103,19 +101,19 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, function statSyncPerm(): void {
|
unitTest({ perms: { read: false } }, function statSyncPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.statSync("README.md");
|
Deno.statSync("README.md");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function statSyncNotFound(): void {
|
unitTest({ perms: { read: true } }, function statSyncNotFound() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.statSync("bad_file_name");
|
Deno.statSync("bad_file_name");
|
||||||
}, Deno.errors.NotFound);
|
}, Deno.errors.NotFound);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function lstatSyncSuccess(): void {
|
unitTest({ perms: { read: true } }, function lstatSyncSuccess() {
|
||||||
const packageInfo = Deno.lstatSync("README.md");
|
const packageInfo = Deno.lstatSync("README.md");
|
||||||
assert(packageInfo.isFile);
|
assert(packageInfo.isFile);
|
||||||
assert(!packageInfo.isSymlink);
|
assert(!packageInfo.isSymlink);
|
||||||
|
@ -143,13 +141,13 @@ unitTest({ perms: { read: true } }, function lstatSyncSuccess(): void {
|
||||||
assert(!coreInfoByUrl.isSymlink);
|
assert(!coreInfoByUrl.isSymlink);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, function lstatSyncPerm(): void {
|
unitTest({ perms: { read: false } }, function lstatSyncPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.lstatSync("README.md");
|
Deno.lstatSync("README.md");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, function lstatSyncNotFound(): void {
|
unitTest({ perms: { read: true } }, function lstatSyncNotFound() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.lstatSync("bad_file_name");
|
Deno.lstatSync("bad_file_name");
|
||||||
}, Deno.errors.NotFound);
|
}, Deno.errors.NotFound);
|
||||||
|
@ -157,7 +155,7 @@ unitTest({ perms: { read: true } }, function lstatSyncNotFound(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function statSuccess(): Promise<void> {
|
async function statSuccess() {
|
||||||
const packageInfo = await Deno.stat("README.md");
|
const packageInfo = await Deno.stat("README.md");
|
||||||
assert(packageInfo.isFile);
|
assert(packageInfo.isFile);
|
||||||
assert(!packageInfo.isSymlink);
|
assert(!packageInfo.isSymlink);
|
||||||
|
@ -221,25 +219,21 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, async function statPerm(): Promise<void> {
|
unitTest({ perms: { read: false } }, async function statPerm() {
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.stat("README.md");
|
await Deno.stat("README.md");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function statNotFound(): Promise<
|
unitTest({ perms: { read: true } }, async function statNotFound() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(
|
await assertThrowsAsync(
|
||||||
async (): Promise<void> => {
|
async () => {
|
||||||
await Deno.stat("bad_file_name"), Deno.errors.NotFound;
|
await Deno.stat("bad_file_name"), Deno.errors.NotFound;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function lstatSuccess(): Promise<
|
unitTest({ perms: { read: true } }, async function lstatSuccess() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
const packageInfo = await Deno.lstat("README.md");
|
const packageInfo = await Deno.lstat("README.md");
|
||||||
assert(packageInfo.isFile);
|
assert(packageInfo.isFile);
|
||||||
assert(!packageInfo.isSymlink);
|
assert(!packageInfo.isSymlink);
|
||||||
|
@ -267,15 +261,13 @@ unitTest({ perms: { read: true } }, async function lstatSuccess(): Promise<
|
||||||
assert(!coreInfoByUrl.isSymlink);
|
assert(!coreInfoByUrl.isSymlink);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: false } }, async function lstatPerm(): Promise<void> {
|
unitTest({ perms: { read: false } }, async function lstatPerm() {
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.lstat("README.md");
|
await Deno.lstat("README.md");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { read: true } }, async function lstatNotFound(): Promise<
|
unitTest({ perms: { read: true } }, async function lstatNotFound() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.lstat("bad_file_name");
|
await Deno.lstat("bad_file_name");
|
||||||
}, Deno.errors.NotFound);
|
}, Deno.errors.NotFound);
|
||||||
|
@ -283,7 +275,7 @@ unitTest({ perms: { read: true } }, async function lstatNotFound(): Promise<
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os !== "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os !== "windows", perms: { read: true, write: true } },
|
||||||
function statNoUnixFields(): void {
|
function statNoUnixFields() {
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const data = enc.encode("Hello");
|
const data = enc.encode("Hello");
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
|
@ -304,7 +296,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||||
function statUnixFields(): void {
|
function statUnixFields() {
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const data = enc.encode("Hello");
|
const data = enc.encode("Hello");
|
||||||
const tempDir = Deno.makeTempDirSync();
|
const tempDir = Deno.makeTempDirSync();
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function symlinkSyncSuccess(): void {
|
function symlinkSyncSuccess() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldname = testDir + "/oldname";
|
const oldname = testDir + "/oldname";
|
||||||
const newname = testDir + "/newname";
|
const newname = testDir + "/newname";
|
||||||
|
@ -23,7 +23,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function symlinkSyncURL(): void {
|
function symlinkSyncURL() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldname = testDir + "/oldname";
|
const oldname = testDir + "/oldname";
|
||||||
const newname = testDir + "/newname";
|
const newname = testDir + "/newname";
|
||||||
|
@ -39,7 +39,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(function symlinkSyncPerm(): void {
|
unitTest(function symlinkSyncPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.symlinkSync("oldbaddir", "newbaddir");
|
Deno.symlinkSync("oldbaddir", "newbaddir");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -47,7 +47,7 @@ unitTest(function symlinkSyncPerm(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function symlinkSuccess(): Promise<void> {
|
async function symlinkSuccess() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldname = testDir + "/oldname";
|
const oldname = testDir + "/oldname";
|
||||||
const newname = testDir + "/newname";
|
const newname = testDir + "/newname";
|
||||||
|
@ -62,7 +62,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function symlinkURL(): Promise<void> {
|
async function symlinkURL() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const oldname = testDir + "/oldname";
|
const oldname = testDir + "/oldname";
|
||||||
const newname = testDir + "/newname";
|
const newname = testDir + "/newname";
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { assertEquals, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function fdatasyncSyncSuccess(): void {
|
function fdatasyncSyncSuccess() {
|
||||||
const filename = Deno.makeTempDirSync() + "/test_fdatasyncSync.txt";
|
const filename = Deno.makeTempDirSync() + "/test_fdatasyncSync.txt";
|
||||||
const file = Deno.openSync(filename, {
|
const file = Deno.openSync(filename, {
|
||||||
read: true,
|
read: true,
|
||||||
|
@ -21,7 +21,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function fdatasyncSuccess(): Promise<void> {
|
async function fdatasyncSuccess() {
|
||||||
const filename = (await Deno.makeTempDir()) + "/test_fdatasync.txt";
|
const filename = (await Deno.makeTempDir()) + "/test_fdatasync.txt";
|
||||||
const file = await Deno.open(filename, {
|
const file = await Deno.open(filename, {
|
||||||
read: true,
|
read: true,
|
||||||
|
@ -39,7 +39,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
function fsyncSyncSuccess(): void {
|
function fsyncSyncSuccess() {
|
||||||
const filename = Deno.makeTempDirSync() + "/test_fsyncSync.txt";
|
const filename = Deno.makeTempDirSync() + "/test_fsyncSync.txt";
|
||||||
const file = Deno.openSync(filename, {
|
const file = Deno.openSync(filename, {
|
||||||
read: true,
|
read: true,
|
||||||
|
@ -57,7 +57,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true } },
|
{ perms: { read: true, write: true } },
|
||||||
async function fsyncSuccess(): Promise<void> {
|
async function fsyncSuccess() {
|
||||||
const filename = (await Deno.makeTempDir()) + "/test_fsync.txt";
|
const filename = (await Deno.makeTempDir()) + "/test_fsync.txt";
|
||||||
const file = await Deno.open(filename, {
|
const file = await Deno.open(filename, {
|
||||||
read: true,
|
read: true,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertThrows, unitTest } from "./test_util.ts";
|
import { assertThrows, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function testFnOverloading(): void {
|
unitTest(function testFnOverloading() {
|
||||||
// just verifying that you can use this test definition syntax
|
// just verifying that you can use this test definition syntax
|
||||||
Deno.test("test fn overloading", (): void => {});
|
Deno.test("test fn overloading", () => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function nameOfTestCaseCantBeEmpty(): void {
|
unitTest(function nameOfTestCaseCantBeEmpty() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.test("", () => {});
|
Deno.test("", () => {});
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assert, assertEquals, assertThrows, unitTest } from "./test_util.ts";
|
import { assert, assertEquals, assertThrows, unitTest } from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(function btoaSuccess(): void {
|
unitTest(function btoaSuccess() {
|
||||||
const text = "hello world";
|
const text = "hello world";
|
||||||
const encoded = btoa(text);
|
const encoded = btoa(text);
|
||||||
assertEquals(encoded, "aGVsbG8gd29ybGQ=");
|
assertEquals(encoded, "aGVsbG8gd29ybGQ=");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function atobSuccess(): void {
|
unitTest(function atobSuccess() {
|
||||||
const encoded = "aGVsbG8gd29ybGQ=";
|
const encoded = "aGVsbG8gd29ybGQ=";
|
||||||
const decoded = atob(encoded);
|
const decoded = atob(encoded);
|
||||||
assertEquals(decoded, "hello world");
|
assertEquals(decoded, "hello world");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function atobWithAsciiWhitespace(): void {
|
unitTest(function atobWithAsciiWhitespace() {
|
||||||
const encodedList = [
|
const encodedList = [
|
||||||
" aGVsbG8gd29ybGQ=",
|
" aGVsbG8gd29ybGQ=",
|
||||||
" aGVsbG8gd29ybGQ=",
|
" aGVsbG8gd29ybGQ=",
|
||||||
|
@ -30,7 +30,7 @@ unitTest(function atobWithAsciiWhitespace(): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function atobThrows(): void {
|
unitTest(function atobThrows() {
|
||||||
let threw = false;
|
let threw = false;
|
||||||
try {
|
try {
|
||||||
atob("aGVsbG8gd29ybGQ==");
|
atob("aGVsbG8gd29ybGQ==");
|
||||||
|
@ -40,7 +40,7 @@ unitTest(function atobThrows(): void {
|
||||||
assert(threw);
|
assert(threw);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function atobThrows2(): void {
|
unitTest(function atobThrows2() {
|
||||||
let threw = false;
|
let threw = false;
|
||||||
try {
|
try {
|
||||||
atob("aGVsbG8gd29ybGQ===");
|
atob("aGVsbG8gd29ybGQ===");
|
||||||
|
@ -50,7 +50,7 @@ unitTest(function atobThrows2(): void {
|
||||||
assert(threw);
|
assert(threw);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function atobThrows3(): void {
|
unitTest(function atobThrows3() {
|
||||||
let threw = false;
|
let threw = false;
|
||||||
try {
|
try {
|
||||||
atob("foobar!!");
|
atob("foobar!!");
|
||||||
|
@ -65,14 +65,14 @@ unitTest(function atobThrows3(): void {
|
||||||
assert(threw);
|
assert(threw);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function btoaFailed(): void {
|
unitTest(function btoaFailed() {
|
||||||
const text = "你好";
|
const text = "你好";
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
btoa(text);
|
btoa(text);
|
||||||
}, DOMException);
|
}, DOMException);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function textDecoder2(): void {
|
unitTest(function textDecoder2() {
|
||||||
// deno-fmt-ignore
|
// deno-fmt-ignore
|
||||||
const fixture = new Uint8Array([
|
const fixture = new Uint8Array([
|
||||||
0xf0, 0x9d, 0x93, 0xbd,
|
0xf0, 0x9d, 0x93, 0xbd,
|
||||||
|
@ -86,13 +86,13 @@ unitTest(function textDecoder2(): void {
|
||||||
|
|
||||||
// ignoreBOM is tested through WPT
|
// ignoreBOM is tested through WPT
|
||||||
|
|
||||||
unitTest(function textDecoderASCII(): void {
|
unitTest(function textDecoderASCII() {
|
||||||
const fixture = new Uint8Array([0x89, 0x95, 0x9f, 0xbf]);
|
const fixture = new Uint8Array([0x89, 0x95, 0x9f, 0xbf]);
|
||||||
const decoder = new TextDecoder("ascii");
|
const decoder = new TextDecoder("ascii");
|
||||||
assertEquals(decoder.decode(fixture), "‰•Ÿ¿");
|
assertEquals(decoder.decode(fixture), "‰•Ÿ¿");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function textDecoderErrorEncoding(): void {
|
unitTest(function textDecoderErrorEncoding() {
|
||||||
let didThrow = false;
|
let didThrow = false;
|
||||||
try {
|
try {
|
||||||
new TextDecoder("Foo");
|
new TextDecoder("Foo");
|
||||||
|
@ -103,7 +103,7 @@ unitTest(function textDecoderErrorEncoding(): void {
|
||||||
assert(didThrow);
|
assert(didThrow);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function textEncoder(): void {
|
unitTest(function textEncoder() {
|
||||||
const fixture = "𝓽𝓮𝔁𝓽";
|
const fixture = "𝓽𝓮𝔁𝓽";
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
// deno-fmt-ignore
|
// deno-fmt-ignore
|
||||||
|
@ -115,7 +115,7 @@ unitTest(function textEncoder(): void {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function textEncodeInto(): void {
|
unitTest(function textEncodeInto() {
|
||||||
const fixture = "text";
|
const fixture = "text";
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const bytes = new Uint8Array(5);
|
const bytes = new Uint8Array(5);
|
||||||
|
@ -128,7 +128,7 @@ unitTest(function textEncodeInto(): void {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function textEncodeInto2(): void {
|
unitTest(function textEncodeInto2() {
|
||||||
const fixture = "𝓽𝓮𝔁𝓽";
|
const fixture = "𝓽𝓮𝔁𝓽";
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const bytes = new Uint8Array(17);
|
const bytes = new Uint8Array(17);
|
||||||
|
@ -144,7 +144,7 @@ unitTest(function textEncodeInto2(): void {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function textEncodeInto3(): void {
|
unitTest(function textEncodeInto3() {
|
||||||
const fixture = "𝓽𝓮𝔁𝓽";
|
const fixture = "𝓽𝓮𝔁𝓽";
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const bytes = new Uint8Array(5);
|
const bytes = new Uint8Array(5);
|
||||||
|
@ -157,7 +157,7 @@ unitTest(function textEncodeInto3(): void {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function loneSurrogateEncodeInto(): void {
|
unitTest(function loneSurrogateEncodeInto() {
|
||||||
const fixture = "lone𝄞\ud888surrogate";
|
const fixture = "lone𝄞\ud888surrogate";
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const bytes = new Uint8Array(20);
|
const bytes = new Uint8Array(20);
|
||||||
|
@ -174,7 +174,7 @@ unitTest(function loneSurrogateEncodeInto(): void {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function loneSurrogateEncodeInto2(): void {
|
unitTest(function loneSurrogateEncodeInto2() {
|
||||||
const fixture = "\ud800";
|
const fixture = "\ud800";
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const bytes = new Uint8Array(3);
|
const bytes = new Uint8Array(3);
|
||||||
|
@ -187,7 +187,7 @@ unitTest(function loneSurrogateEncodeInto2(): void {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function loneSurrogateEncodeInto3(): void {
|
unitTest(function loneSurrogateEncodeInto3() {
|
||||||
const fixture = "\udc00";
|
const fixture = "\udc00";
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const bytes = new Uint8Array(3);
|
const bytes = new Uint8Array(3);
|
||||||
|
@ -200,7 +200,7 @@ unitTest(function loneSurrogateEncodeInto3(): void {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function swappedSurrogatePairEncodeInto4(): void {
|
unitTest(function swappedSurrogatePairEncodeInto4() {
|
||||||
const fixture = "\udc00\ud800";
|
const fixture = "\udc00\ud800";
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const bytes = new Uint8Array(8);
|
const bytes = new Uint8Array(8);
|
||||||
|
@ -213,7 +213,7 @@ unitTest(function swappedSurrogatePairEncodeInto4(): void {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function textDecoderSharedUint8Array(): void {
|
unitTest(function textDecoderSharedUint8Array() {
|
||||||
const ab = new SharedArrayBuffer(6);
|
const ab = new SharedArrayBuffer(6);
|
||||||
const dataView = new DataView(ab);
|
const dataView = new DataView(ab);
|
||||||
const charCodeA = "A".charCodeAt(0);
|
const charCodeA = "A".charCodeAt(0);
|
||||||
|
@ -226,7 +226,7 @@ unitTest(function textDecoderSharedUint8Array(): void {
|
||||||
assertEquals(actual, "ABCDEF");
|
assertEquals(actual, "ABCDEF");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function textDecoderSharedInt32Array(): void {
|
unitTest(function textDecoderSharedInt32Array() {
|
||||||
const ab = new SharedArrayBuffer(8);
|
const ab = new SharedArrayBuffer(8);
|
||||||
const dataView = new DataView(ab);
|
const dataView = new DataView(ab);
|
||||||
const charCodeA = "A".charCodeAt(0);
|
const charCodeA = "A".charCodeAt(0);
|
||||||
|
@ -239,14 +239,14 @@ unitTest(function textDecoderSharedInt32Array(): void {
|
||||||
assertEquals(actual, "ABCDEFGH");
|
assertEquals(actual, "ABCDEFGH");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function toStringShouldBeWebCompatibility(): void {
|
unitTest(function toStringShouldBeWebCompatibility() {
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
assertEquals(encoder.toString(), "[object TextEncoder]");
|
assertEquals(encoder.toString(), "[object TextEncoder]");
|
||||||
|
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
assertEquals(decoder.toString(), "[object TextDecoder]");
|
assertEquals(decoder.toString(), "[object TextDecoder]");
|
||||||
});
|
});
|
||||||
unitTest(function textEncoderShouldCoerceToString(): void {
|
unitTest(function textEncoderShouldCoerceToString() {
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const fixutreText = "text";
|
const fixutreText = "text";
|
||||||
const fixture = {
|
const fixture = {
|
||||||
|
|
|
@ -9,11 +9,11 @@ import {
|
||||||
unitTest,
|
unitTest,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
unitTest(async function functionParameterBindingSuccess(): Promise<void> {
|
unitTest(async function functionParameterBindingSuccess() {
|
||||||
const promise = deferred();
|
const promise = deferred();
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
const nullProto = (newCount: number): void => {
|
const nullProto = (newCount: number) => {
|
||||||
count = newCount;
|
count = newCount;
|
||||||
promise.resolve();
|
promise.resolve();
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,7 @@ unitTest(async function functionParameterBindingSuccess(): Promise<void> {
|
||||||
assertEquals(count, 1);
|
assertEquals(count, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function stringifyAndEvalNonFunctions(): Promise<void> {
|
unitTest(async function stringifyAndEvalNonFunctions() {
|
||||||
// eval can only access global scope
|
// eval can only access global scope
|
||||||
const global = globalThis as unknown as {
|
const global = globalThis as unknown as {
|
||||||
globalPromise: ReturnType<typeof deferred>;
|
globalPromise: ReturnType<typeof deferred>;
|
||||||
|
@ -50,10 +50,10 @@ unitTest(async function stringifyAndEvalNonFunctions(): Promise<void> {
|
||||||
Reflect.deleteProperty(global, "globalCount");
|
Reflect.deleteProperty(global, "globalCount");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timeoutSuccess(): Promise<void> {
|
unitTest(async function timeoutSuccess() {
|
||||||
const promise = deferred();
|
const promise = deferred();
|
||||||
let count = 0;
|
let count = 0;
|
||||||
setTimeout((): void => {
|
setTimeout(() => {
|
||||||
count++;
|
count++;
|
||||||
promise.resolve();
|
promise.resolve();
|
||||||
}, 500);
|
}, 500);
|
||||||
|
@ -62,7 +62,7 @@ unitTest(async function timeoutSuccess(): Promise<void> {
|
||||||
assertEquals(count, 1);
|
assertEquals(count, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timeoutEvalNoScopeLeak(): Promise<void> {
|
unitTest(async function timeoutEvalNoScopeLeak() {
|
||||||
// eval can only access global scope
|
// eval can only access global scope
|
||||||
const global = globalThis as unknown as {
|
const global = globalThis as unknown as {
|
||||||
globalPromise: Deferred<Error>;
|
globalPromise: Deferred<Error>;
|
||||||
|
@ -83,11 +83,11 @@ unitTest(async function timeoutEvalNoScopeLeak(): Promise<void> {
|
||||||
Reflect.deleteProperty(global, "globalPromise");
|
Reflect.deleteProperty(global, "globalPromise");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timeoutArgs(): Promise<void> {
|
unitTest(async function timeoutArgs() {
|
||||||
const promise = deferred();
|
const promise = deferred();
|
||||||
const arg = 1;
|
const arg = 1;
|
||||||
setTimeout(
|
setTimeout(
|
||||||
(a, b, c): void => {
|
(a, b, c) => {
|
||||||
assertEquals(a, arg);
|
assertEquals(a, arg);
|
||||||
assertEquals(b, arg.toString());
|
assertEquals(b, arg.toString());
|
||||||
assertEquals(c, [arg]);
|
assertEquals(c, [arg]);
|
||||||
|
@ -101,9 +101,9 @@ unitTest(async function timeoutArgs(): Promise<void> {
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timeoutCancelSuccess(): Promise<void> {
|
unitTest(async function timeoutCancelSuccess() {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const id = setTimeout((): void => {
|
const id = setTimeout(() => {
|
||||||
count++;
|
count++;
|
||||||
}, 1);
|
}, 1);
|
||||||
// Cancelled, count should not increment
|
// Cancelled, count should not increment
|
||||||
|
@ -112,7 +112,7 @@ unitTest(async function timeoutCancelSuccess(): Promise<void> {
|
||||||
assertEquals(count, 0);
|
assertEquals(count, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timeoutCancelMultiple(): Promise<void> {
|
unitTest(async function timeoutCancelMultiple() {
|
||||||
function uncalled(): never {
|
function uncalled(): never {
|
||||||
throw new Error("This function should not be called.");
|
throw new Error("This function should not be called.");
|
||||||
}
|
}
|
||||||
|
@ -137,11 +137,11 @@ unitTest(async function timeoutCancelMultiple(): Promise<void> {
|
||||||
await delay(50);
|
await delay(50);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timeoutCancelInvalidSilentFail(): Promise<void> {
|
unitTest(async function timeoutCancelInvalidSilentFail() {
|
||||||
// Expect no panic
|
// Expect no panic
|
||||||
const promise = deferred();
|
const promise = deferred();
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const id = setTimeout((): void => {
|
const id = setTimeout(() => {
|
||||||
count++;
|
count++;
|
||||||
// Should have no effect
|
// Should have no effect
|
||||||
clearTimeout(id);
|
clearTimeout(id);
|
||||||
|
@ -154,10 +154,10 @@ unitTest(async function timeoutCancelInvalidSilentFail(): Promise<void> {
|
||||||
clearTimeout(2147483647);
|
clearTimeout(2147483647);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function intervalSuccess(): Promise<void> {
|
unitTest(async function intervalSuccess() {
|
||||||
const promise = deferred();
|
const promise = deferred();
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const id = setInterval((): void => {
|
const id = setInterval(() => {
|
||||||
count++;
|
count++;
|
||||||
clearInterval(id);
|
clearInterval(id);
|
||||||
promise.resolve();
|
promise.resolve();
|
||||||
|
@ -172,9 +172,9 @@ unitTest(async function intervalSuccess(): Promise<void> {
|
||||||
await delay(0);
|
await delay(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function intervalCancelSuccess(): Promise<void> {
|
unitTest(async function intervalCancelSuccess() {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const id = setInterval((): void => {
|
const id = setInterval(() => {
|
||||||
count++;
|
count++;
|
||||||
}, 1);
|
}, 1);
|
||||||
clearInterval(id);
|
clearInterval(id);
|
||||||
|
@ -182,10 +182,10 @@ unitTest(async function intervalCancelSuccess(): Promise<void> {
|
||||||
assertEquals(count, 0);
|
assertEquals(count, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function intervalOrdering(): Promise<void> {
|
unitTest(async function intervalOrdering() {
|
||||||
const timers: number[] = [];
|
const timers: number[] = [];
|
||||||
let timeouts = 0;
|
let timeouts = 0;
|
||||||
function onTimeout(): void {
|
function onTimeout() {
|
||||||
++timeouts;
|
++timeouts;
|
||||||
for (let i = 1; i < timers.length; i++) {
|
for (let i = 1; i < timers.length; i++) {
|
||||||
clearTimeout(timers[i]);
|
clearTimeout(timers[i]);
|
||||||
|
@ -198,26 +198,24 @@ unitTest(async function intervalOrdering(): Promise<void> {
|
||||||
assertEquals(timeouts, 1);
|
assertEquals(timeouts, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function intervalCancelInvalidSilentFail(): void {
|
unitTest(function intervalCancelInvalidSilentFail() {
|
||||||
// Should silently fail (no panic)
|
// Should silently fail (no panic)
|
||||||
clearInterval(2147483647);
|
clearInterval(2147483647);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function fireCallbackImmediatelyWhenDelayOverMaxValue(): Promise<
|
unitTest(async function fireCallbackImmediatelyWhenDelayOverMaxValue() {
|
||||||
void
|
|
||||||
> {
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
setTimeout((): void => {
|
setTimeout(() => {
|
||||||
count++;
|
count++;
|
||||||
}, 2 ** 31);
|
}, 2 ** 31);
|
||||||
await delay(1);
|
await delay(1);
|
||||||
assertEquals(count, 1);
|
assertEquals(count, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timeoutCallbackThis(): Promise<void> {
|
unitTest(async function timeoutCallbackThis() {
|
||||||
const promise = deferred();
|
const promise = deferred();
|
||||||
const obj = {
|
const obj = {
|
||||||
foo(): void {
|
foo() {
|
||||||
assertEquals(this, window);
|
assertEquals(this, window);
|
||||||
promise.resolve();
|
promise.resolve();
|
||||||
},
|
},
|
||||||
|
@ -226,7 +224,7 @@ unitTest(async function timeoutCallbackThis(): Promise<void> {
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timeoutBindThis(): Promise<void> {
|
unitTest(async function timeoutBindThis() {
|
||||||
const thisCheckPassed = [null, undefined, window, globalThis];
|
const thisCheckPassed = [null, undefined, window, globalThis];
|
||||||
|
|
||||||
const thisCheckFailed = [
|
const thisCheckFailed = [
|
||||||
|
@ -237,7 +235,7 @@ unitTest(async function timeoutBindThis(): Promise<void> {
|
||||||
{},
|
{},
|
||||||
[],
|
[],
|
||||||
"foo",
|
"foo",
|
||||||
(): void => {},
|
() => {},
|
||||||
Object.prototype,
|
Object.prototype,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -274,7 +272,7 @@ unitTest(async function timeoutBindThis(): Promise<void> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function clearTimeoutShouldConvertToNumber(): void {
|
unitTest(function clearTimeoutShouldConvertToNumber() {
|
||||||
let called = false;
|
let called = false;
|
||||||
const obj = {
|
const obj = {
|
||||||
valueOf(): number {
|
valueOf(): number {
|
||||||
|
@ -286,10 +284,10 @@ unitTest(function clearTimeoutShouldConvertToNumber(): void {
|
||||||
assert(called);
|
assert(called);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function setTimeoutShouldThrowWithBigint(): void {
|
unitTest(function setTimeoutShouldThrowWithBigint() {
|
||||||
let hasThrown = 0;
|
let hasThrown = 0;
|
||||||
try {
|
try {
|
||||||
setTimeout((): void => {}, (1n as unknown) as number);
|
setTimeout(() => {}, (1n as unknown) as number);
|
||||||
hasThrown = 1;
|
hasThrown = 1;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof TypeError) {
|
if (err instanceof TypeError) {
|
||||||
|
@ -301,7 +299,7 @@ unitTest(function setTimeoutShouldThrowWithBigint(): void {
|
||||||
assertEquals(hasThrown, 2);
|
assertEquals(hasThrown, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function clearTimeoutShouldThrowWithBigint(): void {
|
unitTest(function clearTimeoutShouldThrowWithBigint() {
|
||||||
let hasThrown = 0;
|
let hasThrown = 0;
|
||||||
try {
|
try {
|
||||||
clearTimeout((1n as unknown) as number);
|
clearTimeout((1n as unknown) as number);
|
||||||
|
@ -316,23 +314,23 @@ unitTest(function clearTimeoutShouldThrowWithBigint(): void {
|
||||||
assertEquals(hasThrown, 2);
|
assertEquals(hasThrown, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function testFunctionName(): void {
|
unitTest(function testFunctionName() {
|
||||||
assertEquals(clearTimeout.name, "clearTimeout");
|
assertEquals(clearTimeout.name, "clearTimeout");
|
||||||
assertEquals(clearInterval.name, "clearInterval");
|
assertEquals(clearInterval.name, "clearInterval");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function testFunctionParamsLength(): void {
|
unitTest(function testFunctionParamsLength() {
|
||||||
assertEquals(setTimeout.length, 1);
|
assertEquals(setTimeout.length, 1);
|
||||||
assertEquals(setInterval.length, 1);
|
assertEquals(setInterval.length, 1);
|
||||||
assertEquals(clearTimeout.length, 0);
|
assertEquals(clearTimeout.length, 0);
|
||||||
assertEquals(clearInterval.length, 0);
|
assertEquals(clearInterval.length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(function clearTimeoutAndClearIntervalNotBeEquals(): void {
|
unitTest(function clearTimeoutAndClearIntervalNotBeEquals() {
|
||||||
assertNotEquals(clearTimeout, clearInterval);
|
assertNotEquals(clearTimeout, clearInterval);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timerMaxCpuBug(): Promise<void> {
|
unitTest(async function timerMaxCpuBug() {
|
||||||
// There was a bug where clearing a timeout would cause Deno to use 100% CPU.
|
// There was a bug where clearing a timeout would cause Deno to use 100% CPU.
|
||||||
clearTimeout(setTimeout(() => {}, 1000));
|
clearTimeout(setTimeout(() => {}, 1000));
|
||||||
// We can check this by counting how many ops have triggered in the interim.
|
// We can check this by counting how many ops have triggered in the interim.
|
||||||
|
@ -343,7 +341,7 @@ unitTest(async function timerMaxCpuBug(): Promise<void> {
|
||||||
assert(opsDispatched_ - opsDispatched < 10);
|
assert(opsDispatched_ - opsDispatched < 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timerBasicMicrotaskOrdering(): Promise<void> {
|
unitTest(async function timerBasicMicrotaskOrdering() {
|
||||||
let s = "";
|
let s = "";
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const promise = deferred();
|
const promise = deferred();
|
||||||
|
@ -367,7 +365,7 @@ unitTest(async function timerBasicMicrotaskOrdering(): Promise<void> {
|
||||||
assertEquals(s, "deno");
|
assertEquals(s, "deno");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timerNestedMicrotaskOrdering(): Promise<void> {
|
unitTest(async function timerNestedMicrotaskOrdering() {
|
||||||
let s = "";
|
let s = "";
|
||||||
const promise = deferred();
|
const promise = deferred();
|
||||||
s += "0";
|
s += "0";
|
||||||
|
@ -407,7 +405,7 @@ unitTest(function testQueueMicrotask() {
|
||||||
assertEquals(typeof queueMicrotask, "function");
|
assertEquals(typeof queueMicrotask, "function");
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest(async function timerIgnoresDateOverride(): Promise<void> {
|
unitTest(async function timerIgnoresDateOverride() {
|
||||||
const OriginalDate = Date;
|
const OriginalDate = Date;
|
||||||
const promise = deferred();
|
const promise = deferred();
|
||||||
let hasThrown = 0;
|
let hasThrown = 0;
|
||||||
|
@ -416,7 +414,7 @@ unitTest(async function timerIgnoresDateOverride(): Promise<void> {
|
||||||
promise.reject("global Date override used over original Date object");
|
promise.reject("global Date override used over original Date object");
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
const DateOverride = (): void => {
|
const DateOverride = () => {
|
||||||
overrideCalled();
|
overrideCalled();
|
||||||
};
|
};
|
||||||
globalThis.Date = DateOverride as DateConstructor;
|
globalThis.Date = DateOverride as DateConstructor;
|
||||||
|
@ -441,7 +439,7 @@ unitTest(async function timerIgnoresDateOverride(): Promise<void> {
|
||||||
assertEquals(hasThrown, 1);
|
assertEquals(hasThrown, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
unitTest({ perms: { hrtime: true } }, function sleepSync(): void {
|
unitTest({ perms: { hrtime: true } }, function sleepSync() {
|
||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
Deno.sleepSync(10);
|
Deno.sleepSync(10);
|
||||||
const after = performance.now();
|
const after = performance.now();
|
||||||
|
@ -450,7 +448,7 @@ unitTest({ perms: { hrtime: true } }, function sleepSync(): void {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { hrtime: true } },
|
{ perms: { hrtime: true } },
|
||||||
async function sleepSyncShorterPromise(): Promise<void> {
|
async function sleepSyncShorterPromise() {
|
||||||
const perf = performance;
|
const perf = performance;
|
||||||
const short = 5;
|
const short = 5;
|
||||||
const long = 10;
|
const long = 10;
|
||||||
|
@ -469,7 +467,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { hrtime: true } },
|
{ perms: { hrtime: true } },
|
||||||
async function sleepSyncLongerPromise(): Promise<void> {
|
async function sleepSyncLongerPromise() {
|
||||||
const perf = performance;
|
const perf = performance;
|
||||||
const short = 5;
|
const short = 5;
|
||||||
const long = 10;
|
const long = 10;
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { TextProtoReader } from "../../../test_util/std/textproto/mod.ts";
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
|
|
||||||
async function sleep(msec: number): Promise<void> {
|
async function sleep(msec: number) {
|
||||||
await new Promise((res, _rej) => setTimeout(res, msec));
|
await new Promise((res, _rej) => setTimeout(res, msec));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ function unreachable(): never {
|
||||||
throw new Error("Unreachable code reached");
|
throw new Error("Unreachable code reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
unitTest(async function connectTLSNoPerm(): Promise<void> {
|
unitTest(async function connectTLSNoPerm() {
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.connectTls({ hostname: "github.com", port: 443 });
|
await Deno.connectTls({ hostname: "github.com", port: 443 });
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
|
@ -32,7 +32,7 @@ unitTest(async function connectTLSNoPerm(): Promise<void> {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function connectTLSInvalidHost(): Promise<void> {
|
async function connectTLSInvalidHost() {
|
||||||
const listener = await Deno.listenTls({
|
const listener = await Deno.listenTls({
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
port: 3567,
|
port: 3567,
|
||||||
|
@ -48,7 +48,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(async function connectTLSCertFileNoReadPerm(): Promise<void> {
|
unitTest(async function connectTLSCertFileNoReadPerm() {
|
||||||
await assertThrowsAsync(async () => {
|
await assertThrowsAsync(async () => {
|
||||||
await Deno.connectTls({
|
await Deno.connectTls({
|
||||||
hostname: "github.com",
|
hostname: "github.com",
|
||||||
|
@ -60,7 +60,7 @@ unitTest(async function connectTLSCertFileNoReadPerm(): Promise<void> {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
function listenTLSNonExistentCertKeyFiles(): void {
|
function listenTLSNonExistentCertKeyFiles() {
|
||||||
const options = {
|
const options = {
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
port: 3500,
|
port: 3500,
|
||||||
|
@ -84,7 +84,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest({ perms: { net: true } }, function listenTLSNoReadPerm(): void {
|
unitTest({ perms: { net: true } }, function listenTLSNoReadPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.listenTls({
|
Deno.listenTls({
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
|
@ -99,7 +99,7 @@ unitTest(
|
||||||
{
|
{
|
||||||
perms: { read: true, write: true, net: true },
|
perms: { read: true, write: true, net: true },
|
||||||
},
|
},
|
||||||
function listenTLSEmptyKeyFile(): void {
|
function listenTLSEmptyKeyFile() {
|
||||||
const options = {
|
const options = {
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
port: 3500,
|
port: 3500,
|
||||||
|
@ -124,7 +124,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, write: true, net: true } },
|
{ perms: { read: true, write: true, net: true } },
|
||||||
function listenTLSEmptyCertFile(): void {
|
function listenTLSEmptyCertFile() {
|
||||||
const options = {
|
const options = {
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
port: 3500,
|
port: 3500,
|
||||||
|
@ -149,7 +149,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function dialAndListenTLS(): Promise<void> {
|
async function dialAndListenTLS() {
|
||||||
const resolvable = deferred();
|
const resolvable = deferred();
|
||||||
const hostname = "localhost";
|
const hostname = "localhost";
|
||||||
const port = 3500;
|
const port = 3500;
|
||||||
|
@ -166,7 +166,7 @@ unitTest(
|
||||||
);
|
);
|
||||||
|
|
||||||
listener.accept().then(
|
listener.accept().then(
|
||||||
async (conn): Promise<void> => {
|
async (conn) => {
|
||||||
assert(conn.remoteAddr != null);
|
assert(conn.remoteAddr != null);
|
||||||
assert(conn.localAddr != null);
|
assert(conn.localAddr != null);
|
||||||
await conn.write(response);
|
await conn.write(response);
|
||||||
|
@ -242,7 +242,7 @@ async function sendThenCloseWriteThenReceive(
|
||||||
conn: Deno.Conn,
|
conn: Deno.Conn,
|
||||||
chunkCount: number,
|
chunkCount: number,
|
||||||
chunkSize: number,
|
chunkSize: number,
|
||||||
): Promise<void> {
|
) {
|
||||||
const byteCount = chunkCount * chunkSize;
|
const byteCount = chunkCount * chunkSize;
|
||||||
const buf = new Uint8Array(chunkSize); // Note: buf is size of _chunk_.
|
const buf = new Uint8Array(chunkSize); // Note: buf is size of _chunk_.
|
||||||
let n: number;
|
let n: number;
|
||||||
|
@ -274,7 +274,7 @@ async function receiveThenSend(
|
||||||
conn: Deno.Conn,
|
conn: Deno.Conn,
|
||||||
chunkCount: number,
|
chunkCount: number,
|
||||||
chunkSize: number,
|
chunkSize: number,
|
||||||
): Promise<void> {
|
) {
|
||||||
const byteCount = chunkCount * chunkSize;
|
const byteCount = chunkCount * chunkSize;
|
||||||
const buf = new Uint8Array(byteCount); // Note: buf size equals `byteCount`.
|
const buf = new Uint8Array(byteCount); // Note: buf size equals `byteCount`.
|
||||||
let n: number;
|
let n: number;
|
||||||
|
@ -301,7 +301,7 @@ async function receiveThenSend(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsServerStreamHalfCloseSendOneByte(): Promise<void> {
|
async function tlsServerStreamHalfCloseSendOneByte() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendThenCloseWriteThenReceive(serverConn, 1, 1),
|
sendThenCloseWriteThenReceive(serverConn, 1, 1),
|
||||||
|
@ -312,7 +312,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsClientStreamHalfCloseSendOneByte(): Promise<void> {
|
async function tlsClientStreamHalfCloseSendOneByte() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendThenCloseWriteThenReceive(clientConn, 1, 1),
|
sendThenCloseWriteThenReceive(clientConn, 1, 1),
|
||||||
|
@ -323,7 +323,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsServerStreamHalfCloseSendOneChunk(): Promise<void> {
|
async function tlsServerStreamHalfCloseSendOneChunk() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendThenCloseWriteThenReceive(serverConn, 1, 1 << 20 /* 1 MB */),
|
sendThenCloseWriteThenReceive(serverConn, 1, 1 << 20 /* 1 MB */),
|
||||||
|
@ -334,7 +334,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsClientStreamHalfCloseSendOneChunk(): Promise<void> {
|
async function tlsClientStreamHalfCloseSendOneChunk() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendThenCloseWriteThenReceive(clientConn, 1, 1 << 20 /* 1 MB */),
|
sendThenCloseWriteThenReceive(clientConn, 1, 1 << 20 /* 1 MB */),
|
||||||
|
@ -345,7 +345,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsServerStreamHalfCloseSendManyBytes(): Promise<void> {
|
async function tlsServerStreamHalfCloseSendManyBytes() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendThenCloseWriteThenReceive(serverConn, 100, 1),
|
sendThenCloseWriteThenReceive(serverConn, 100, 1),
|
||||||
|
@ -356,7 +356,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsClientStreamHalfCloseSendManyBytes(): Promise<void> {
|
async function tlsClientStreamHalfCloseSendManyBytes() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendThenCloseWriteThenReceive(clientConn, 100, 1),
|
sendThenCloseWriteThenReceive(clientConn, 100, 1),
|
||||||
|
@ -367,7 +367,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsServerStreamHalfCloseSendManyChunks(): Promise<void> {
|
async function tlsServerStreamHalfCloseSendManyChunks() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendThenCloseWriteThenReceive(serverConn, 100, 1 << 16 /* 64 kB */),
|
sendThenCloseWriteThenReceive(serverConn, 100, 1 << 16 /* 64 kB */),
|
||||||
|
@ -378,7 +378,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsClientStreamHalfCloseSendManyChunks(): Promise<void> {
|
async function tlsClientStreamHalfCloseSendManyChunks() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendThenCloseWriteThenReceive(clientConn, 100, 1 << 16 /* 64 kB */),
|
sendThenCloseWriteThenReceive(clientConn, 100, 1 << 16 /* 64 kB */),
|
||||||
|
@ -387,7 +387,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
async function sendAlotReceiveNothing(conn: Deno.Conn): Promise<void> {
|
async function sendAlotReceiveNothing(conn: Deno.Conn) {
|
||||||
// Start receive op.
|
// Start receive op.
|
||||||
const readBuf = new Uint8Array(1024);
|
const readBuf = new Uint8Array(1024);
|
||||||
const readPromise = conn.read(readBuf);
|
const readPromise = conn.read(readBuf);
|
||||||
|
@ -410,7 +410,7 @@ async function sendAlotReceiveNothing(conn: Deno.Conn): Promise<void> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function receiveAlotSendNothing(conn: Deno.Conn): Promise<void> {
|
async function receiveAlotSendNothing(conn: Deno.Conn) {
|
||||||
const readBuf = new Uint8Array(1024);
|
const readBuf = new Uint8Array(1024);
|
||||||
let n: number | null;
|
let n: number | null;
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ async function receiveAlotSendNothing(conn: Deno.Conn): Promise<void> {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsServerStreamCancelRead(): Promise<void> {
|
async function tlsServerStreamCancelRead() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendAlotReceiveNothing(serverConn),
|
sendAlotReceiveNothing(serverConn),
|
||||||
|
@ -439,7 +439,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsClientStreamCancelRead(): Promise<void> {
|
async function tlsClientStreamCancelRead() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendAlotReceiveNothing(clientConn),
|
sendAlotReceiveNothing(clientConn),
|
||||||
|
@ -448,7 +448,7 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
async function sendReceiveEmptyBuf(conn: Deno.Conn): Promise<void> {
|
async function sendReceiveEmptyBuf(conn: Deno.Conn) {
|
||||||
const byteBuf = new Uint8Array([1]);
|
const byteBuf = new Uint8Array([1]);
|
||||||
const emptyBuf = new Uint8Array(0);
|
const emptyBuf = new Uint8Array(0);
|
||||||
let n: number | null;
|
let n: number | null;
|
||||||
|
@ -485,7 +485,7 @@ async function sendReceiveEmptyBuf(conn: Deno.Conn): Promise<void> {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsStreamSendReceiveEmptyBuf(): Promise<void> {
|
async function tlsStreamSendReceiveEmptyBuf() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendReceiveEmptyBuf(serverConn),
|
sendReceiveEmptyBuf(serverConn),
|
||||||
|
@ -494,12 +494,12 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
function immediateClose(conn: Deno.Conn): Promise<void> {
|
function immediateClose(conn: Deno.Conn) {
|
||||||
conn.close();
|
conn.close();
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function closeWriteAndClose(conn: Deno.Conn): Promise<void> {
|
async function closeWriteAndClose(conn: Deno.Conn) {
|
||||||
await conn.closeWrite();
|
await conn.closeWrite();
|
||||||
|
|
||||||
if (await conn.read(new Uint8Array(1)) !== null) {
|
if (await conn.read(new Uint8Array(1)) !== null) {
|
||||||
|
@ -511,7 +511,7 @@ async function closeWriteAndClose(conn: Deno.Conn): Promise<void> {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsServerStreamImmediateClose(): Promise<void> {
|
async function tlsServerStreamImmediateClose() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
immediateClose(serverConn),
|
immediateClose(serverConn),
|
||||||
|
@ -522,7 +522,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsClientStreamImmediateClose(): Promise<void> {
|
async function tlsClientStreamImmediateClose() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
closeWriteAndClose(serverConn),
|
closeWriteAndClose(serverConn),
|
||||||
|
@ -533,7 +533,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function tlsClientAndServerStreamImmediateClose(): Promise<void> {
|
async function tlsClientAndServerStreamImmediateClose() {
|
||||||
const [serverConn, clientConn] = await tlsPair();
|
const [serverConn, clientConn] = await tlsPair();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
immediateClose(serverConn),
|
immediateClose(serverConn),
|
||||||
|
@ -547,7 +547,7 @@ async function tlsWithTcpFailureTestImpl(
|
||||||
cipherByteCount: number,
|
cipherByteCount: number,
|
||||||
failureMode: "corruption" | "shutdown",
|
failureMode: "corruption" | "shutdown",
|
||||||
reverse: boolean,
|
reverse: boolean,
|
||||||
): Promise<void> {
|
) {
|
||||||
const tlsPort = getPort();
|
const tlsPort = getPort();
|
||||||
const tlsListener = Deno.listenTls({
|
const tlsListener = Deno.listenTls({
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
|
@ -723,7 +723,7 @@ async function tlsWithTcpFailureTestImpl(
|
||||||
conn: Deno.Conn,
|
conn: Deno.Conn,
|
||||||
byte: number,
|
byte: number,
|
||||||
count: number,
|
count: number,
|
||||||
): Promise<void> {
|
) {
|
||||||
let buf = new Uint8Array(1 << 12 /* 4 kB */);
|
let buf = new Uint8Array(1 << 12 /* 4 kB */);
|
||||||
buf.fill(byte);
|
buf.fill(byte);
|
||||||
|
|
||||||
|
@ -739,7 +739,7 @@ async function tlsWithTcpFailureTestImpl(
|
||||||
conn: Deno.Conn,
|
conn: Deno.Conn,
|
||||||
byte: number,
|
byte: number,
|
||||||
count: number,
|
count: number,
|
||||||
): Promise<void> {
|
) {
|
||||||
let buf = new Uint8Array(1 << 12 /* 4 kB */);
|
let buf = new Uint8Array(1 << 12 /* 4 kB */);
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
buf = buf.subarray(0, Math.min(buf.length, count));
|
buf = buf.subarray(0, Math.min(buf.length, count));
|
||||||
|
@ -761,7 +761,7 @@ async function tlsWithTcpFailureTestImpl(
|
||||||
sink: Deno.Conn,
|
sink: Deno.Conn,
|
||||||
count: number,
|
count: number,
|
||||||
interruptPromise: Deferred<void>,
|
interruptPromise: Deferred<void>,
|
||||||
): Promise<void> {
|
) {
|
||||||
let buf = new Uint8Array(1 << 12 /* 4 kB */);
|
let buf = new Uint8Array(1 << 12 /* 4 kB */);
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
buf = buf.subarray(0, Math.min(buf.length, count));
|
buf = buf.subarray(0, Math.min(buf.length, count));
|
||||||
|
@ -913,7 +913,7 @@ async function curl(url: string): Promise<string> {
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true, run: true } },
|
{ perms: { read: true, net: true, run: true } },
|
||||||
async function curlFakeHttpsServer(): Promise<void> {
|
async function curlFakeHttpsServer() {
|
||||||
const port = getPort();
|
const port = getPort();
|
||||||
const listener = createHttpsListener(port);
|
const listener = createHttpsListener(port);
|
||||||
|
|
||||||
|
@ -937,7 +937,7 @@ unitTest(
|
||||||
|
|
||||||
unitTest(
|
unitTest(
|
||||||
{ perms: { read: true, net: true } },
|
{ perms: { read: true, net: true } },
|
||||||
async function startTls(): Promise<void> {
|
async function startTls() {
|
||||||
const hostname = "smtp.gmail.com";
|
const hostname = "smtp.gmail.com";
|
||||||
const port = 587;
|
const port = 587;
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue