1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-03 04:48:52 -05:00

Upgrade deno_std (#1892)

A major API change was that asserts are imported from testing/asserts.ts
now rather than testing/mod.ts and assertEqual as renamed to
assertEquals to conform to what is most common in JavaScript.
This commit is contained in:
Ryan Dahl 2019-03-06 20:48:46 -05:00 committed by GitHub
parent de1a10e5f7
commit c42a9d7370
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 753 additions and 734 deletions

View file

@ -1,11 +1,11 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assert, assertEqual } from "./test_util.ts"; import { test, assert, assertEquals } from "./test_util.ts";
test(function blobString() { test(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]);
assertEqual(b2.size, b1.size + str.length); assertEquals(b2.size, b1.size + str.length);
}); });
test(function blobBuffer() { test(function blobBuffer() {
@ -13,23 +13,23 @@ test(function blobBuffer() {
const u8 = new Uint8Array(buffer); const u8 = new Uint8Array(buffer);
const f1 = new Float32Array(buffer); const f1 = new Float32Array(buffer);
const b1 = new Blob([buffer, u8]); const b1 = new Blob([buffer, u8]);
assertEqual(b1.size, 2 * u8.length); assertEquals(b1.size, 2 * u8.length);
const b2 = new Blob([b1, f1]); const b2 = new Blob([b1, f1]);
assertEqual(b2.size, 3 * u8.length); assertEquals(b2.size, 3 * u8.length);
}); });
test(function blobSlice() { test(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);
assertEqual(b1.size, 3); assertEquals(b1.size, 3);
assertEqual(b1.type, "text/html"); assertEquals(b1.type, "text/html");
const b2 = blob.slice(-1, 3); const b2 = blob.slice(-1, 3);
assertEqual(b2.size, 0); assertEquals(b2.size, 0);
const b3 = blob.slice(100, 3); const b3 = blob.slice(100, 3);
assertEqual(b3.size, 0); assertEquals(b3.size, 0);
const b4 = blob.slice(0, 10); const b4 = blob.slice(0, 10);
assertEqual(b4.size, blob.size); assertEquals(b4.size, blob.size);
}); });
// TODO(qti3e) Test the stored data in a Blob after implementing FileReader API. // TODO(qti3e) Test the stored data in a Blob after implementing FileReader API.

View file

@ -3,7 +3,7 @@
// This code has been ported almost directly from Go's src/bytes/buffer_test.go // This code has been ported almost directly from Go's src/bytes/buffer_test.go
// Copyright 2009 The Go Authors. All rights reserved. BSD license. // Copyright 2009 The Go Authors. All rights reserved. BSD license.
// https://github.com/golang/go/blob/master/LICENSE // https://github.com/golang/go/blob/master/LICENSE
import { assertEqual, test } from "./test_util.ts"; import { assertEquals, test } from "./test_util.ts";
const { Buffer, readAll } = Deno; const { Buffer, readAll } = Deno;
type Buffer = Deno.Buffer; type Buffer = Deno.Buffer;
@ -26,12 +26,12 @@ function init() {
function check(buf: Deno.Buffer, s: string) { function check(buf: Deno.Buffer, s: string) {
const bytes = buf.bytes(); const bytes = buf.bytes();
assertEqual(buf.length, bytes.byteLength); assertEquals(buf.length, bytes.byteLength);
const decoder = new TextDecoder(); const decoder = new TextDecoder();
const bytesStr = decoder.decode(bytes); const bytesStr = decoder.decode(bytes);
assertEqual(bytesStr, s); assertEquals(bytesStr, s);
assertEqual(buf.length, buf.toString().length); assertEquals(buf.length, buf.toString().length);
assertEqual(buf.length, s.length); assertEquals(buf.length, s.length);
} }
// Fill buf through n writes of byte slice fub. // Fill buf through n writes of byte slice fub.
@ -46,7 +46,7 @@ async function fillBytes(
check(buf, s); check(buf, s);
for (; n > 0; n--) { for (; n > 0; n--) {
let m = await buf.write(fub); let m = await buf.write(fub);
assertEqual(m, fub.byteLength); assertEquals(m, fub.byteLength);
const decoder = new TextDecoder(); const decoder = new TextDecoder();
s += decoder.decode(fub); s += decoder.decode(fub);
check(buf, s); check(buf, s);
@ -88,15 +88,15 @@ test(async function bufferBasicOperations() {
check(buf, ""); check(buf, "");
let n = await buf.write(testBytes.subarray(0, 1)); let n = await buf.write(testBytes.subarray(0, 1));
assertEqual(n, 1); assertEquals(n, 1);
check(buf, "a"); check(buf, "a");
n = await buf.write(testBytes.subarray(1, 2)); n = await buf.write(testBytes.subarray(1, 2));
assertEqual(n, 1); assertEquals(n, 1);
check(buf, "ab"); check(buf, "ab");
n = await buf.write(testBytes.subarray(2, 26)); n = await buf.write(testBytes.subarray(2, 26));
assertEqual(n, 24); assertEquals(n, 24);
check(buf, testString.slice(0, 26)); check(buf, testString.slice(0, 26));
buf.truncate(26); buf.truncate(26);
@ -119,8 +119,8 @@ test(async function bufferReadEmptyAtEOF() {
let buf = new Buffer(); let buf = new Buffer();
const zeroLengthTmp = new Uint8Array(0); const zeroLengthTmp = new Uint8Array(0);
let result = await buf.read(zeroLengthTmp); let result = await buf.read(zeroLengthTmp);
assertEqual(result.nread, 0); assertEquals(result.nread, 0);
assertEqual(result.eof, false); assertEquals(result.eof, false);
}); });
test(async function bufferLargeByteWrites() { test(async function bufferLargeByteWrites() {
@ -149,8 +149,8 @@ test(async function bufferTooLargeByteWrites() {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.TooLarge); assertEquals(err.kind, Deno.ErrorKind.TooLarge);
assertEqual(err.name, "TooLarge"); assertEquals(err.name, "TooLarge");
}); });
test(async function bufferLargeByteReads() { test(async function bufferLargeByteReads() {
@ -166,7 +166,7 @@ test(async function bufferLargeByteReads() {
test(function bufferCapWithPreallocatedSlice() { test(function bufferCapWithPreallocatedSlice() {
const buf = new Buffer(new ArrayBuffer(10)); const buf = new Buffer(new ArrayBuffer(10));
assertEqual(buf.capacity, 10); assertEquals(buf.capacity, 10);
}); });
test(async function bufferReadFrom() { test(async function bufferReadFrom() {
@ -187,7 +187,7 @@ test(async function bufferReadFrom() {
}); });
function repeat(c: string, bytes: number): Uint8Array { function repeat(c: string, bytes: number): Uint8Array {
assertEqual(c.length, 1); assertEquals(c.length, 1);
const ui8 = new Uint8Array(bytes); const ui8 = new Uint8Array(bytes);
ui8.fill(c.charCodeAt(0)); ui8.fill(c.charCodeAt(0));
return ui8; return ui8;
@ -205,11 +205,11 @@ test(async function bufferTestGrow() {
const yBytes = repeat("y", growLen); const yBytes = repeat("y", growLen);
await buf.write(yBytes); await buf.write(yBytes);
// Check that buffer has correct data. // Check that buffer has correct data.
assertEqual( assertEquals(
buf.bytes().subarray(0, startLen - nread), buf.bytes().subarray(0, startLen - nread),
xBytes.subarray(nread) xBytes.subarray(nread)
); );
assertEqual( assertEquals(
buf.bytes().subarray(startLen - nread, startLen - nread + growLen), buf.bytes().subarray(startLen - nread, startLen - nread + growLen),
yBytes yBytes
); );
@ -221,8 +221,8 @@ test(async function testReadAll() {
init(); init();
const reader = new Buffer(testBytes.buffer as ArrayBuffer); const reader = new Buffer(testBytes.buffer as ArrayBuffer);
const actualBytes = await readAll(reader); const actualBytes = await readAll(reader);
assertEqual(testBytes.byteLength, actualBytes.byteLength); assertEquals(testBytes.byteLength, actualBytes.byteLength);
for (let i = 0; i < testBytes.length; ++i) { for (let i = 0; i < testBytes.length; ++i) {
assertEqual(testBytes[i], actualBytes[i]); assertEquals(testBytes[i], actualBytes[i]);
} }
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assertEqual } from "./test_util.ts"; import { testPerm, assertEquals } from "./test_util.ts";
const isNotWindows = Deno.build.os !== "win"; const isNotWindows = Deno.build.os !== "win";
@ -16,7 +16,7 @@ testPerm({ read: true, write: true }, function chmodSyncSuccess() {
// Check success when not on windows // Check success when not on windows
if (isNotWindows) { if (isNotWindows) {
const fileInfo = Deno.statSync(filename); const fileInfo = Deno.statSync(filename);
assertEqual(fileInfo.mode & 0o777, 0o777); assertEquals(fileInfo.mode & 0o777, 0o777);
} }
}); });
@ -39,9 +39,9 @@ if (isNotWindows) {
// Change actual file mode, not symlink // Change actual file mode, not symlink
const fileInfo = Deno.statSync(filename); const fileInfo = Deno.statSync(filename);
assertEqual(fileInfo.mode & 0o777, 0o777); assertEquals(fileInfo.mode & 0o777, 0o777);
symlinkInfo = Deno.lstatSync(symlinkName); symlinkInfo = Deno.lstatSync(symlinkName);
assertEqual(symlinkInfo.mode & 0o777, symlinkMode); assertEquals(symlinkInfo.mode & 0o777, symlinkMode);
}); });
} }
@ -53,8 +53,8 @@ testPerm({ write: true }, function chmodSyncFailure() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: false }, function chmodSyncPerm() { testPerm({ write: false }, function chmodSyncPerm() {
@ -64,8 +64,8 @@ testPerm({ write: false }, function chmodSyncPerm() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
testPerm({ read: true, write: true }, async function chmodSuccess() { testPerm({ read: true, write: true }, async function chmodSuccess() {
@ -81,7 +81,7 @@ testPerm({ read: true, write: true }, async function chmodSuccess() {
// Check success when not on windows // Check success when not on windows
if (isNotWindows) { if (isNotWindows) {
const fileInfo = Deno.statSync(filename); const fileInfo = Deno.statSync(filename);
assertEqual(fileInfo.mode & 0o777, 0o777); assertEquals(fileInfo.mode & 0o777, 0o777);
} }
}); });
@ -104,9 +104,9 @@ if (isNotWindows) {
// Just change actual file mode, not symlink // Just change actual file mode, not symlink
const fileInfo = Deno.statSync(filename); const fileInfo = Deno.statSync(filename);
assertEqual(fileInfo.mode & 0o777, 0o777); assertEquals(fileInfo.mode & 0o777, 0o777);
symlinkInfo = Deno.lstatSync(symlinkName); symlinkInfo = Deno.lstatSync(symlinkName);
assertEqual(symlinkInfo.mode & 0o777, symlinkMode); assertEquals(symlinkInfo.mode & 0o777, symlinkMode);
}); });
} }
@ -118,8 +118,8 @@ testPerm({ write: true }, async function chmodFailure() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: false }, async function chmodPerm() { testPerm({ write: false }, async function chmodPerm() {
@ -129,6 +129,6 @@ testPerm({ write: false }, async function chmodPerm() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assert, assertEqual } from "./test_util.ts"; import { test, assert, assertEquals } from "./test_util.ts";
// We use a silly amount of `any` in these tests... // We use a silly amount of `any` in these tests...
// tslint:disable:no-any // tslint:disable:no-any
@ -370,8 +370,8 @@ function teardown() {
logStack = []; logStack = [];
getEmitOutputStack = []; getEmitOutputStack = [];
assertEqual(mockDepsStack.length, 0); assertEquals(mockDepsStack.length, 0);
assertEqual(mockFactoryStack.length, 0); assertEquals(mockFactoryStack.length, 0);
mockDepsStack = []; mockDepsStack = [];
mockFactoryStack = []; mockFactoryStack = [];
@ -384,7 +384,7 @@ test(function testJsonEsmTemplate() {
`{ "hello": "world", "foo": "bar" }`, `{ "hello": "world", "foo": "bar" }`,
"/foo.ts" "/foo.ts"
); );
assertEqual( assertEquals(
result, result,
`const _json = JSON.parse(\`{ "hello": "world", "foo": "bar" }\`)\n` + `const _json = JSON.parse(\`{ "hello": "world", "foo": "bar" }\`)\n` +
`export default _json;\n` + `export default _json;\n` +
@ -406,24 +406,24 @@ test(function compilerCompile() {
"foo/bar.ts", "foo/bar.ts",
"/root/project" "/root/project"
); );
assertEqual(moduleMetaData.sourceCode, fooBarTsSource); assertEquals(moduleMetaData.sourceCode, fooBarTsSource);
assertEqual(moduleMetaData.outputCode, fooBarTsOutput); assertEquals(moduleMetaData.outputCode, fooBarTsOutput);
assertEqual( assertEquals(
codeFetchStack.length, codeFetchStack.length,
1, 1,
"Module should have only been fetched once." "Module should have only been fetched once."
); );
assertEqual( assertEquals(
codeCacheStack.length, codeCacheStack.length,
1, 1,
"Compiled code should have only been cached once." "Compiled code should have only been cached once."
); );
const [codeCacheCall] = codeCacheStack; const [codeCacheCall] = codeCacheStack;
assertEqual(codeCacheCall.fileName, "/root/project/foo/bar.ts"); assertEquals(codeCacheCall.fileName, "/root/project/foo/bar.ts");
assertEqual(codeCacheCall.sourceCode, fooBarTsSource); assertEquals(codeCacheCall.sourceCode, fooBarTsSource);
assertEqual(codeCacheCall.outputCode, fooBarTsOutput); assertEquals(codeCacheCall.outputCode, fooBarTsOutput);
assertEqual(codeCacheCall.sourceMap, fooBarTsSourcemap); assertEquals(codeCacheCall.sourceMap, fooBarTsSourcemap);
teardown(); teardown();
}); });
@ -431,16 +431,16 @@ test(function compilerCompilerMultiModule() {
// equal to `deno foo/baz.ts` // equal to `deno foo/baz.ts`
setup(); setup();
compilerInstance.compile("foo/baz.ts", "/root/project"); compilerInstance.compile("foo/baz.ts", "/root/project");
assertEqual(codeFetchStack.length, 2, "Two modules fetched."); assertEquals(codeFetchStack.length, 2, "Two modules fetched.");
assertEqual(codeCacheStack.length, 1, "Only one module compiled."); assertEquals(codeCacheStack.length, 1, "Only one module compiled.");
teardown(); teardown();
}); });
test(function compilerLoadJsonModule() { test(function compilerLoadJsonModule() {
setup(); setup();
compilerInstance.compile("loadConfig.ts", "/root/project"); compilerInstance.compile("loadConfig.ts", "/root/project");
assertEqual(codeFetchStack.length, 2, "Two modules fetched."); assertEquals(codeFetchStack.length, 2, "Two modules fetched.");
assertEqual(codeCacheStack.length, 1, "Only one module compiled."); assertEquals(codeCacheStack.length, 1, "Only one module compiled.");
teardown(); teardown();
}); });
@ -451,12 +451,12 @@ test(function compilerResolveModule() {
"/root/project" "/root/project"
); );
console.log(moduleMetaData); console.log(moduleMetaData);
assertEqual(moduleMetaData.sourceCode, fooBazTsSource); assertEquals(moduleMetaData.sourceCode, fooBazTsSource);
assertEqual(moduleMetaData.outputCode, null); assertEquals(moduleMetaData.outputCode, null);
assertEqual(moduleMetaData.sourceMap, null); assertEquals(moduleMetaData.sourceMap, null);
assertEqual(moduleMetaData.scriptVersion, "1"); assertEquals(moduleMetaData.scriptVersion, "1");
assertEqual(codeFetchStack.length, 1, "Only initial module is resolved."); assertEquals(codeFetchStack.length, 1, "Only initial module is resolved.");
teardown(); teardown();
}); });
@ -467,7 +467,7 @@ test(function compilerResolveModuleUnknownMediaType() {
compilerInstance.resolveModule("some.txt", "/root/project"); compilerInstance.resolveModule("some.txt", "/root/project");
} catch (e) { } catch (e) {
assert(e instanceof Error); assert(e instanceof Error);
assertEqual( assertEquals(
e.message, e.message,
`Unknown media type for: "some.txt" from "/root/project".` `Unknown media type for: "some.txt" from "/root/project".`
); );
@ -480,21 +480,21 @@ test(function compilerResolveModuleUnknownMediaType() {
test(function compilerRecompileFlag() { test(function compilerRecompileFlag() {
setup(); setup();
compilerInstance.compile("foo/bar.ts", "/root/project"); compilerInstance.compile("foo/bar.ts", "/root/project");
assertEqual( assertEquals(
getEmitOutputStack.length, getEmitOutputStack.length,
1, 1,
"Expected only a single emitted file." "Expected only a single emitted file."
); );
// running compiler against same file should use cached code // running compiler against same file should use cached code
compilerInstance.compile("foo/bar.ts", "/root/project"); compilerInstance.compile("foo/bar.ts", "/root/project");
assertEqual( assertEquals(
getEmitOutputStack.length, getEmitOutputStack.length,
1, 1,
"Expected only a single emitted file." "Expected only a single emitted file."
); );
compilerInstance.recompile = true; compilerInstance.recompile = true;
compilerInstance.compile("foo/bar.ts", "/root/project"); compilerInstance.compile("foo/bar.ts", "/root/project");
assertEqual(getEmitOutputStack.length, 2, "Expected two emitted file."); assertEquals(getEmitOutputStack.length, 2, "Expected two emitted file.");
assert( assert(
getEmitOutputStack[0] === getEmitOutputStack[1], getEmitOutputStack[0] === getEmitOutputStack[1],
"Expected same file to be emitted twice." "Expected same file to be emitted twice."
@ -520,20 +520,20 @@ test(function compilerGetCompilationSettings() {
for (const key of expectedKeys) { for (const key of expectedKeys) {
assert(key in result, `Expected "${key}" in compiler options.`); assert(key in result, `Expected "${key}" in compiler options.`);
} }
assertEqual(Object.keys(result).length, expectedKeys.length); assertEquals(Object.keys(result).length, expectedKeys.length);
}); });
test(function compilerGetNewLine() { test(function compilerGetNewLine() {
const result = compilerInstance.getNewLine(); const result = compilerInstance.getNewLine();
assertEqual(result, "\n", "Expected newline value of '\\n'."); assertEquals(result, "\n", "Expected newline value of '\\n'.");
}); });
test(function compilerGetScriptFileNames() { test(function compilerGetScriptFileNames() {
setup(); setup();
compilerInstance.compile("foo/bar.ts", "/root/project"); compilerInstance.compile("foo/bar.ts", "/root/project");
const result = compilerInstance.getScriptFileNames(); const result = compilerInstance.getScriptFileNames();
assertEqual(result.length, 1, "Expected only a single filename."); assertEquals(result.length, 1, "Expected only a single filename.");
assertEqual(result[0], "/root/project/foo/bar.ts"); assertEquals(result[0], "/root/project/foo/bar.ts");
teardown(); teardown();
}); });
@ -544,23 +544,23 @@ test(function compilerGetScriptKind() {
compilerInstance.resolveModule("foo.js", "/moduleKinds"); compilerInstance.resolveModule("foo.js", "/moduleKinds");
compilerInstance.resolveModule("foo.json", "/moduleKinds"); compilerInstance.resolveModule("foo.json", "/moduleKinds");
compilerInstance.resolveModule("foo.txt", "/moduleKinds"); compilerInstance.resolveModule("foo.txt", "/moduleKinds");
assertEqual( assertEquals(
compilerInstance.getScriptKind("/moduleKinds/foo.ts"), compilerInstance.getScriptKind("/moduleKinds/foo.ts"),
ScriptKind.TS ScriptKind.TS
); );
assertEqual( assertEquals(
compilerInstance.getScriptKind("/moduleKinds/foo.d.ts"), compilerInstance.getScriptKind("/moduleKinds/foo.d.ts"),
ScriptKind.TS ScriptKind.TS
); );
assertEqual( assertEquals(
compilerInstance.getScriptKind("/moduleKinds/foo.js"), compilerInstance.getScriptKind("/moduleKinds/foo.js"),
ScriptKind.JS ScriptKind.JS
); );
assertEqual( assertEquals(
compilerInstance.getScriptKind("/moduleKinds/foo.json"), compilerInstance.getScriptKind("/moduleKinds/foo.json"),
ScriptKind.JSON ScriptKind.JSON
); );
assertEqual( assertEquals(
compilerInstance.getScriptKind("/moduleKinds/foo.txt"), compilerInstance.getScriptKind("/moduleKinds/foo.txt"),
ScriptKind.JS ScriptKind.JS
); );
@ -573,7 +573,7 @@ test(function compilerGetScriptVersion() {
"foo/bar.ts", "foo/bar.ts",
"/root/project" "/root/project"
); );
assertEqual( assertEquals(
compilerInstance.getScriptVersion(moduleMetaData.fileName), compilerInstance.getScriptVersion(moduleMetaData.fileName),
"1", "1",
"Expected known module to have script version of 1" "Expected known module to have script version of 1"
@ -582,7 +582,7 @@ test(function compilerGetScriptVersion() {
}); });
test(function compilerGetScriptVersionUnknown() { test(function compilerGetScriptVersionUnknown() {
assertEqual( assertEquals(
compilerInstance.getScriptVersion("/root/project/unknown_module.ts"), compilerInstance.getScriptVersion("/root/project/unknown_module.ts"),
"", "",
"Expected unknown module to have an empty script version" "Expected unknown module to have an empty script version"
@ -597,13 +597,13 @@ test(function compilerGetScriptSnapshot() {
); );
const result = compilerInstance.getScriptSnapshot(moduleMetaData.fileName); const result = compilerInstance.getScriptSnapshot(moduleMetaData.fileName);
assert(result != null, "Expected snapshot to be defined."); assert(result != null, "Expected snapshot to be defined.");
assertEqual(result.getLength(), fooBarTsSource.length); assertEquals(result.getLength(), fooBarTsSource.length);
assertEqual( assertEquals(
result.getText(0, 6), result.getText(0, 6),
"import", "import",
"Expected .getText() to equal 'import'" "Expected .getText() to equal 'import'"
); );
assertEqual(result.getChangeRange(result), undefined); assertEquals(result.getChangeRange(result), undefined);
// This is and optional part of the `IScriptSnapshot` API which we don't // This is and optional part of the `IScriptSnapshot` API which we don't
// define, os checking for the lack of this property. // define, os checking for the lack of this property.
assert(!("dispose" in result)); assert(!("dispose" in result));
@ -616,12 +616,12 @@ test(function compilerGetScriptSnapshot() {
}); });
test(function compilerGetCurrentDirectory() { test(function compilerGetCurrentDirectory() {
assertEqual(compilerInstance.getCurrentDirectory(), ""); assertEquals(compilerInstance.getCurrentDirectory(), "");
}); });
test(function compilerGetDefaultLibFileName() { test(function compilerGetDefaultLibFileName() {
setup(); setup();
assertEqual( assertEquals(
compilerInstance.getDefaultLibFileName(), compilerInstance.getDefaultLibFileName(),
"$asset$/lib.deno_runtime.d.ts" "$asset$/lib.deno_runtime.d.ts"
); );
@ -629,7 +629,7 @@ test(function compilerGetDefaultLibFileName() {
}); });
test(function compilerUseCaseSensitiveFileNames() { test(function compilerUseCaseSensitiveFileNames() {
assertEqual(compilerInstance.useCaseSensitiveFileNames(), true); assertEquals(compilerInstance.useCaseSensitiveFileNames(), true);
}); });
test(function compilerReadFile() { test(function compilerReadFile() {
@ -651,7 +651,7 @@ test(function compilerFileExists() {
); );
assert(compilerInstance.fileExists(moduleMetaData.fileName)); assert(compilerInstance.fileExists(moduleMetaData.fileName));
assert(compilerInstance.fileExists("$asset$/lib.deno_runtime.d.ts")); assert(compilerInstance.fileExists("$asset$/lib.deno_runtime.d.ts"));
assertEqual( assertEquals(
compilerInstance.fileExists("/root/project/unknown-module.ts"), compilerInstance.fileExists("/root/project/unknown-module.ts"),
false false
); );
@ -664,7 +664,7 @@ test(function compilerResolveModuleNames() {
["foo/bar.ts", "foo/baz.ts", "deno"], ["foo/bar.ts", "foo/baz.ts", "deno"],
"/root/project" "/root/project"
); );
assertEqual(results.length, 3); assertEquals(results.length, 3);
const fixtures: Array<[string, boolean]> = [ const fixtures: Array<[string, boolean]> = [
["/root/project/foo/bar.ts", false], ["/root/project/foo/bar.ts", false],
["/root/project/foo/baz.ts", false], ["/root/project/foo/baz.ts", false],
@ -673,8 +673,8 @@ test(function compilerResolveModuleNames() {
for (let i = 0; i < results.length; i++) { for (let i = 0; i < results.length; i++) {
const result = results[i]; const result = results[i];
const [resolvedFileName, isExternalLibraryImport] = fixtures[i]; const [resolvedFileName, isExternalLibraryImport] = fixtures[i];
assertEqual(result.resolvedFileName, resolvedFileName); assertEquals(result.resolvedFileName, resolvedFileName);
assertEqual(result.isExternalLibraryImport, isExternalLibraryImport); assertEquals(result.isExternalLibraryImport, isExternalLibraryImport);
} }
teardown(); teardown();
}); });
@ -685,6 +685,6 @@ test(function compilerResolveEmptyFile() {
["empty_file.ts"], ["empty_file.ts"],
"/moduleKinds" "/moduleKinds"
); );
assertEqual(result[0].resolvedFileName, "/moduleKinds/empty_file.ts"); assertEquals(result[0].resolvedFileName, "/moduleKinds/empty_file.ts");
teardown(); teardown();
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { assert, assertEqual, test } from "./test_util.ts"; import { assert, assertEquals, test } from "./test_util.ts";
// Some of these APIs aren't exposed in the types and so we have to cast to any // Some of these APIs aren't exposed in the types and so we have to cast to any
// in order to "trick" TypeScript. // in order to "trick" TypeScript.
@ -23,13 +23,13 @@ test(function consoleTestAssertShouldNotThrowError() {
} catch { } catch {
hasThrown = true; hasThrown = true;
} }
assertEqual(hasThrown, false); assertEquals(hasThrown, false);
}); });
test(function consoleTestStringifyComplexObjects() { test(function consoleTestStringifyComplexObjects() {
assertEqual(stringify("foo"), "foo"); assertEquals(stringify("foo"), "foo");
assertEqual(stringify(["foo", "bar"]), `[ "foo", "bar" ]`); assertEquals(stringify(["foo", "bar"]), `[ "foo", "bar" ]`);
assertEqual(stringify({ foo: "bar" }), `{ foo: "bar" }`); assertEquals(stringify({ foo: "bar" }), `{ foo: "bar" }`);
}); });
test(function consoleTestStringifyCircular() { test(function consoleTestStringifyCircular() {
@ -76,151 +76,151 @@ test(function consoleTestStringifyCircular() {
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
const nestedObjExpected = `{ num: 1, bool: true, str: "a", method: [Function: method], asyncMethod: [AsyncFunction: asyncMethod], generatorMethod: [GeneratorFunction: generatorMethod], un: undefined, nu: null, arrowFunc: [Function: arrowFunc], extendedClass: Extended { a: 1, b: 2 }, nFunc: [Function], extendedCstr: [Function: Extended], o: { num: 2, bool: false, str: "b", method: [Function: method], un: undefined, nu: null, nested: [Circular], emptyObj: {}, arr: [ 1, "s", false, null, [Circular] ], baseClass: Base { a: 1 } } }`; const nestedObjExpected = `{ num: 1, bool: true, str: "a", method: [Function: method], asyncMethod: [AsyncFunction: asyncMethod], generatorMethod: [GeneratorFunction: generatorMethod], un: undefined, nu: null, arrowFunc: [Function: arrowFunc], extendedClass: Extended { a: 1, b: 2 }, nFunc: [Function], extendedCstr: [Function: Extended], o: { num: 2, bool: false, str: "b", method: [Function: method], un: undefined, nu: null, nested: [Circular], emptyObj: {}, arr: [ 1, "s", false, null, [Circular] ], baseClass: Base { a: 1 } } }`;
assertEqual(stringify(1), "1"); assertEquals(stringify(1), "1");
assertEqual(stringify(1n), "1n"); assertEquals(stringify(1n), "1n");
assertEqual(stringify("s"), "s"); assertEquals(stringify("s"), "s");
assertEqual(stringify(false), "false"); assertEquals(stringify(false), "false");
// tslint:disable-next-line:no-construct // tslint:disable-next-line:no-construct
assertEqual(stringify(new Number(1)), "[Number: 1]"); assertEquals(stringify(new Number(1)), "[Number: 1]");
// tslint:disable-next-line:no-construct // tslint:disable-next-line:no-construct
assertEqual(stringify(new Boolean(true)), "[Boolean: true]"); assertEquals(stringify(new Boolean(true)), "[Boolean: true]");
// tslint:disable-next-line:no-construct // tslint:disable-next-line:no-construct
assertEqual(stringify(new String("deno")), `[String: "deno"]`); assertEquals(stringify(new String("deno")), `[String: "deno"]`);
assertEqual(stringify(/[0-9]*/), "/[0-9]*/"); assertEquals(stringify(/[0-9]*/), "/[0-9]*/");
assertEqual( assertEquals(
stringify(new Date("2018-12-10T02:26:59.002Z")), stringify(new Date("2018-12-10T02:26:59.002Z")),
"2018-12-10T02:26:59.002Z" "2018-12-10T02:26:59.002Z"
); );
assertEqual(stringify(new Set([1, 2, 3])), "Set { 1, 2, 3 }"); assertEquals(stringify(new Set([1, 2, 3])), "Set { 1, 2, 3 }");
assertEqual( assertEquals(
stringify(new Map([[1, "one"], [2, "two"]])), stringify(new Map([[1, "one"], [2, "two"]])),
`Map { 1 => "one", 2 => "two" }` `Map { 1 => "one", 2 => "two" }`
); );
assertEqual(stringify(new WeakSet()), "WeakSet { [items unknown] }"); assertEquals(stringify(new WeakSet()), "WeakSet { [items unknown] }");
assertEqual(stringify(new WeakMap()), "WeakMap { [items unknown] }"); assertEquals(stringify(new WeakMap()), "WeakMap { [items unknown] }");
assertEqual(stringify(Symbol(1)), "Symbol(1)"); assertEquals(stringify(Symbol(1)), "Symbol(1)");
assertEqual(stringify(null), "null"); assertEquals(stringify(null), "null");
assertEqual(stringify(undefined), "undefined"); assertEquals(stringify(undefined), "undefined");
assertEqual(stringify(new Extended()), "Extended { a: 1, b: 2 }"); assertEquals(stringify(new Extended()), "Extended { a: 1, b: 2 }");
assertEqual(stringify(function f() {}), "[Function: f]"); assertEquals(stringify(function f() {}), "[Function: f]");
assertEqual(stringify(async function af() {}), "[AsyncFunction: af]"); assertEquals(stringify(async function af() {}), "[AsyncFunction: af]");
assertEqual(stringify(function* gf() {}), "[GeneratorFunction: gf]"); assertEquals(stringify(function* gf() {}), "[GeneratorFunction: gf]");
assertEqual( assertEquals(
stringify(async function* agf() {}), stringify(async function* agf() {}),
"[AsyncGeneratorFunction: agf]" "[AsyncGeneratorFunction: agf]"
); );
assertEqual(stringify(new Uint8Array([1, 2, 3])), "Uint8Array [ 1, 2, 3 ]"); assertEquals(stringify(new Uint8Array([1, 2, 3])), "Uint8Array [ 1, 2, 3 ]");
assertEqual(stringify(Uint8Array.prototype), "TypedArray []"); assertEquals(stringify(Uint8Array.prototype), "TypedArray []");
assertEqual( assertEquals(
stringify({ a: { b: { c: { d: new Set([1]) } } } }), stringify({ a: { b: { c: { d: new Set([1]) } } } }),
"{ a: { b: { c: { d: [Set] } } } }" "{ a: { b: { c: { d: [Set] } } } }"
); );
assertEqual(stringify(nestedObj), nestedObjExpected); assertEquals(stringify(nestedObj), nestedObjExpected);
assertEqual(stringify(JSON), "{}"); assertEquals(stringify(JSON), "{}");
assertEqual( assertEquals(
stringify(console), stringify(console),
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
"Console { printFunc: [Function], log: [Function], debug: [Function], info: [Function], dir: [Function], warn: [Function], error: [Function], assert: [Function], count: [Function], countReset: [Function], table: [Function], time: [Function], timeLog: [Function], timeEnd: [Function], group: [Function], groupCollapsed: [Function], groupEnd: [Function], clear: [Function], indentLevel: 0, collapsedAt: null }" "Console { printFunc: [Function], log: [Function], debug: [Function], info: [Function], dir: [Function], warn: [Function], error: [Function], assert: [Function], count: [Function], countReset: [Function], table: [Function], time: [Function], timeLog: [Function], timeEnd: [Function], group: [Function], groupCollapsed: [Function], groupEnd: [Function], clear: [Function], indentLevel: 0, collapsedAt: null }"
); );
// test inspect is working the same // test inspect is working the same
assertEqual(inspect(nestedObj), nestedObjExpected); assertEquals(inspect(nestedObj), nestedObjExpected);
}); });
test(function consoleTestStringifyWithDepth() { test(function consoleTestStringifyWithDepth() {
// tslint:disable-next-line:no-any // tslint:disable-next-line:no-any
const nestedObj: any = { a: { b: { c: { d: { e: { f: 42 } } } } } }; const nestedObj: any = { a: { b: { c: { d: { e: { f: 42 } } } } } };
assertEqual( assertEquals(
stringifyArgs([nestedObj], { depth: 3 }), stringifyArgs([nestedObj], { depth: 3 }),
"{ a: { b: { c: [Object] } } }\n" "{ a: { b: { c: [Object] } } }\n"
); );
assertEqual( assertEquals(
stringifyArgs([nestedObj], { depth: 4 }), stringifyArgs([nestedObj], { depth: 4 }),
"{ a: { b: { c: { d: [Object] } } } }\n" "{ a: { b: { c: { d: [Object] } } } }\n"
); );
assertEqual(stringifyArgs([nestedObj], { depth: 0 }), "[Object]\n"); assertEquals(stringifyArgs([nestedObj], { depth: 0 }), "[Object]\n");
assertEqual( assertEquals(
stringifyArgs([nestedObj], { depth: null }), stringifyArgs([nestedObj], { depth: null }),
"{ a: { b: { c: { d: [Object] } } } }\n" "{ a: { b: { c: { d: [Object] } } } }\n"
); );
// test inspect is working the same way // test inspect is working the same way
assertEqual( assertEquals(
inspect(nestedObj, { depth: 4 }), inspect(nestedObj, { depth: 4 }),
"{ a: { b: { c: { d: [Object] } } } }" "{ a: { b: { c: { d: [Object] } } } }"
); );
}); });
test(function consoleTestWithIntegerFormatSpecifier() { test(function consoleTestWithIntegerFormatSpecifier() {
assertEqual(stringify("%i"), "%i"); assertEquals(stringify("%i"), "%i");
assertEqual(stringify("%i", 42.0), "42"); assertEquals(stringify("%i", 42.0), "42");
assertEqual(stringify("%i", 42), "42"); assertEquals(stringify("%i", 42), "42");
assertEqual(stringify("%i", "42"), "42"); assertEquals(stringify("%i", "42"), "42");
assertEqual(stringify("%i", "42.0"), "42"); assertEquals(stringify("%i", "42.0"), "42");
assertEqual(stringify("%i", 1.5), "1"); assertEquals(stringify("%i", 1.5), "1");
assertEqual(stringify("%i", -0.5), "0"); assertEquals(stringify("%i", -0.5), "0");
assertEqual(stringify("%i", ""), "NaN"); assertEquals(stringify("%i", ""), "NaN");
assertEqual(stringify("%i", Symbol()), "NaN"); assertEquals(stringify("%i", Symbol()), "NaN");
assertEqual(stringify("%i %d", 42, 43), "42 43"); assertEquals(stringify("%i %d", 42, 43), "42 43");
assertEqual(stringify("%d %i", 42), "42 %i"); assertEquals(stringify("%d %i", 42), "42 %i");
assertEqual(stringify("%d", 12345678901234567890123), "1"); assertEquals(stringify("%d", 12345678901234567890123), "1");
assertEqual( assertEquals(
stringify("%i", 12345678901234567890123n), stringify("%i", 12345678901234567890123n),
"12345678901234567890123n" "12345678901234567890123n"
); );
}); });
test(function consoleTestWithFloatFormatSpecifier() { test(function consoleTestWithFloatFormatSpecifier() {
assertEqual(stringify("%f"), "%f"); assertEquals(stringify("%f"), "%f");
assertEqual(stringify("%f", 42.0), "42"); assertEquals(stringify("%f", 42.0), "42");
assertEqual(stringify("%f", 42), "42"); assertEquals(stringify("%f", 42), "42");
assertEqual(stringify("%f", "42"), "42"); assertEquals(stringify("%f", "42"), "42");
assertEqual(stringify("%f", "42.0"), "42"); assertEquals(stringify("%f", "42.0"), "42");
assertEqual(stringify("%f", 1.5), "1.5"); assertEquals(stringify("%f", 1.5), "1.5");
assertEqual(stringify("%f", -0.5), "-0.5"); assertEquals(stringify("%f", -0.5), "-0.5");
assertEqual(stringify("%f", Math.PI), "3.141592653589793"); assertEquals(stringify("%f", Math.PI), "3.141592653589793");
assertEqual(stringify("%f", ""), "NaN"); assertEquals(stringify("%f", ""), "NaN");
assertEqual(stringify("%f", Symbol("foo")), "NaN"); assertEquals(stringify("%f", Symbol("foo")), "NaN");
assertEqual(stringify("%f", 5n), "5"); assertEquals(stringify("%f", 5n), "5");
assertEqual(stringify("%f %f", 42, 43), "42 43"); assertEquals(stringify("%f %f", 42, 43), "42 43");
assertEqual(stringify("%f %f", 42), "42 %f"); assertEquals(stringify("%f %f", 42), "42 %f");
}); });
test(function consoleTestWithStringFormatSpecifier() { test(function consoleTestWithStringFormatSpecifier() {
assertEqual(stringify("%s"), "%s"); assertEquals(stringify("%s"), "%s");
assertEqual(stringify("%s", undefined), "undefined"); assertEquals(stringify("%s", undefined), "undefined");
assertEqual(stringify("%s", "foo"), "foo"); assertEquals(stringify("%s", "foo"), "foo");
assertEqual(stringify("%s", 42), "42"); assertEquals(stringify("%s", 42), "42");
assertEqual(stringify("%s", "42"), "42"); assertEquals(stringify("%s", "42"), "42");
assertEqual(stringify("%s %s", 42, 43), "42 43"); assertEquals(stringify("%s %s", 42, 43), "42 43");
assertEqual(stringify("%s %s", 42), "42 %s"); assertEquals(stringify("%s %s", 42), "42 %s");
assertEqual(stringify("%s", Symbol("foo")), "Symbol(foo)"); assertEquals(stringify("%s", Symbol("foo")), "Symbol(foo)");
}); });
test(function consoleTestWithObjectFormatSpecifier() { test(function consoleTestWithObjectFormatSpecifier() {
assertEqual(stringify("%o"), "%o"); assertEquals(stringify("%o"), "%o");
assertEqual(stringify("%o", 42), "42"); assertEquals(stringify("%o", 42), "42");
assertEqual(stringify("%o", "foo"), "foo"); assertEquals(stringify("%o", "foo"), "foo");
assertEqual(stringify("o: %o, a: %O", {}, []), "o: {}, a: []"); assertEquals(stringify("o: %o, a: %O", {}, []), "o: {}, a: []");
assertEqual(stringify("%o", { a: 42 }), "{ a: 42 }"); assertEquals(stringify("%o", { a: 42 }), "{ a: 42 }");
assertEqual( assertEquals(
stringify("%o", { a: { b: { c: { d: new Set([1]) } } } }), stringify("%o", { a: { b: { c: { d: new Set([1]) } } } }),
"{ a: { b: { c: { d: [Set] } } } }" "{ a: { b: { c: { d: [Set] } } } }"
); );
}); });
test(function consoleTestWithVariousOrInvalidFormatSpecifier() { test(function consoleTestWithVariousOrInvalidFormatSpecifier() {
assertEqual(stringify("%s:%s"), "%s:%s"); assertEquals(stringify("%s:%s"), "%s:%s");
assertEqual(stringify("%i:%i"), "%i:%i"); assertEquals(stringify("%i:%i"), "%i:%i");
assertEqual(stringify("%d:%d"), "%d:%d"); assertEquals(stringify("%d:%d"), "%d:%d");
assertEqual(stringify("%%s%s", "foo"), "%sfoo"); assertEquals(stringify("%%s%s", "foo"), "%sfoo");
assertEqual(stringify("%s:%s", undefined), "undefined:%s"); assertEquals(stringify("%s:%s", undefined), "undefined:%s");
assertEqual(stringify("%s:%s", "foo", "bar"), "foo:bar"); assertEquals(stringify("%s:%s", "foo", "bar"), "foo:bar");
assertEqual(stringify("%s:%s", "foo", "bar", "baz"), "foo:bar baz"); assertEquals(stringify("%s:%s", "foo", "bar", "baz"), "foo:bar baz");
assertEqual(stringify("%%%s%%", "hi"), "%hi%"); assertEquals(stringify("%%%s%%", "hi"), "%hi%");
assertEqual(stringify("%d:%d", 12), "12:%d"); assertEquals(stringify("%d:%d", 12), "12:%d");
assertEqual(stringify("%i:%i", 12), "12:%i"); assertEquals(stringify("%i:%i", 12), "12:%i");
assertEqual(stringify("%f:%f", 12), "12:%f"); assertEquals(stringify("%f:%f", 12), "12:%f");
assertEqual(stringify("o: %o, a: %o", {}), "o: {}, a: %o"); assertEquals(stringify("o: %o, a: %o", {}), "o: {}, a: %o");
assertEqual(stringify("abc%", 1), "abc% 1"); assertEquals(stringify("abc%", 1), "abc% 1");
}); });
test(function consoleTestCallToStringOnLabel() { test(function consoleTestCallToStringOnLabel() {
@ -235,7 +235,7 @@ test(function consoleTestCallToStringOnLabel() {
} }
}); });
assertEqual(hasCalled, true); assertEquals(hasCalled, true);
} }
}); });
@ -272,7 +272,7 @@ test(function consoleTestClear() {
}; };
console.clear(); console.clear();
stdout.write = stdoutWrite; stdout.write = stdoutWrite;
assertEqual(buffer, uint8); assertEquals(buffer, uint8);
}); });
// Test bound this issue // Test bound this issue
@ -362,7 +362,7 @@ test(function consoleGroup() {
console.log("9"); console.log("9");
console.log("10"); console.log("10");
assertEqual( assertEquals(
out.toString(), out.toString(),
`1 `1
2 2
@ -399,7 +399,7 @@ test(function consoleGroupWarn() {
console.warn("9"); console.warn("9");
console.warn("10"); console.warn("10");
assertEqual( assertEquals(
both.toString(), both.toString(),
`1 `1
2 2
@ -418,7 +418,7 @@ test(function consoleGroupWarn() {
test(function consoleTable() { test(function consoleTable() {
mockConsole((console, out) => { mockConsole((console, out) => {
console.table({ a: "test", b: 1 }); console.table({ a: "test", b: 1 });
assertEqual( assertEquals(
out.toString(), out.toString(),
`┌─────────┬────────┐ `┌─────────┬────────┐
(index) Values (index) Values
@ -431,7 +431,7 @@ test(function consoleTable() {
}); });
mockConsole((console, out) => { 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"]);
assertEqual( assertEquals(
out.toString(), out.toString(),
`┌─────────┬────┐ `┌─────────┬────┐
(index) c (index) c
@ -444,7 +444,7 @@ test(function consoleTable() {
}); });
mockConsole((console, out) => { mockConsole((console, out) => {
console.table([1, 2, [3, [4]], [5, 6], [[7], [8]]]); console.table([1, 2, [3, [4]], [5, 6], [[7], [8]]]);
assertEqual( assertEquals(
out.toString(), out.toString(),
`┌─────────┬───────┬───────┬────────┐ `┌─────────┬───────┬───────┬────────┐
(index) 0 1 Values (index) 0 1 Values
@ -460,7 +460,7 @@ test(function consoleTable() {
}); });
mockConsole((console, out) => { mockConsole((console, out) => {
console.table(new Set([1, 2, 3, "test"])); console.table(new Set([1, 2, 3, "test"]));
assertEqual( assertEquals(
out.toString(), out.toString(),
`┌───────────────────┬────────┐ `┌───────────────────┬────────┐
(iteration index) Values (iteration index) Values
@ -475,7 +475,7 @@ test(function consoleTable() {
}); });
mockConsole((console, out) => { mockConsole((console, out) => {
console.table(new Map([[1, "one"], [2, "two"]])); console.table(new Map([[1, "one"], [2, "two"]]));
assertEqual( assertEquals(
out.toString(), out.toString(),
`┌───────────────────┬─────┬────────┐ `┌───────────────────┬─────┬────────┐
(iteration index) Key Values (iteration index) Key Values
@ -494,7 +494,7 @@ test(function consoleTable() {
g: new Set([1, 2, 3, "test"]), g: new Set([1, 2, 3, "test"]),
h: new Map([[1, "one"]]) h: new Map([[1, "one"]])
}); });
assertEqual( assertEquals(
out.toString(), out.toString(),
`┌─────────┬───────────┬───────────────────┬────────┐ `┌─────────┬───────────┬───────────────────┬────────┐
(index) c e Values (index) c e Values
@ -516,7 +516,7 @@ test(function consoleTable() {
{ a: 10 }, { a: 10 },
["test", { b: 20, c: "test" }] ["test", { b: 20, c: "test" }]
]); ]);
assertEqual( assertEquals(
out.toString(), out.toString(),
`┌─────────┬────────┬──────────────────────┬────┬────────┐ `┌─────────┬────────┬──────────────────────┬────┬────────┐
(index) 0 1 a Values (index) 0 1 a Values
@ -532,7 +532,7 @@ test(function consoleTable() {
}); });
mockConsole((console, out) => { mockConsole((console, out) => {
console.table([]); console.table([]);
assertEqual( assertEquals(
out.toString(), out.toString(),
`┌─────────┐ `┌─────────┐
(index) (index)
@ -543,7 +543,7 @@ test(function consoleTable() {
}); });
mockConsole((console, out) => { mockConsole((console, out) => {
console.table({}); console.table({});
assertEqual( assertEquals(
out.toString(), out.toString(),
`┌─────────┐ `┌─────────┐
(index) (index)
@ -554,7 +554,7 @@ test(function consoleTable() {
}); });
mockConsole((console, out) => { mockConsole((console, out) => {
console.table(new Set()); console.table(new Set());
assertEqual( assertEquals(
out.toString(), out.toString(),
`┌───────────────────┐ `┌───────────────────┐
(iteration index) (iteration index)
@ -565,7 +565,7 @@ test(function consoleTable() {
}); });
mockConsole((console, out) => { mockConsole((console, out) => {
console.table(new Map()); console.table(new Map());
assertEqual( assertEquals(
out.toString(), out.toString(),
`┌───────────────────┐ `┌───────────────────┐
(iteration index) (iteration index)
@ -576,6 +576,6 @@ test(function consoleTable() {
}); });
mockConsole((console, out) => { mockConsole((console, out) => {
console.table("test"); console.table("test");
assertEqual(out.toString(), "test\n"); assertEquals(out.toString(), "test\n");
}); });
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEqual } from "./test_util.ts"; import { testPerm, assert, assertEquals } from "./test_util.ts";
function readFileString(filename: string): string { function readFileString(filename: string): string {
const dataRead = Deno.readFileSync(filename); const dataRead = Deno.readFileSync(filename);
@ -16,7 +16,7 @@ function writeFileString(filename: string, s: string) {
function assertSameContent(filename1: string, filename2: string) { function assertSameContent(filename1: string, filename2: string) {
const data1 = Deno.readFileSync(filename1); const data1 = Deno.readFileSync(filename1);
const data2 = Deno.readFileSync(filename2); const data2 = Deno.readFileSync(filename2);
assertEqual(data1, data2); assertEquals(data1, data2);
} }
testPerm({ read: true, write: true }, function copyFileSyncSuccess() { testPerm({ read: true, write: true }, function copyFileSyncSuccess() {
@ -26,7 +26,7 @@ testPerm({ read: true, write: true }, function copyFileSyncSuccess() {
writeFileString(fromFilename, "Hello world!"); writeFileString(fromFilename, "Hello world!");
Deno.copyFileSync(fromFilename, toFilename); Deno.copyFileSync(fromFilename, toFilename);
// No change to original file // No change to original file
assertEqual(readFileString(fromFilename), "Hello world!"); assertEquals(readFileString(fromFilename), "Hello world!");
// Original == Dest // Original == Dest
assertSameContent(fromFilename, toFilename); assertSameContent(fromFilename, toFilename);
}); });
@ -43,8 +43,8 @@ testPerm({ write: true, read: true }, function copyFileSyncFailure() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: true, read: false }, function copyFileSyncPerm1() { testPerm({ write: true, read: false }, function copyFileSyncPerm1() {
@ -53,8 +53,8 @@ testPerm({ write: true, read: false }, function copyFileSyncPerm1() {
Deno.copyFileSync("/from.txt", "/to.txt"); Deno.copyFileSync("/from.txt", "/to.txt");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -65,8 +65,8 @@ testPerm({ write: false, read: true }, function copyFileSyncPerm2() {
Deno.copyFileSync("/from.txt", "/to.txt"); Deno.copyFileSync("/from.txt", "/to.txt");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -80,7 +80,7 @@ testPerm({ read: true, write: true }, function copyFileSyncOverwrite() {
writeFileString(toFilename, "Goodbye!"); writeFileString(toFilename, "Goodbye!");
Deno.copyFileSync(fromFilename, toFilename); Deno.copyFileSync(fromFilename, toFilename);
// No change to original file // No change to original file
assertEqual(readFileString(fromFilename), "Hello world!"); assertEquals(readFileString(fromFilename), "Hello world!");
// Original == Dest // Original == Dest
assertSameContent(fromFilename, toFilename); assertSameContent(fromFilename, toFilename);
}); });
@ -92,7 +92,7 @@ testPerm({ read: true, write: true }, async function copyFileSuccess() {
writeFileString(fromFilename, "Hello world!"); writeFileString(fromFilename, "Hello world!");
await Deno.copyFile(fromFilename, toFilename); await Deno.copyFile(fromFilename, toFilename);
// No change to original file // No change to original file
assertEqual(readFileString(fromFilename), "Hello world!"); assertEquals(readFileString(fromFilename), "Hello world!");
// Original == Dest // Original == Dest
assertSameContent(fromFilename, toFilename); assertSameContent(fromFilename, toFilename);
}); });
@ -109,8 +109,8 @@ testPerm({ read: true, write: true }, async function copyFileFailure() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ read: true, write: true }, async function copyFileOverwrite() { testPerm({ read: true, write: true }, async function copyFileOverwrite() {
@ -122,7 +122,7 @@ testPerm({ read: true, write: true }, async function copyFileOverwrite() {
writeFileString(toFilename, "Goodbye!"); writeFileString(toFilename, "Goodbye!");
await Deno.copyFile(fromFilename, toFilename); await Deno.copyFile(fromFilename, toFilename);
// No change to original file // No change to original file
assertEqual(readFileString(fromFilename), "Hello world!"); assertEquals(readFileString(fromFilename), "Hello world!");
// Original == Dest // Original == Dest
assertSameContent(fromFilename, toFilename); assertSameContent(fromFilename, toFilename);
}); });
@ -133,8 +133,8 @@ testPerm({ read: false, write: true }, async function copyFilePerm1() {
await Deno.copyFile("/from.txt", "/to.txt"); await Deno.copyFile("/from.txt", "/to.txt");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -145,8 +145,8 @@ testPerm({ read: true, write: false }, async function copyFilePerm2() {
await Deno.copyFile("/from.txt", "/to.txt"); await Deno.copyFile("/from.txt", "/to.txt");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { test, assertEqual } from "./test_util.ts"; import { test, assertEquals } from "./test_util.ts";
test(function customEventInitializedWithDetail() { test(function customEventInitializedWithDetail() {
const type = "touchstart"; const type = "touchstart";
@ -11,11 +11,11 @@ test(function customEventInitializedWithDetail() {
}); });
const event = new CustomEvent(type, customEventDict); const event = new CustomEvent(type, customEventDict);
assertEqual(event.bubbles, true); assertEquals(event.bubbles, true);
assertEqual(event.cancelable, true); assertEquals(event.cancelable, true);
assertEqual(event.currentTarget, null); assertEquals(event.currentTarget, null);
assertEqual(event.detail, detail); assertEquals(event.detail, detail);
assertEqual(event.isTrusted, false); assertEquals(event.isTrusted, false);
assertEqual(event.target, null); assertEquals(event.target, null);
assertEqual(event.type, type); assertEquals(event.type, type);
}); });

@ -1 +1 @@
Subproject commit d441a7dbf01ed87163dcde4120295c0c796f3f0d Subproject commit 4cf39d4a1420b8153cd78d03d03ef843607ae506

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, testPerm, assert, assertEqual } from "./test_util.ts"; import { test, testPerm, assert, assertEquals } from "./test_util.ts";
test(function dirCwdNotNull() { test(function dirCwdNotNull() {
assert(Deno.cwd() != null); assert(Deno.cwd() != null);
@ -11,9 +11,9 @@ testPerm({ write: true }, function dirCwdChdirSuccess() {
Deno.chdir(path); Deno.chdir(path);
const current = Deno.cwd(); const current = Deno.cwd();
if (Deno.build.os === "mac") { if (Deno.build.os === "mac") {
assertEqual(current, "/private" + path); assertEquals(current, "/private" + path);
} else { } else {
assertEqual(current, path); assertEquals(current, path);
} }
Deno.chdir(initialdir); Deno.chdir(initialdir);
}); });

View file

@ -1,12 +1,12 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assertEqual } from "./test_util.ts"; import { test, assertEquals } from "./test_util.ts";
test(function addEventListenerTest() { test(function addEventListenerTest() {
const document = new EventTarget(); const document = new EventTarget();
assertEqual(document.addEventListener("x", null, false), undefined); assertEquals(document.addEventListener("x", null, false), undefined);
assertEqual(document.addEventListener("x", null, true), undefined); assertEquals(document.addEventListener("x", null, true), undefined);
assertEqual(document.addEventListener("x", null), undefined); assertEquals(document.addEventListener("x", null), undefined);
}); });
test(function constructedEventTargetCanBeUsedAsExpected() { test(function constructedEventTargetCanBeUsedAsExpected() {
@ -15,21 +15,21 @@ test(function constructedEventTargetCanBeUsedAsExpected() {
let callCount = 0; let callCount = 0;
function listener(e) { function listener(e) {
assertEqual(e, event); assertEquals(e, event);
++callCount; ++callCount;
} }
target.addEventListener("foo", listener); target.addEventListener("foo", listener);
target.dispatchEvent(event); target.dispatchEvent(event);
assertEqual(callCount, 1); assertEquals(callCount, 1);
target.dispatchEvent(event); target.dispatchEvent(event);
assertEqual(callCount, 2); assertEquals(callCount, 2);
target.removeEventListener("foo", listener); target.removeEventListener("foo", listener);
target.dispatchEvent(event); target.dispatchEvent(event);
assertEqual(callCount, 2); assertEquals(callCount, 2);
}); });
test(function anEventTargetCanBeSubclassed() { test(function anEventTargetCanBeSubclassed() {
@ -52,15 +52,15 @@ test(function anEventTargetCanBeSubclassed() {
} }
target.on("foo", listener); target.on("foo", listener);
assertEqual(callCount, 0); assertEquals(callCount, 0);
target.off("foo", listener); target.off("foo", listener);
assertEqual(callCount, 0); assertEquals(callCount, 0);
}); });
test(function removingNullEventListenerShouldSucceed() { test(function removingNullEventListenerShouldSucceed() {
const document = new EventTarget(); const document = new EventTarget();
assertEqual(document.removeEventListener("x", null, false), undefined); assertEquals(document.removeEventListener("x", null, false), undefined);
assertEqual(document.removeEventListener("x", null, true), undefined); assertEquals(document.removeEventListener("x", null, true), undefined);
assertEqual(document.removeEventListener("x", null), undefined); assertEquals(document.removeEventListener("x", null), undefined);
}); });

View file

@ -1,16 +1,16 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assertEqual } from "./test_util.ts"; import { test, assertEquals } from "./test_util.ts";
test(function eventInitializedWithType() { test(function eventInitializedWithType() {
const type = "click"; const type = "click";
const event = new Event(type); const event = new Event(type);
assertEqual(event.isTrusted, false); assertEquals(event.isTrusted, false);
assertEqual(event.target, null); assertEquals(event.target, null);
assertEqual(event.currentTarget, null); assertEquals(event.currentTarget, null);
assertEqual(event.type, "click"); assertEquals(event.type, "click");
assertEqual(event.bubbles, false); assertEquals(event.bubbles, false);
assertEqual(event.cancelable, false); assertEquals(event.cancelable, false);
}); });
test(function eventInitializedWithTypeAndDict() { test(function eventInitializedWithTypeAndDict() {
@ -18,12 +18,12 @@ test(function eventInitializedWithTypeAndDict() {
const eventInitDict = new EventInit({ bubbles: true, cancelable: true }); const eventInitDict = new EventInit({ bubbles: true, cancelable: true });
const event = new Event(init, eventInitDict); const event = new Event(init, eventInitDict);
assertEqual(event.isTrusted, false); assertEquals(event.isTrusted, false);
assertEqual(event.target, null); assertEquals(event.target, null);
assertEqual(event.currentTarget, null); assertEquals(event.currentTarget, null);
assertEqual(event.type, "submit"); assertEquals(event.type, "submit");
assertEqual(event.bubbles, true); assertEquals(event.bubbles, true);
assertEqual(event.cancelable, true); assertEquals(event.cancelable, true);
}); });
test(function eventComposedPathSuccess() { test(function eventComposedPathSuccess() {
@ -31,40 +31,40 @@ test(function eventComposedPathSuccess() {
const event = new Event(type); const event = new Event(type);
const composedPath = event.composedPath(); const composedPath = event.composedPath();
assertEqual(composedPath, []); assertEquals(composedPath, []);
}); });
test(function eventStopPropagationSuccess() { test(function eventStopPropagationSuccess() {
const type = "click"; const type = "click";
const event = new Event(type); const event = new Event(type);
assertEqual(event.cancelBubble, false); assertEquals(event.cancelBubble, false);
event.stopPropagation(); event.stopPropagation();
assertEqual(event.cancelBubble, true); assertEquals(event.cancelBubble, true);
}); });
test(function eventStopImmediatePropagationSuccess() { test(function eventStopImmediatePropagationSuccess() {
const type = "click"; const type = "click";
const event = new Event(type); const event = new Event(type);
assertEqual(event.cancelBubble, false); assertEquals(event.cancelBubble, false);
assertEqual(event.cancelBubbleImmediately, false); assertEquals(event.cancelBubbleImmediately, false);
event.stopImmediatePropagation(); event.stopImmediatePropagation();
assertEqual(event.cancelBubble, true); assertEquals(event.cancelBubble, true);
assertEqual(event.cancelBubbleImmediately, true); assertEquals(event.cancelBubbleImmediately, true);
}); });
test(function eventPreventDefaultSuccess() { test(function eventPreventDefaultSuccess() {
const type = "click"; const type = "click";
const event = new Event(type); const event = new Event(type);
assertEqual(event.defaultPrevented, false); assertEquals(event.defaultPrevented, false);
event.preventDefault(); event.preventDefault();
assertEqual(event.defaultPrevented, false); assertEquals(event.defaultPrevented, false);
const eventInitDict = new EventInit({ bubbles: true, cancelable: true }); const eventInitDict = new EventInit({ bubbles: true, cancelable: true });
const cancelableEvent = new Event(type, eventInitDict); const cancelableEvent = new Event(type, eventInitDict);
assertEqual(cancelableEvent.defaultPrevented, false); assertEquals(cancelableEvent.defaultPrevented, false);
cancelableEvent.preventDefault(); cancelableEvent.preventDefault();
assertEqual(cancelableEvent.defaultPrevented, true); assertEquals(cancelableEvent.defaultPrevented, true);
}); });

View file

@ -1,10 +1,10 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, testPerm, assert, assertEqual } from "./test_util.ts"; import { test, testPerm, assert, assertEquals } from "./test_util.ts";
testPerm({ net: true }, async function fetchJsonSuccess() { testPerm({ net: true }, async function fetchJsonSuccess() {
const response = await fetch("http://localhost:4545/package.json"); const response = await fetch("http://localhost:4545/package.json");
const json = await response.json(); const json = await response.json();
assertEqual(json.name, "deno"); assertEquals(json.name, "deno");
}); });
test(async function fetchPerm() { test(async function fetchPerm() {
@ -14,14 +14,14 @@ test(async function fetchPerm() {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
testPerm({ net: true }, async function fetchHeaders() { testPerm({ net: true }, async function fetchHeaders() {
const response = await fetch("http://localhost:4545/package.json"); const response = await fetch("http://localhost:4545/package.json");
const headers = response.headers; const headers = response.headers;
assertEqual(headers.get("Content-Type"), "application/json"); assertEquals(headers.get("Content-Type"), "application/json");
assert(headers.get("Server").startsWith("SimpleHTTP")); assert(headers.get("Server").startsWith("SimpleHTTP"));
}); });
@ -29,20 +29,20 @@ testPerm({ net: true }, async function fetchBlob() {
const response = await fetch("http://localhost:4545/package.json"); const response = await fetch("http://localhost:4545/package.json");
const headers = response.headers; const headers = response.headers;
const blob = await response.blob(); const blob = await response.blob();
assertEqual(blob.type, headers.get("Content-Type")); assertEquals(blob.type, headers.get("Content-Type"));
assertEqual(blob.size, Number(headers.get("Content-Length"))); assertEquals(blob.size, Number(headers.get("Content-Length")));
}); });
testPerm({ net: true }, async function responseClone() { testPerm({ net: true }, async function responseClone() {
const response = await fetch("http://localhost:4545/package.json"); const response = await fetch("http://localhost:4545/package.json");
const response1 = response.clone(); const response1 = response.clone();
assert(response !== response1); assert(response !== response1);
assertEqual(response.status, response1.status); assertEquals(response.status, response1.status);
assertEqual(response.statusText, response1.statusText); assertEquals(response.statusText, response1.statusText);
const ab = await response.arrayBuffer(); const ab = await response.arrayBuffer();
const ab1 = await response1.arrayBuffer(); const ab1 = await response1.arrayBuffer();
for (let i = 0; i < ab.byteLength; i++) { for (let i = 0; i < ab.byteLength; i++) {
assertEqual(ab[i], ab1[i]); assertEquals(ab[i], ab1[i]);
} }
}); });
@ -53,8 +53,8 @@ testPerm({ net: true }, async function fetchEmptyInvalid() {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assertEqual(err.kind, Deno.ErrorKind.InvalidUri); assertEquals(err.kind, Deno.ErrorKind.InvalidUri);
assertEqual(err.name, "InvalidUri"); assertEquals(err.name, "InvalidUri");
}); });
testPerm({ net: true }, async function fetchMultipartFormDataSuccess() { testPerm({ net: true }, async function fetchMultipartFormDataSuccess() {
@ -63,11 +63,11 @@ testPerm({ net: true }, async function fetchMultipartFormDataSuccess() {
); );
const formData = await response.formData(); const formData = await response.formData();
assert(formData.has("field_1")); assert(formData.has("field_1"));
assertEqual(formData.get("field_1").toString(), "value_1 \r\n"); assertEquals(formData.get("field_1").toString(), "value_1 \r\n");
assert(formData.has("field_2")); assert(formData.has("field_2"));
/* TODO(ry) Re-enable this test once we bring back the global File type. /* TODO(ry) Re-enable this test once we bring back the global File type.
const file = formData.get("field_2") as File; const file = formData.get("field_2") as File;
assertEqual(file.name, "file.js"); assertEquals(file.name, "file.js");
*/ */
// Currently we cannot read from file... // Currently we cannot read from file...
}); });
@ -78,9 +78,9 @@ testPerm({ net: true }, async function fetchURLEncodedFormDataSuccess() {
); );
const formData = await response.formData(); const formData = await response.formData();
assert(formData.has("field_1")); assert(formData.has("field_1"));
assertEqual(formData.get("field_1").toString(), "Hi"); assertEquals(formData.get("field_1").toString(), "Hi");
assert(formData.has("field_2")); assert(formData.has("field_2"));
assertEqual(formData.get("field_2").toString(), "<Deno>"); assertEquals(formData.get("field_2").toString(), "<Deno>");
}); });
testPerm({ net: true }, async function fetchInitStringBody() { testPerm({ net: true }, async function fetchInitStringBody() {
@ -90,7 +90,7 @@ testPerm({ net: true }, async function fetchInitStringBody() {
body: data body: data
}); });
const text = await response.text(); const text = await response.text();
assertEqual(text, data); assertEquals(text, data);
assert(response.headers.get("content-type").startsWith("text/plain")); assert(response.headers.get("content-type").startsWith("text/plain"));
}); });
@ -101,7 +101,7 @@ testPerm({ net: true }, async function fetchInitTypedArrayBody() {
body: new TextEncoder().encode(data) body: new TextEncoder().encode(data)
}); });
const text = await response.text(); const text = await response.text();
assertEqual(text, data); assertEquals(text, data);
}); });
testPerm({ net: true }, async function fetchInitURLSearchParamsBody() { testPerm({ net: true }, async function fetchInitURLSearchParamsBody() {
@ -112,7 +112,7 @@ testPerm({ net: true }, async function fetchInitURLSearchParamsBody() {
body: params body: params
}); });
const text = await response.text(); const text = await response.text();
assertEqual(text, data); assertEquals(text, data);
assert( assert(
response.headers response.headers
.get("content-type") .get("content-type")
@ -130,7 +130,7 @@ testPerm({ net: true }, async function fetchInitBlobBody() {
body: blob body: blob
}); });
const text = await response.text(); const text = await response.text();
assertEqual(text, data); assertEquals(text, data);
assert(response.headers.get("content-type").startsWith("text/javascript")); assert(response.headers.get("content-type").startsWith("text/javascript"));
}); });
@ -138,7 +138,7 @@ testPerm({ net: true }, async function fetchInitBlobBody() {
// somewhere. Here is what one of these flaky failures looks like: // somewhere. Here is what one of these flaky failures looks like:
// //
// test fetchPostBodyString_permW0N1E0R0 // test fetchPostBodyString_permW0N1E0R0
// assertEqual failed. actual = expected = POST /blah HTTP/1.1 // assertEquals failed. actual = expected = POST /blah HTTP/1.1
// hello: World // hello: World
// foo: Bar // foo: Bar
// host: 127.0.0.1:4502 // host: 127.0.0.1:4502
@ -150,7 +150,7 @@ testPerm({ net: true }, async function fetchInitBlobBody() {
// host: 127.0.0.1:4502 // host: 127.0.0.1:4502
// content-length: 11 // content-length: 11
// hello world // hello world
// at Object.assertEqual (file:///C:/deno/js/testing/util.ts:29:11) // at Object.assertEquals (file:///C:/deno/js/testing/util.ts:29:11)
// at fetchPostBodyString (file // at fetchPostBodyString (file
/* /*
@ -184,8 +184,8 @@ testPerm({ net: true }, async function fetchRequest() {
method: "POST", method: "POST",
headers: [["Hello", "World"], ["Foo", "Bar"]] headers: [["Hello", "World"], ["Foo", "Bar"]]
}); });
assertEqual(response.status, 404); assertEquals(response.status, 404);
assertEqual(response.headers.get("Content-Length"), "2"); assertEquals(response.headers.get("Content-Length"), "2");
const actual = new TextDecoder().decode(buf.bytes()); const actual = new TextDecoder().decode(buf.bytes());
const expected = [ const expected = [
@ -194,7 +194,7 @@ testPerm({ net: true }, async function fetchRequest() {
"foo: Bar\r\n", "foo: Bar\r\n",
`host: ${addr}\r\n\r\n` `host: ${addr}\r\n\r\n`
].join(""); ].join("");
assertEqual(actual, expected); assertEquals(actual, expected);
}); });
testPerm({ net: true }, async function fetchPostBodyString() { testPerm({ net: true }, async function fetchPostBodyString() {
@ -206,8 +206,8 @@ testPerm({ net: true }, async function fetchPostBodyString() {
headers: [["Hello", "World"], ["Foo", "Bar"]], headers: [["Hello", "World"], ["Foo", "Bar"]],
body body
}); });
assertEqual(response.status, 404); assertEquals(response.status, 404);
assertEqual(response.headers.get("Content-Length"), "2"); assertEquals(response.headers.get("Content-Length"), "2");
const actual = new TextDecoder().decode(buf.bytes()); const actual = new TextDecoder().decode(buf.bytes());
const expected = [ const expected = [
@ -218,7 +218,7 @@ testPerm({ net: true }, async function fetchPostBodyString() {
`content-length: ${body.length}\r\n\r\n`, `content-length: ${body.length}\r\n\r\n`,
body body
].join(""); ].join("");
assertEqual(actual, expected); assertEquals(actual, expected);
}); });
testPerm({ net: true }, async function fetchPostBodyTypedArray() { testPerm({ net: true }, async function fetchPostBodyTypedArray() {
@ -231,8 +231,8 @@ testPerm({ net: true }, async function fetchPostBodyTypedArray() {
headers: [["Hello", "World"], ["Foo", "Bar"]], headers: [["Hello", "World"], ["Foo", "Bar"]],
body body
}); });
assertEqual(response.status, 404); assertEquals(response.status, 404);
assertEqual(response.headers.get("Content-Length"), "2"); assertEquals(response.headers.get("Content-Length"), "2");
const actual = new TextDecoder().decode(buf.bytes()); const actual = new TextDecoder().decode(buf.bytes());
const expected = [ const expected = [
@ -243,6 +243,6 @@ testPerm({ net: true }, async function fetchPostBodyTypedArray() {
`content-length: ${body.byteLength}\r\n\r\n`, `content-length: ${body.byteLength}\r\n\r\n`,
bodyStr bodyStr
].join(""); ].join("");
assertEqual(actual, expected); assertEquals(actual, expected);
}); });
*/ */

View file

@ -1,12 +1,12 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assert, assertEqual } from "./test_util.ts"; import { test, assert, assertEquals } from "./test_util.ts";
function testFirstArgument(arg1, expectedSize) { function testFirstArgument(arg1, expectedSize) {
const file = new File(arg1, "name"); const file = new File(arg1, "name");
assert(file instanceof File); assert(file instanceof File);
assertEqual(file.name, "name"); assertEquals(file.name, "name");
assertEqual(file.size, expectedSize); assertEquals(file.size, expectedSize);
assertEqual(file.type, ""); assertEquals(file.type, "");
} }
test(function fileEmptyFileBits() { test(function fileEmptyFileBits() {
@ -80,7 +80,7 @@ test(function fileObjectInFileBits() {
function testSecondArgument(arg2, expectedFileName) { function testSecondArgument(arg2, expectedFileName) {
const file = new File(["bits"], arg2); const file = new File(["bits"], arg2);
assert(file instanceof File); assert(file instanceof File);
assertEqual(file.name, expectedFileName); assertEquals(file.name, expectedFileName);
} }
test(function fileUsingFileName() { test(function fileUsingFileName() {

View file

@ -1,10 +1,10 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, testPerm, assert, assertEqual } from "./test_util.ts"; import { test, testPerm, assert, assertEquals } from "./test_util.ts";
test(function filesStdioFileDescriptors() { test(function filesStdioFileDescriptors() {
assertEqual(Deno.stdin.rid, 0); assertEquals(Deno.stdin.rid, 0);
assertEqual(Deno.stdout.rid, 1); assertEquals(Deno.stdout.rid, 1);
assertEqual(Deno.stderr.rid, 2); assertEquals(Deno.stderr.rid, 2);
}); });
testPerm({ read: true }, async function filesCopyToStdout() { testPerm({ read: true }, async function filesCopyToStdout() {
@ -13,7 +13,7 @@ testPerm({ read: true }, async function filesCopyToStdout() {
assert(file.rid > 2); assert(file.rid > 2);
const bytesWritten = await Deno.copy(Deno.stdout, file); const bytesWritten = await Deno.copy(Deno.stdout, file);
const fileSize = Deno.statSync(filename).len; const fileSize = Deno.statSync(filename).len;
assertEqual(bytesWritten, fileSize); assertEquals(bytesWritten, fileSize);
console.log("bytes written", bytesWritten); console.log("bytes written", bytesWritten);
}); });
@ -26,7 +26,7 @@ testPerm({ read: true }, async function filesToAsyncIterator() {
totalSize += buf.byteLength; totalSize += buf.byteLength;
} }
assertEqual(totalSize, 12); assertEquals(totalSize, 12);
}); });
testPerm({ write: false }, async function writePermFailure() { testPerm({ write: false }, async function writePermFailure() {
@ -40,8 +40,8 @@ testPerm({ write: false }, async function writePermFailure() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
} }
}); });
@ -51,8 +51,8 @@ testPerm({ read: false }, async function readPermFailure() {
await Deno.open("package.json", "r"); await Deno.open("package.json", "r");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -68,8 +68,8 @@ testPerm({ write: false, read: false }, async function readWritePermFailure() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
} }
}); });
@ -101,11 +101,11 @@ testPerm({ read: true, write: true }, async function openModeWrite() {
// assert file was created // assert file was created
let fileInfo = Deno.statSync(filename); let fileInfo = Deno.statSync(filename);
assert(fileInfo.isFile()); assert(fileInfo.isFile());
assertEqual(fileInfo.len, 0); assertEquals(fileInfo.len, 0);
// write some data // write some data
await file.write(data); await file.write(data);
fileInfo = Deno.statSync(filename); fileInfo = Deno.statSync(filename);
assertEqual(fileInfo.len, 13); assertEquals(fileInfo.len, 13);
// assert we can't read from file // assert we can't read from file
let thrown = false; let thrown = false;
try { try {
@ -121,7 +121,7 @@ testPerm({ read: true, write: true }, async function openModeWrite() {
file = await Deno.open(filename, "w"); file = await Deno.open(filename, "w");
file.close(); file.close();
const fileSize = Deno.statSync(filename).len; const fileSize = Deno.statSync(filename).len;
assertEqual(fileSize, 0); assertEquals(fileSize, 0);
await Deno.remove(tempDir, { recursive: true }); await Deno.remove(tempDir, { recursive: true });
}); });
@ -135,16 +135,16 @@ testPerm({ read: true, write: true }, async function openModeWriteRead() {
// assert file was created // assert file was created
let fileInfo = Deno.statSync(filename); let fileInfo = Deno.statSync(filename);
assert(fileInfo.isFile()); assert(fileInfo.isFile());
assertEqual(fileInfo.len, 0); assertEquals(fileInfo.len, 0);
// write some data // write some data
await file.write(data); await file.write(data);
fileInfo = Deno.statSync(filename); fileInfo = Deno.statSync(filename);
assertEqual(fileInfo.len, 13); assertEquals(fileInfo.len, 13);
const buf = new Uint8Array(20); const buf = new Uint8Array(20);
await file.seek(0, Deno.SeekMode.SEEK_START); await file.seek(0, Deno.SeekMode.SEEK_START);
const result = await file.read(buf); const result = await file.read(buf);
assertEqual(result.nread, 13); assertEquals(result.nread, 13);
file.close(); file.close();
await Deno.remove(tempDir, { recursive: true }); await Deno.remove(tempDir, { recursive: true });
@ -160,7 +160,7 @@ testPerm({ read: true }, async function seekStart() {
const buf = new Uint8Array(6); const buf = new Uint8Array(6);
await file.read(buf); await file.read(buf);
const decoded = new TextDecoder().decode(buf); const decoded = new TextDecoder().decode(buf);
assertEqual(decoded, "world!"); assertEquals(decoded, "world!");
}); });
testPerm({ read: true }, async function seekCurrent() { testPerm({ read: true }, async function seekCurrent() {
@ -173,7 +173,7 @@ testPerm({ read: true }, async function seekCurrent() {
const buf = new Uint8Array(6); const buf = new Uint8Array(6);
await file.read(buf); await file.read(buf);
const decoded = new TextDecoder().decode(buf); const decoded = new TextDecoder().decode(buf);
assertEqual(decoded, "world!"); assertEquals(decoded, "world!");
}); });
testPerm({ read: true }, async function seekEnd() { testPerm({ read: true }, async function seekEnd() {
@ -183,7 +183,7 @@ testPerm({ read: true }, async function seekEnd() {
const buf = new Uint8Array(6); const buf = new Uint8Array(6);
await file.read(buf); await file.read(buf);
const decoded = new TextDecoder().decode(buf); const decoded = new TextDecoder().decode(buf);
assertEqual(decoded, "world!"); assertEquals(decoded, "world!");
}); });
testPerm({ read: true }, async function seekMode() { testPerm({ read: true }, async function seekMode() {
@ -196,6 +196,6 @@ testPerm({ read: true }, async function seekMode() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assertEqual(err.kind, Deno.ErrorKind.InvalidSeekMode); assertEquals(err.kind, Deno.ErrorKind.InvalidSeekMode);
assertEqual(err.name, "InvalidSeekMode"); assertEquals(err.name, "InvalidSeekMode");
}); });

View file

@ -1,24 +1,24 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assert, assertEqual } from "./test_util.ts"; import { test, assert, assertEquals } from "./test_util.ts";
test(function formDataHasCorrectNameProp() { test(function formDataHasCorrectNameProp() {
assertEqual(FormData.name, "FormData"); assertEquals(FormData.name, "FormData");
}); });
test(function formDataParamsAppendSuccess() { test(function formDataParamsAppendSuccess() {
const formData = new FormData(); const formData = new FormData();
formData.append("a", "true"); formData.append("a", "true");
assertEqual(formData.get("a"), "true"); assertEquals(formData.get("a"), "true");
}); });
test(function formDataParamsDeleteSuccess() { test(function formDataParamsDeleteSuccess() {
const formData = new FormData(); const formData = new FormData();
formData.append("a", "true"); formData.append("a", "true");
formData.append("b", "false"); formData.append("b", "false");
assertEqual(formData.get("b"), "false"); assertEquals(formData.get("b"), "false");
formData.delete("b"); formData.delete("b");
assertEqual(formData.get("a"), "true"); assertEquals(formData.get("a"), "true");
assertEqual(formData.get("b"), null); assertEquals(formData.get("b"), null);
}); });
test(function formDataParamsGetAllSuccess() { test(function formDataParamsGetAllSuccess() {
@ -26,9 +26,9 @@ test(function formDataParamsGetAllSuccess() {
formData.append("a", "true"); formData.append("a", "true");
formData.append("b", "false"); formData.append("b", "false");
formData.append("a", "null"); formData.append("a", "null");
assertEqual(formData.getAll("a"), ["true", "null"]); assertEquals(formData.getAll("a"), ["true", "null"]);
assertEqual(formData.getAll("b"), ["false"]); assertEquals(formData.getAll("b"), ["false"]);
assertEqual(formData.getAll("c"), []); assertEquals(formData.getAll("c"), []);
}); });
test(function formDataParamsGetSuccess() { test(function formDataParamsGetSuccess() {
@ -38,11 +38,11 @@ test(function formDataParamsGetSuccess() {
formData.append("a", "null"); formData.append("a", "null");
formData.append("d", undefined); formData.append("d", undefined);
formData.append("e", null); formData.append("e", null);
assertEqual(formData.get("a"), "true"); assertEquals(formData.get("a"), "true");
assertEqual(formData.get("b"), "false"); assertEquals(formData.get("b"), "false");
assertEqual(formData.get("c"), null); assertEquals(formData.get("c"), null);
assertEqual(formData.get("d"), "undefined"); assertEquals(formData.get("d"), "undefined");
assertEqual(formData.get("e"), "null"); assertEquals(formData.get("e"), "null");
}); });
test(function formDataParamsHasSuccess() { test(function formDataParamsHasSuccess() {
@ -59,14 +59,14 @@ test(function formDataParamsSetSuccess() {
formData.append("a", "true"); formData.append("a", "true");
formData.append("b", "false"); formData.append("b", "false");
formData.append("a", "null"); formData.append("a", "null");
assertEqual(formData.getAll("a"), ["true", "null"]); assertEquals(formData.getAll("a"), ["true", "null"]);
assertEqual(formData.getAll("b"), ["false"]); assertEquals(formData.getAll("b"), ["false"]);
formData.set("a", "false"); formData.set("a", "false");
assertEqual(formData.getAll("a"), ["false"]); assertEquals(formData.getAll("a"), ["false"]);
formData.set("d", undefined); formData.set("d", undefined);
assertEqual(formData.get("d"), "undefined"); assertEquals(formData.get("d"), "undefined");
formData.set("e", null); formData.set("e", null);
assertEqual(formData.get("e"), "null"); assertEquals(formData.get("e"), "null");
}); });
test(function formDataSetEmptyBlobSuccess() { test(function formDataSetEmptyBlobSuccess() {
@ -76,7 +76,7 @@ test(function formDataSetEmptyBlobSuccess() {
/* TODO Fix this test. /* TODO Fix this test.
assert(file instanceof File); assert(file instanceof File);
if (typeof file !== "string") { if (typeof file !== "string") {
assertEqual(file.name, "blank.txt"); assertEquals(file.name, "blank.txt");
} }
*/ */
}); });
@ -89,12 +89,12 @@ test(function formDataParamsForEachSuccess() {
} }
let callNum = 0; let callNum = 0;
formData.forEach((value, key, parent) => { formData.forEach((value, key, parent) => {
assertEqual(formData, parent); assertEquals(formData, parent);
assertEqual(value, init[callNum][1]); assertEquals(value, init[callNum][1]);
assertEqual(key, init[callNum][0]); assertEquals(key, init[callNum][0]);
callNum++; callNum++;
}); });
assertEqual(callNum, init.length); assertEquals(callNum, init.length);
}); });
test(function formDataParamsArgumentsCheck() { test(function formDataParamsArgumentsCheck() {
@ -117,8 +117,8 @@ test(function formDataParamsArgumentsCheck() {
hasThrown = 3; hasThrown = 3;
} }
} }
assertEqual(hasThrown, 2); assertEquals(hasThrown, 2);
assertEqual( assertEquals(
errMsg, errMsg,
`FormData.${method} requires at least 1 argument, but only 0 present` `FormData.${method} requires at least 1 argument, but only 0 present`
); );
@ -140,8 +140,8 @@ test(function formDataParamsArgumentsCheck() {
hasThrown = 3; hasThrown = 3;
} }
} }
assertEqual(hasThrown, 2); assertEquals(hasThrown, 2);
assertEqual( assertEquals(
errMsg, errMsg,
`FormData.${method} requires at least 2 arguments, but only 0 present` `FormData.${method} requires at least 2 arguments, but only 0 present`
); );
@ -159,8 +159,8 @@ test(function formDataParamsArgumentsCheck() {
hasThrown = 3; hasThrown = 3;
} }
} }
assertEqual(hasThrown, 2); assertEquals(hasThrown, 2);
assertEqual( assertEquals(
errMsg, errMsg,
`FormData.${method} requires at least 2 arguments, but only 1 present` `FormData.${method} requires at least 2 arguments, but only 1 present`
); );

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assert, assertEqual } from "./test_util.ts"; import { test, assert, assertEquals } from "./test_util.ts";
// 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
@ -13,7 +13,7 @@ test(function newHeaderTest() {
try { try {
new Headers(null); new Headers(null);
} catch (e) { } catch (e) {
assertEqual( assertEquals(
e.message, e.message,
"Failed to construct 'Headers'; The provided value was not valid" "Failed to construct 'Headers'; The provided value was not valid"
); );
@ -35,15 +35,15 @@ for (const name in headerDict) {
test(function newHeaderWithSequence() { test(function newHeaderWithSequence() {
const headers = new Headers(headerSeq); const headers = new Headers(headerSeq);
for (const name in headerDict) { for (const name in headerDict) {
assertEqual(headers.get(name), String(headerDict[name])); assertEquals(headers.get(name), String(headerDict[name]));
} }
assertEqual(headers.get("length"), null); assertEquals(headers.get("length"), null);
}); });
test(function newHeaderWithRecord() { test(function newHeaderWithRecord() {
const headers = new Headers(headerDict); const headers = new Headers(headerDict);
for (const name in headerDict) { for (const name in headerDict) {
assertEqual(headers.get(name), String(headerDict[name])); assertEquals(headers.get(name), String(headerDict[name]));
} }
}); });
@ -51,7 +51,7 @@ test(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) {
assertEqual(headers2.get(name), String(headerDict[name])); assertEquals(headers2.get(name), String(headerDict[name]));
} }
}); });
@ -59,7 +59,7 @@ test(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]);
assertEqual(headers.get(name), String(headerDict[name])); assertEquals(headers.get(name), String(headerDict[name]));
} }
}); });
@ -67,7 +67,7 @@ test(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]);
assertEqual(headers.get(name), String(headerDict[name])); assertEquals(headers.get(name), String(headerDict[name]));
} }
}); });
@ -95,8 +95,8 @@ test(function headerDeleteSuccess() {
test(function headerGetSuccess() { test(function headerGetSuccess() {
const headers = new Headers(headerDict); const headers = new Headers(headerDict);
for (const name in headerDict) { for (const name in headerDict) {
assertEqual(headers.get(name), String(headerDict[name])); assertEquals(headers.get(name), String(headerDict[name]));
assertEqual(headers.get("nameNotInHeaders"), null); assertEquals(headers.get("nameNotInHeaders"), null);
} }
}); });
@ -107,7 +107,7 @@ test(function headerEntriesSuccess() {
const key = it[0]; const key = it[0];
const value = it[1]; const value = it[1];
assert(headers.has(key)); assert(headers.has(key));
assertEqual(value, headers.get(key)); assertEquals(value, headers.get(key));
} }
}); });
@ -151,11 +151,11 @@ test(function headerForEachSuccess() {
}); });
let callNum = 0; let callNum = 0;
headers.forEach((value, key, container) => { headers.forEach((value, key, container) => {
assertEqual(headers, container); assertEquals(headers, container);
assertEqual(value, headerEntriesDict[key]); assertEquals(value, headerEntriesDict[key]);
callNum++; callNum++;
}); });
assertEqual(callNum, keys.length); assertEquals(callNum, keys.length);
}); });
test(function headerSymbolIteratorSuccess() { test(function headerSymbolIteratorSuccess() {
@ -165,7 +165,7 @@ test(function headerSymbolIteratorSuccess() {
const key = header[0]; const key = header[0];
const value = header[1]; const value = header[1];
assert(headers.has(key)); assert(headers.has(key));
assertEqual(value, headers.get(key)); assertEquals(value, headers.get(key));
} }
}); });
@ -228,7 +228,7 @@ test(function headerIllegalReject() {
} catch (e) { } catch (e) {
errorCount++; errorCount++;
} }
assertEqual(errorCount, 9); assertEquals(errorCount, 9);
// 'o k' is valid value but invalid name // 'o k' is valid value but invalid name
new Headers({ "He-y": "o k" }); new Headers({ "He-y": "o k" });
}); });
@ -248,7 +248,7 @@ test(function headerParamsShouldThrowTypeError() {
} }
} }
assertEqual(hasThrown, 2); assertEquals(hasThrown, 2);
}); });
test(function headerParamsArgumentsCheck() { test(function headerParamsArgumentsCheck() {
@ -271,8 +271,8 @@ test(function headerParamsArgumentsCheck() {
hasThrown = 3; hasThrown = 3;
} }
} }
assertEqual(hasThrown, 2); assertEquals(hasThrown, 2);
assertEqual( assertEquals(
errMsg, errMsg,
`Headers.${method} requires at least 1 argument, but only 0 present` `Headers.${method} requires at least 1 argument, but only 0 present`
); );
@ -294,8 +294,8 @@ test(function headerParamsArgumentsCheck() {
hasThrown = 3; hasThrown = 3;
} }
} }
assertEqual(hasThrown, 2); assertEquals(hasThrown, 2);
assertEqual( assertEquals(
errMsg, errMsg,
`Headers.${method} requires at least 2 arguments, but only 0 present` `Headers.${method} requires at least 2 arguments, but only 0 present`
); );
@ -313,8 +313,8 @@ test(function headerParamsArgumentsCheck() {
hasThrown = 3; hasThrown = 3;
} }
} }
assertEqual(hasThrown, 2); assertEquals(hasThrown, 2);
assertEqual( assertEquals(
errMsg, errMsg,
`Headers.${method} requires at least 2 arguments, but only 1 present` `Headers.${method} requires at least 2 arguments, but only 1 present`
); );

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, testPerm, assert, assertEqual } from "./test_util.ts"; import { test, testPerm, assert, assertEquals } from "./test_util.ts";
testPerm({ write: true }, function makeTempDirSyncSuccess() { testPerm({ write: true }, function makeTempDirSyncSuccess() {
const dir1 = Deno.makeTempDirSync({ prefix: "hello", suffix: "world" }); const dir1 = Deno.makeTempDirSync({ prefix: "hello", suffix: "world" });
@ -23,8 +23,8 @@ testPerm({ write: true }, function makeTempDirSyncSuccess() {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
test(function makeTempDirSyncPerm() { test(function makeTempDirSyncPerm() {
@ -35,8 +35,8 @@ test(function makeTempDirSyncPerm() {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
testPerm({ write: true }, async function makeTempDirSuccess() { testPerm({ write: true }, async function makeTempDirSuccess() {
@ -61,6 +61,6 @@ testPerm({ write: true }, async function makeTempDirSuccess() {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assert, assertEqual } from "../test_util.ts"; import { test, assert, assertEquals } from "../test_util.ts";
function setup() { function setup() {
const dataSymbol = Symbol("data symbol"); const dataSymbol = Symbol("data symbol");
@ -32,9 +32,9 @@ test(function testDomIterable() {
const domIterable = new DomIterable(fixture); const domIterable = new DomIterable(fixture);
assertEqual(Array.from(domIterable.entries()), fixture); assertEquals(Array.from(domIterable.entries()), fixture);
assertEqual(Array.from(domIterable.values()), [1, 2]); assertEquals(Array.from(domIterable.values()), [1, 2]);
assertEqual(Array.from(domIterable.keys()), ["foo", "bar"]); assertEquals(Array.from(domIterable.keys()), ["foo", "bar"]);
let result: Array<[string, number]> = []; let result: Array<[string, number]> = [];
for (const [key, value] of domIterable) { for (const [key, value] of domIterable) {
@ -42,21 +42,21 @@ test(function testDomIterable() {
assert(value != null); assert(value != null);
result.push([key, value]); result.push([key, value]);
} }
assertEqual(fixture, result); assertEquals(fixture, result);
result = []; result = [];
const scope = {}; const scope = {};
function callback(value, key, parent) { function callback(value, key, parent) {
assertEqual(parent, domIterable); assertEquals(parent, domIterable);
assert(key != null); assert(key != null);
assert(value != null); assert(value != null);
assert(this === scope); assert(this === scope);
result.push([key, value]); result.push([key, value]);
} }
domIterable.forEach(callback, scope); domIterable.forEach(callback, scope);
assertEqual(fixture, result); assertEquals(fixture, result);
assertEqual(DomIterable.name, Base.name); assertEquals(DomIterable.name, Base.name);
}); });
test(function testDomIterableScope() { test(function testDomIterableScope() {
@ -68,7 +68,7 @@ test(function testDomIterableScope() {
// tslint:disable-next-line:no-any // tslint:disable-next-line:no-any
function checkScope(thisArg: any, expected: any) { function checkScope(thisArg: any, expected: any) {
function callback() { function callback() {
assertEqual(this, expected); assertEquals(this, expected);
} }
domIterable.forEach(callback, thisArg); domIterable.forEach(callback, thisArg);
} }

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEqual } from "./test_util.ts"; import { testPerm, assert, assertEquals } from "./test_util.ts";
testPerm({ read: true, write: true }, function mkdirSyncSuccess() { testPerm({ read: true, write: true }, function mkdirSyncSuccess() {
const path = Deno.makeTempDirSync() + "/dir"; const path = Deno.makeTempDirSync() + "/dir";
@ -14,7 +14,7 @@ testPerm({ read: true, write: true }, function mkdirSyncMode() {
const pathInfo = Deno.statSync(path); const pathInfo = Deno.statSync(path);
if (pathInfo.mode !== null) { if (pathInfo.mode !== null) {
// Skip windows // Skip windows
assertEqual(pathInfo.mode & 0o777, 0o755); assertEquals(pathInfo.mode & 0o777, 0o755);
} }
}); });
@ -25,8 +25,8 @@ testPerm({ write: false }, function mkdirSyncPerm() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
testPerm({ read: true, write: true }, async function mkdirSuccess() { testPerm({ read: true, write: true }, async function mkdirSuccess() {
@ -43,8 +43,8 @@ testPerm({ write: true }, function mkdirErrIfExists() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.AlreadyExists); assertEquals(err.kind, Deno.ErrorKind.AlreadyExists);
assertEqual(err.name, "AlreadyExists"); assertEquals(err.name, "AlreadyExists");
}); });
testPerm({ read: true, write: true }, function mkdirSyncRecursive() { testPerm({ read: true, write: true }, function mkdirSyncRecursive() {

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEqual } from "./test_util.ts"; import { testPerm, assert, assertEquals } from "./test_util.ts";
testPerm({ net: true }, function netListenClose() { testPerm({ net: true }, function netListenClose() {
const listener = Deno.listen("tcp", "127.0.0.1:4500"); const listener = Deno.listen("tcp", "127.0.0.1:4500");
@ -17,17 +17,17 @@ testPerm({ net: true }, async function netCloseWhileAccept() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assertEqual(err.kind, Deno.ErrorKind.Other); assertEquals(err.kind, Deno.ErrorKind.Other);
assertEqual(err.message, "Listener has been closed"); assertEquals(err.message, "Listener has been closed");
}); });
testPerm({ net: true }, async function netConcurrentAccept() { testPerm({ net: true }, async function netConcurrentAccept() {
const listener = Deno.listen("tcp", ":4502"); const listener = Deno.listen("tcp", ":4502");
let acceptErrCount = 0; let acceptErrCount = 0;
const checkErr = e => { const checkErr = e => {
assertEqual(e.kind, Deno.ErrorKind.Other); assertEquals(e.kind, Deno.ErrorKind.Other);
if (e.message === "Listener has been closed") { if (e.message === "Listener has been closed") {
assertEqual(acceptErrCount, 1); assertEquals(acceptErrCount, 1);
} else if (e.message === "Another accept task is ongoing") { } else if (e.message === "Another accept task is ongoing") {
acceptErrCount++; acceptErrCount++;
} else { } else {
@ -39,7 +39,7 @@ testPerm({ net: true }, async function netConcurrentAccept() {
await Promise.race([p, p1]); await Promise.race([p, p1]);
listener.close(); listener.close();
await [p, p1]; await [p, p1];
assertEqual(acceptErrCount, 1); assertEquals(acceptErrCount, 1);
}); });
testPerm({ net: true }, async function netDialListen() { testPerm({ net: true }, async function netDialListen() {
@ -51,20 +51,20 @@ testPerm({ net: true }, async function netDialListen() {
const conn = await Deno.dial("tcp", "127.0.0.1:4500"); const conn = await Deno.dial("tcp", "127.0.0.1:4500");
const buf = new Uint8Array(1024); const buf = new Uint8Array(1024);
const readResult = await conn.read(buf); const readResult = await conn.read(buf);
assertEqual(3, readResult.nread); assertEquals(3, readResult.nread);
assertEqual(1, buf[0]); assertEquals(1, buf[0]);
assertEqual(2, buf[1]); assertEquals(2, buf[1]);
assertEqual(3, buf[2]); assertEquals(3, buf[2]);
assert(conn.rid > 0); assert(conn.rid > 0);
// TODO Currently ReadResult does not properly transmit EOF in the same call. // TODO Currently ReadResult does not properly transmit EOF in the same call.
// it requires a second call to get the EOF. Either ReadResult to be an // it requires a second call to get the EOF. Either ReadResult to be an
// integer in which 0 signifies EOF or the handler should be modified so that // integer in which 0 signifies EOF or the handler should be modified so that
// EOF is properly transmitted. // EOF is properly transmitted.
assertEqual(false, readResult.eof); assertEquals(false, readResult.eof);
const readResult2 = await conn.read(buf); const readResult2 = await conn.read(buf);
assertEqual(true, readResult2.eof); assertEquals(true, readResult2.eof);
listener.close(); listener.close();
conn.close(); conn.close();
@ -81,10 +81,10 @@ testPerm({ net: true }, async function netCloseReadSuccess() {
await conn.write(new Uint8Array([1, 2, 3])); await conn.write(new Uint8Array([1, 2, 3]));
const buf = new Uint8Array(1024); const buf = new Uint8Array(1024);
const readResult = await conn.read(buf); const readResult = await conn.read(buf);
assertEqual(3, readResult.nread); assertEquals(3, readResult.nread);
assertEqual(4, buf[0]); assertEquals(4, buf[0]);
assertEqual(5, buf[1]); assertEquals(5, buf[1]);
assertEqual(6, buf[2]); assertEquals(6, buf[2]);
conn.close(); conn.close();
closeDeferred.resolve(); closeDeferred.resolve();
}); });
@ -93,8 +93,8 @@ testPerm({ net: true }, async function netCloseReadSuccess() {
closeReadDeferred.resolve(); closeReadDeferred.resolve();
const buf = new Uint8Array(1024); const buf = new Uint8Array(1024);
const readResult = await conn.read(buf); const readResult = await conn.read(buf);
assertEqual(0, readResult.nread); // No error, read nothing assertEquals(0, readResult.nread); // No error, read nothing
assertEqual(true, readResult.eof); // with immediate EOF assertEquals(true, readResult.eof); // with immediate EOF
// Ensure closeRead does not impact write // Ensure closeRead does not impact write
await conn.write(new Uint8Array([4, 5, 6])); await conn.write(new Uint8Array([4, 5, 6]));
await closeDeferred.promise; await closeDeferred.promise;
@ -123,8 +123,8 @@ testPerm({ net: true }, async function netDoubleCloseRead() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assertEqual(err.kind, Deno.ErrorKind.NotConnected); assertEquals(err.kind, Deno.ErrorKind.NotConnected);
assertEqual(err.name, "NotConnected"); assertEquals(err.name, "NotConnected");
closeDeferred.resolve(); closeDeferred.resolve();
listener.close(); listener.close();
conn.close(); conn.close();
@ -146,10 +146,10 @@ testPerm({ net: true }, async function netCloseWriteSuccess() {
const buf = new Uint8Array(1024); const buf = new Uint8Array(1024);
// Check read not impacted // Check read not impacted
const readResult = await conn.read(buf); const readResult = await conn.read(buf);
assertEqual(3, readResult.nread); assertEquals(3, readResult.nread);
assertEqual(1, buf[0]); assertEquals(1, buf[0]);
assertEqual(2, buf[1]); assertEquals(2, buf[1]);
assertEqual(3, buf[2]); assertEquals(3, buf[2]);
// Check write should be closed // Check write should be closed
let err; let err;
try { try {
@ -158,8 +158,8 @@ testPerm({ net: true }, async function netCloseWriteSuccess() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assertEqual(err.kind, Deno.ErrorKind.BrokenPipe); assertEquals(err.kind, Deno.ErrorKind.BrokenPipe);
assertEqual(err.name, "BrokenPipe"); assertEquals(err.name, "BrokenPipe");
closeDeferred.resolve(); closeDeferred.resolve();
listener.close(); listener.close();
conn.close(); conn.close();
@ -185,8 +185,8 @@ testPerm({ net: true }, async function netDoubleCloseWrite() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assertEqual(err.kind, Deno.ErrorKind.NotConnected); assertEquals(err.kind, Deno.ErrorKind.NotConnected);
assertEqual(err.name, "NotConnected"); assertEquals(err.name, "NotConnected");
closeDeferred.resolve(); closeDeferred.resolve();
listener.close(); listener.close();
conn.close(); conn.close();

View file

@ -1,12 +1,12 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, testPerm, assert, assertEqual } from "./test_util.ts"; import { test, testPerm, assert, assertEquals } from "./test_util.ts";
testPerm({ env: true }, function envSuccess() { testPerm({ env: true }, function envSuccess() {
const env = Deno.env(); const env = Deno.env();
assert(env !== null); assert(env !== null);
env.test_var = "Hello World"; env.test_var = "Hello World";
const newEnv = Deno.env(); const newEnv = Deno.env();
assertEqual(env.test_var, newEnv.test_var); assertEquals(env.test_var, newEnv.test_var);
}); });
test(function envFailure() { test(function envFailure() {
@ -15,8 +15,8 @@ test(function envFailure() {
const env = Deno.env(); const env = Deno.env();
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEqual } from "./test_util.ts"; import { testPerm, assert, assertEquals } from "./test_util.ts";
import { Permission } from "deno"; import { Permission } from "deno";
const knownPermissions: Permission[] = ["run", "read", "write", "net", "env"]; const knownPermissions: Permission[] = ["run", "read", "write", "net", "env"];
@ -9,14 +9,14 @@ for (let grant of knownPermissions) {
const perms = Deno.permissions(); const perms = Deno.permissions();
assert(perms !== null); assert(perms !== null);
for (const perm in perms) { for (const perm in perms) {
assertEqual(perms[perm], perm === grant); assertEquals(perms[perm], perm === grant);
} }
Deno.revokePermission(grant); Deno.revokePermission(grant);
const revoked = Deno.permissions(); const revoked = Deno.permissions();
for (const perm in revoked) { for (const perm in revoked) {
assertEqual(revoked[perm], false); assertEquals(revoked[perm], false);
} }
}); });
} }

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, testPerm, assert, assertEqual } from "./test_util.ts"; import { test, testPerm, assert, assertEquals } from "./test_util.ts";
const { run, DenoError, ErrorKind } = Deno; const { run, DenoError, ErrorKind } = Deno;
test(function runPermissions() { test(function runPermissions() {
@ -8,8 +8,8 @@ test(function runPermissions() {
Deno.run({ args: ["python", "-c", "print('hello world')"] }); Deno.run({ args: ["python", "-c", "print('hello world')"] });
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -20,9 +20,9 @@ testPerm({ run: true }, async function runSuccess() {
}); });
const status = await p.status(); const status = await p.status();
console.log("status", status); console.log("status", status);
assertEqual(status.success, true); assertEquals(status.success, true);
assertEqual(status.code, 0); assertEquals(status.code, 0);
assertEqual(status.signal, undefined); assertEquals(status.signal, undefined);
p.close(); p.close();
}); });
@ -31,9 +31,9 @@ testPerm({ run: true }, async function runCommandFailedWithCode() {
args: ["python", "-c", "import sys;sys.exit(41 + 1)"] args: ["python", "-c", "import sys;sys.exit(41 + 1)"]
}); });
let status = await p.status(); let status = await p.status();
assertEqual(status.success, false); assertEquals(status.success, false);
assertEqual(status.code, 42); assertEquals(status.code, 42);
assertEqual(status.signal, undefined); assertEquals(status.signal, undefined);
p.close(); p.close();
}); });
@ -45,9 +45,9 @@ testPerm({ run: true }, async function runCommandFailedWithSignal() {
args: ["python", "-c", "import os;os.kill(os.getpid(), 9)"] args: ["python", "-c", "import os;os.kill(os.getpid(), 9)"]
}); });
const status = await p.status(); const status = await p.status();
assertEqual(status.success, false); assertEquals(status.success, false);
assertEqual(status.code, undefined); assertEquals(status.code, undefined);
assertEqual(status.signal, 9); assertEquals(status.signal, 9);
p.close(); p.close();
}); });
@ -60,7 +60,7 @@ testPerm({ run: true }, function runNotFound() {
} }
assert(error !== undefined); assert(error !== undefined);
assert(error instanceof DenoError); assert(error instanceof DenoError);
assertEqual(error.kind, ErrorKind.NotFound); assertEquals(error.kind, ErrorKind.NotFound);
}); });
testPerm({ write: true, run: true }, async function runWithCwdIsAsync() { testPerm({ write: true, run: true }, async function runWithCwdIsAsync() {
@ -97,9 +97,9 @@ while True:
Deno.writeFileSync(`${cwd}/${exitCodeFile}`, enc.encode(`${code}`)); Deno.writeFileSync(`${cwd}/${exitCodeFile}`, enc.encode(`${code}`));
const status = await p.status(); const status = await p.status();
assertEqual(status.success, false); assertEquals(status.success, false);
assertEqual(status.code, code); assertEquals(status.code, code);
assertEqual(status.signal, undefined); assertEquals(status.signal, undefined);
p.close(); p.close();
}); });
@ -113,14 +113,14 @@ testPerm({ run: true }, async function runStdinPiped() {
let msg = new TextEncoder().encode("hello"); let msg = new TextEncoder().encode("hello");
let n = await p.stdin.write(msg); let n = await p.stdin.write(msg);
assertEqual(n, msg.byteLength); assertEquals(n, msg.byteLength);
p.stdin.close(); p.stdin.close();
const status = await p.status(); const status = await p.status();
assertEqual(status.success, true); assertEquals(status.success, true);
assertEqual(status.code, 0); assertEquals(status.code, 0);
assertEqual(status.signal, undefined); assertEquals(status.signal, undefined);
p.close(); p.close();
}); });
@ -134,19 +134,19 @@ testPerm({ run: true }, async function runStdoutPiped() {
const data = new Uint8Array(10); const data = new Uint8Array(10);
let r = await p.stdout.read(data); let r = await p.stdout.read(data);
assertEqual(r.nread, 5); assertEquals(r.nread, 5);
assertEqual(r.eof, false); assertEquals(r.eof, false);
const s = new TextDecoder().decode(data.subarray(0, r.nread)); const s = new TextDecoder().decode(data.subarray(0, r.nread));
assertEqual(s, "hello"); assertEquals(s, "hello");
r = await p.stdout.read(data); r = await p.stdout.read(data);
assertEqual(r.nread, 0); assertEquals(r.nread, 0);
assertEqual(r.eof, true); assertEquals(r.eof, true);
p.stdout.close(); p.stdout.close();
const status = await p.status(); const status = await p.status();
assertEqual(status.success, true); assertEquals(status.success, true);
assertEqual(status.code, 0); assertEquals(status.code, 0);
assertEqual(status.signal, undefined); assertEquals(status.signal, undefined);
p.close(); p.close();
}); });
@ -160,19 +160,19 @@ testPerm({ run: true }, async function runStderrPiped() {
const data = new Uint8Array(10); const data = new Uint8Array(10);
let r = await p.stderr.read(data); let r = await p.stderr.read(data);
assertEqual(r.nread, 5); assertEquals(r.nread, 5);
assertEqual(r.eof, false); assertEquals(r.eof, false);
const s = new TextDecoder().decode(data.subarray(0, r.nread)); const s = new TextDecoder().decode(data.subarray(0, r.nread));
assertEqual(s, "hello"); assertEquals(s, "hello");
r = await p.stderr.read(data); r = await p.stderr.read(data);
assertEqual(r.nread, 0); assertEquals(r.nread, 0);
assertEqual(r.eof, true); assertEquals(r.eof, true);
p.stderr.close(); p.stderr.close();
const status = await p.status(); const status = await p.status();
assertEqual(status.success, true); assertEquals(status.success, true);
assertEqual(status.code, 0); assertEquals(status.code, 0);
assertEqual(status.signal, undefined); assertEquals(status.signal, undefined);
p.close(); p.close();
}); });
@ -183,7 +183,7 @@ testPerm({ run: true }, async function runOutput() {
}); });
const output = await p.output(); const output = await p.output();
const s = new TextDecoder().decode(output); const s = new TextDecoder().decode(output);
assertEqual(s, "hello"); assertEquals(s, "hello");
p.close(); p.close();
}); });
@ -202,6 +202,6 @@ testPerm({ run: true }, async function runEnv() {
}); });
const output = await p.output(); const output = await p.output();
const s = new TextDecoder().decode(output); const s = new TextDecoder().decode(output);
assertEqual(s, "01234567"); assertEquals(s, "01234567");
p.close(); p.close();
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEqual } from "./test_util.ts"; import { testPerm, assert, assertEquals } from "./test_util.ts";
type FileInfo = Deno.FileInfo; type FileInfo = Deno.FileInfo;
@ -13,13 +13,13 @@ function assertSameContent(files: FileInfo[]) {
} }
if (file.name === "002_hello.ts") { if (file.name === "002_hello.ts") {
assertEqual(file.path, `tests/${file.name}`); assertEquals(file.path, `tests/${file.name}`);
assertEqual(file.mode!, Deno.statSync(`tests/${file.name}`).mode!); assertEquals(file.mode!, Deno.statSync(`tests/${file.name}`).mode!);
counter++; counter++;
} }
} }
assertEqual(counter, 2); assertEquals(counter, 2);
} }
testPerm({ read: true }, function readDirSyncSuccess() { testPerm({ read: true }, function readDirSyncSuccess() {
@ -33,8 +33,8 @@ testPerm({ read: false }, function readDirSyncPerm() {
const files = Deno.readDirSync("tests/"); const files = Deno.readDirSync("tests/");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -47,10 +47,10 @@ testPerm({ read: true }, function readDirSyncNotDir() {
src = Deno.readDirSync("package.json"); src = Deno.readDirSync("package.json");
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assertEqual(err.kind, Deno.ErrorKind.Other); assertEquals(err.kind, Deno.ErrorKind.Other);
} }
assert(caughtError); assert(caughtError);
assertEqual(src, undefined); assertEquals(src, undefined);
}); });
testPerm({ read: true }, function readDirSyncNotFound() { testPerm({ read: true }, function readDirSyncNotFound() {
@ -61,10 +61,10 @@ testPerm({ read: true }, function readDirSyncNotFound() {
src = Deno.readDirSync("bad_dir_name"); src = Deno.readDirSync("bad_dir_name");
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
} }
assert(caughtError); assert(caughtError);
assertEqual(src, undefined); assertEquals(src, undefined);
}); });
testPerm({ read: true }, async function readDirSuccess() { testPerm({ read: true }, async function readDirSuccess() {
@ -78,8 +78,8 @@ testPerm({ read: false }, async function readDirPerm() {
const files = await Deno.readDir("tests/"); const files = await Deno.readDir("tests/");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEqual } from "./test_util.ts"; import { testPerm, assert, assertEquals } from "./test_util.ts";
testPerm({ read: true }, function readFileSyncSuccess() { testPerm({ read: true }, function readFileSyncSuccess() {
const data = Deno.readFileSync("package.json"); const data = Deno.readFileSync("package.json");
@ -7,7 +7,7 @@ testPerm({ read: true }, function readFileSyncSuccess() {
const decoder = new TextDecoder("utf-8"); const decoder = new TextDecoder("utf-8");
const json = decoder.decode(data); const json = decoder.decode(data);
const pkg = JSON.parse(json); const pkg = JSON.parse(json);
assertEqual(pkg.name, "deno"); assertEquals(pkg.name, "deno");
}); });
testPerm({ read: false }, function readFileSyncPerm() { testPerm({ read: false }, function readFileSyncPerm() {
@ -16,8 +16,8 @@ testPerm({ read: false }, function readFileSyncPerm() {
const data = Deno.readFileSync("package.json"); const data = Deno.readFileSync("package.json");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -29,7 +29,7 @@ testPerm({ read: true }, function readFileSyncNotFound() {
data = Deno.readFileSync("bad_filename"); data = Deno.readFileSync("bad_filename");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.NotFound); assertEquals(e.kind, Deno.ErrorKind.NotFound);
} }
assert(caughtError); assert(caughtError);
assert(data === undefined); assert(data === undefined);
@ -41,7 +41,7 @@ testPerm({ read: true }, async function readFileSuccess() {
const decoder = new TextDecoder("utf-8"); const decoder = new TextDecoder("utf-8");
const json = decoder.decode(data); const json = decoder.decode(data);
const pkg = JSON.parse(json); const pkg = JSON.parse(json);
assertEqual(pkg.name, "deno"); assertEquals(pkg.name, "deno");
}); });
testPerm({ read: false }, async function readFilePerm() { testPerm({ read: false }, async function readFilePerm() {
@ -50,8 +50,8 @@ testPerm({ read: false }, async function readFilePerm() {
await Deno.readFile("package.json"); await Deno.readFile("package.json");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEqual } from "./test_util.ts"; import { testPerm, assert, assertEquals } from "./test_util.ts";
testPerm({ write: true, read: true }, function readlinkSyncSuccess() { testPerm({ write: true, read: true }, function readlinkSyncSuccess() {
const testDir = Deno.makeTempDirSync(); const testDir = Deno.makeTempDirSync();
@ -11,7 +11,7 @@ testPerm({ write: true, read: true }, function readlinkSyncSuccess() {
if (Deno.build.os !== "win") { if (Deno.build.os !== "win") {
Deno.symlinkSync(target, symlink); Deno.symlinkSync(target, symlink);
const targetPath = Deno.readlinkSync(symlink); const targetPath = Deno.readlinkSync(symlink);
assertEqual(targetPath, target); assertEquals(targetPath, target);
} }
}); });
@ -21,8 +21,8 @@ testPerm({ read: false }, async function readlinkSyncPerm() {
Deno.readlinkSync("/symlink"); Deno.readlinkSync("/symlink");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -34,10 +34,10 @@ testPerm({ read: true }, function readlinkSyncNotFound() {
data = Deno.readlinkSync("bad_filename"); data = Deno.readlinkSync("bad_filename");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.NotFound); assertEquals(e.kind, Deno.ErrorKind.NotFound);
} }
assert(caughtError); assert(caughtError);
assertEqual(data, undefined); assertEquals(data, undefined);
}); });
testPerm({ write: true, read: true }, async function readlinkSuccess() { testPerm({ write: true, read: true }, async function readlinkSuccess() {
@ -50,7 +50,7 @@ testPerm({ write: true, read: true }, async function readlinkSuccess() {
if (Deno.build.os !== "win") { if (Deno.build.os !== "win") {
Deno.symlinkSync(target, symlink); Deno.symlinkSync(target, symlink);
const targetPath = await Deno.readlink(symlink); const targetPath = await Deno.readlink(symlink);
assertEqual(targetPath, target); assertEquals(targetPath, target);
} }
}); });
@ -60,8 +60,8 @@ testPerm({ read: false }, async function readlinkPerm() {
await Deno.readlink("/symlink"); await Deno.readlink("/symlink");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEqual } from "./test_util.ts"; import { testPerm, assert, assertEquals } from "./test_util.ts";
// SYNC // SYNC
@ -18,8 +18,8 @@ testPerm({ write: true }, function removeSyncDirSuccess() {
err = e; err = e;
} }
// Directory is gone // Directory is gone
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: true }, function removeSyncFileSuccess() { testPerm({ write: true }, function removeSyncFileSuccess() {
@ -39,8 +39,8 @@ testPerm({ write: true }, function removeSyncFileSuccess() {
err = e; err = e;
} }
// File is gone // File is gone
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: true }, function removeSyncFail() { testPerm({ write: true }, function removeSyncFail() {
@ -61,8 +61,8 @@ testPerm({ write: true }, function removeSyncFail() {
err = e; err = e;
} }
// TODO(ry) Is Other really the error we should get here? What would Go do? // TODO(ry) Is Other really the error we should get here? What would Go do?
assertEqual(err.kind, Deno.ErrorKind.Other); assertEquals(err.kind, Deno.ErrorKind.Other);
assertEqual(err.name, "Other"); assertEquals(err.name, "Other");
// NON-EXISTENT DIRECTORY/FILE // NON-EXISTENT DIRECTORY/FILE
try { try {
// Non-existent // Non-existent
@ -70,8 +70,8 @@ testPerm({ write: true }, function removeSyncFail() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: false }, function removeSyncPerm() { testPerm({ write: false }, function removeSyncPerm() {
@ -81,8 +81,8 @@ testPerm({ write: false }, function removeSyncPerm() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
testPerm({ write: true }, function removeAllSyncDirSuccess() { testPerm({ write: true }, function removeAllSyncDirSuccess() {
@ -100,8 +100,8 @@ testPerm({ write: true }, function removeAllSyncDirSuccess() {
err = e; err = e;
} }
// Directory is gone // Directory is gone
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
// REMOVE NON-EMPTY DIRECTORY // REMOVE NON-EMPTY DIRECTORY
path = Deno.makeTempDirSync() + "/dir/subdir"; path = Deno.makeTempDirSync() + "/dir/subdir";
const subPath = path + "/subsubdir"; const subPath = path + "/subsubdir";
@ -119,8 +119,8 @@ testPerm({ write: true }, function removeAllSyncDirSuccess() {
err = e; err = e;
} }
// Directory is gone // Directory is gone
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: true }, function removeAllSyncFileSuccess() { testPerm({ write: true }, function removeAllSyncFileSuccess() {
@ -140,8 +140,8 @@ testPerm({ write: true }, function removeAllSyncFileSuccess() {
err = e; err = e;
} }
// File is gone // File is gone
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: true }, function removeAllSyncFail() { testPerm({ write: true }, function removeAllSyncFail() {
@ -153,8 +153,8 @@ testPerm({ write: true }, function removeAllSyncFail() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: false }, function removeAllSyncPerm() { testPerm({ write: false }, function removeAllSyncPerm() {
@ -164,8 +164,8 @@ testPerm({ write: false }, function removeAllSyncPerm() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
// ASYNC // ASYNC
@ -185,8 +185,8 @@ testPerm({ write: true }, async function removeDirSuccess() {
err = e; err = e;
} }
// Directory is gone // Directory is gone
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: true }, async function removeFileSuccess() { testPerm({ write: true }, async function removeFileSuccess() {
@ -206,8 +206,8 @@ testPerm({ write: true }, async function removeFileSuccess() {
err = e; err = e;
} }
// File is gone // File is gone
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: true }, async function removeFail() { testPerm({ write: true }, async function removeFail() {
@ -227,8 +227,8 @@ testPerm({ write: true }, async function removeFail() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.Other); assertEquals(err.kind, Deno.ErrorKind.Other);
assertEqual(err.name, "Other"); assertEquals(err.name, "Other");
// NON-EXISTENT DIRECTORY/FILE // NON-EXISTENT DIRECTORY/FILE
try { try {
// Non-existent // Non-existent
@ -236,8 +236,8 @@ testPerm({ write: true }, async function removeFail() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: false }, async function removePerm() { testPerm({ write: false }, async function removePerm() {
@ -247,8 +247,8 @@ testPerm({ write: false }, async function removePerm() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
testPerm({ write: true }, async function removeAllDirSuccess() { testPerm({ write: true }, async function removeAllDirSuccess() {
@ -266,8 +266,8 @@ testPerm({ write: true }, async function removeAllDirSuccess() {
err = e; err = e;
} }
// Directory is gone // Directory is gone
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
// REMOVE NON-EMPTY DIRECTORY // REMOVE NON-EMPTY DIRECTORY
path = Deno.makeTempDirSync() + "/dir/subdir"; path = Deno.makeTempDirSync() + "/dir/subdir";
const subPath = path + "/subsubdir"; const subPath = path + "/subsubdir";
@ -285,8 +285,8 @@ testPerm({ write: true }, async function removeAllDirSuccess() {
err = e; err = e;
} }
// Directory is gone // Directory is gone
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: true }, async function removeAllFileSuccess() { testPerm({ write: true }, async function removeAllFileSuccess() {
@ -306,8 +306,8 @@ testPerm({ write: true }, async function removeAllFileSuccess() {
err = e; err = e;
} }
// File is gone // File is gone
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: true }, async function removeAllFail() { testPerm({ write: true }, async function removeAllFail() {
@ -319,8 +319,8 @@ testPerm({ write: true }, async function removeAllFail() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
}); });
testPerm({ write: false }, async function removeAllPerm() { testPerm({ write: false }, async function removeAllPerm() {
@ -330,6 +330,6 @@ testPerm({ write: false }, async function removeAllPerm() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEqual } from "./test_util.ts"; import { testPerm, assert, assertEquals } from "./test_util.ts";
testPerm({ read: true, write: true }, function renameSyncSuccess() { testPerm({ read: true, write: true }, function renameSyncSuccess() {
const testDir = Deno.makeTempDirSync(); const testDir = Deno.makeTempDirSync();
@ -17,10 +17,10 @@ testPerm({ read: true, write: true }, function renameSyncSuccess() {
oldPathInfo = Deno.statSync(oldpath); oldPathInfo = Deno.statSync(oldpath);
} catch (e) { } catch (e) {
caughtErr = true; caughtErr = true;
assertEqual(e.kind, Deno.ErrorKind.NotFound); assertEquals(e.kind, Deno.ErrorKind.NotFound);
} }
assert(caughtErr); assert(caughtErr);
assertEqual(oldPathInfo, undefined); assertEquals(oldPathInfo, undefined);
}); });
testPerm({ read: true, write: false }, function renameSyncPerm() { testPerm({ read: true, write: false }, function renameSyncPerm() {
@ -32,8 +32,8 @@ testPerm({ read: true, write: false }, function renameSyncPerm() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
testPerm({ read: true, write: true }, async function renameSuccess() { testPerm({ read: true, write: true }, async function renameSuccess() {
@ -52,8 +52,8 @@ testPerm({ read: true, write: true }, async function renameSuccess() {
oldPathInfo = Deno.statSync(oldpath); oldPathInfo = Deno.statSync(oldpath);
} catch (e) { } catch (e) {
caughtErr = true; caughtErr = true;
assertEqual(e.kind, Deno.ErrorKind.NotFound); assertEquals(e.kind, Deno.ErrorKind.NotFound);
} }
assert(caughtErr); assert(caughtErr);
assertEqual(oldPathInfo, undefined); assertEquals(oldPathInfo, undefined);
}); });

View file

@ -1,12 +1,12 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, testPerm, assertEqual } from "./test_util.ts"; import { test, testPerm, assertEquals } from "./test_util.ts";
test(function resourcesStdio() { test(function resourcesStdio() {
const res = Deno.resources(); const res = Deno.resources();
assertEqual(res[0], "stdin"); assertEquals(res[0], "stdin");
assertEqual(res[1], "stdout"); assertEquals(res[1], "stdout");
assertEqual(res[2], "stderr"); assertEquals(res[2], "stderr");
}); });
testPerm({ net: true }, async function resourcesNet() { testPerm({ net: true }, async function resourcesNet() {
@ -17,8 +17,8 @@ testPerm({ net: true }, async function resourcesNet() {
const listenerConn = await listener.accept(); const listenerConn = await listener.accept();
const res = Deno.resources(); const res = Deno.resources();
assertEqual(Object.values(res).filter(r => r === "tcpListener").length, 1); assertEquals(Object.values(res).filter(r => r === "tcpListener").length, 1);
assertEqual(Object.values(res).filter(r => r === "tcpStream").length, 2); assertEquals(Object.values(res).filter(r => r === "tcpStream").length, 2);
listenerConn.close(); listenerConn.close();
dialerConn.close(); dialerConn.close();
@ -31,12 +31,12 @@ testPerm({ read: true }, async function resourcesFile() {
const resourcesAfter = Deno.resources(); const resourcesAfter = Deno.resources();
// check that exactly one new resource (file) was added // check that exactly one new resource (file) was added
assertEqual( assertEquals(
Object.keys(resourcesAfter).length, Object.keys(resourcesAfter).length,
Object.keys(resourcesBefore).length + 1 Object.keys(resourcesBefore).length + 1
); );
const newRid = Object.keys(resourcesAfter).find(rid => { const newRid = Object.keys(resourcesAfter).find(rid => {
return !resourcesBefore.hasOwnProperty(rid); return !resourcesBefore.hasOwnProperty(rid);
}); });
assertEqual(resourcesAfter[newRid], "fsFile"); assertEquals(resourcesAfter[newRid], "fsFile");
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEqual } from "./test_util.ts"; import { testPerm, assert, assertEquals } from "./test_util.ts";
// TODO Add tests for modified, accessed, and created fields once there is a way // TODO Add tests for modified, accessed, and created fields once there is a way
// to create temp files. // to create temp files.
@ -23,8 +23,8 @@ testPerm({ read: false }, async function statSyncPerm() {
Deno.statSync("package.json"); Deno.statSync("package.json");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -37,12 +37,12 @@ testPerm({ read: true }, async function statSyncNotFound() {
badInfo = Deno.statSync("bad_file_name"); badInfo = Deno.statSync("bad_file_name");
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
} }
assert(caughtError); assert(caughtError);
assertEqual(badInfo, undefined); assertEquals(badInfo, undefined);
}); });
testPerm({ read: true }, async function lstatSyncSuccess() { testPerm({ read: true }, async function lstatSyncSuccess() {
@ -65,8 +65,8 @@ testPerm({ read: false }, async function lstatSyncPerm() {
Deno.lstatSync("package.json"); Deno.lstatSync("package.json");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -79,12 +79,12 @@ testPerm({ read: true }, async function lstatSyncNotFound() {
badInfo = Deno.lstatSync("bad_file_name"); badInfo = Deno.lstatSync("bad_file_name");
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
} }
assert(caughtError); assert(caughtError);
assertEqual(badInfo, undefined); assertEquals(badInfo, undefined);
}); });
testPerm({ read: true }, async function statSuccess() { testPerm({ read: true }, async function statSuccess() {
@ -107,8 +107,8 @@ testPerm({ read: false }, async function statPerm() {
await Deno.stat("package.json"); await Deno.stat("package.json");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -121,12 +121,12 @@ testPerm({ read: true }, async function statNotFound() {
badInfo = await Deno.stat("bad_file_name"); badInfo = await Deno.stat("bad_file_name");
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
} }
assert(caughtError); assert(caughtError);
assertEqual(badInfo, undefined); assertEquals(badInfo, undefined);
}); });
testPerm({ read: true }, async function lstatSuccess() { testPerm({ read: true }, async function lstatSuccess() {
@ -149,8 +149,8 @@ testPerm({ read: false }, async function lstatPerm() {
await Deno.lstat("package.json"); await Deno.lstat("package.json");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -163,10 +163,10 @@ testPerm({ read: true }, async function lstatNotFound() {
badInfo = await Deno.lstat("bad_file_name"); badInfo = await Deno.lstat("bad_file_name");
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assertEqual(err.kind, Deno.ErrorKind.NotFound); assertEquals(err.kind, Deno.ErrorKind.NotFound);
assertEqual(err.name, "NotFound"); assertEquals(err.name, "NotFound");
} }
assert(caughtError); assert(caughtError);
assertEqual(badInfo, undefined); assertEquals(badInfo, undefined);
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, testPerm, assert, assertEqual } from "./test_util.ts"; import { test, testPerm, assert, assertEquals } from "./test_util.ts";
testPerm({ read: true, write: true }, function symlinkSyncSuccess() { testPerm({ read: true, write: true }, function symlinkSyncSuccess() {
const testDir = Deno.makeTempDirSync(); const testDir = Deno.makeTempDirSync();
@ -14,8 +14,8 @@ testPerm({ read: true, write: true }, function symlinkSyncSuccess() {
errOnWindows = e; errOnWindows = e;
} }
if (errOnWindows) { if (errOnWindows) {
assertEqual(errOnWindows.kind, Deno.ErrorKind.Other); assertEquals(errOnWindows.kind, Deno.ErrorKind.Other);
assertEqual(errOnWindows.message, "Not implemented"); assertEquals(errOnWindows.message, "Not implemented");
} else { } else {
const newNameInfoLStat = Deno.lstatSync(newname); const newNameInfoLStat = Deno.lstatSync(newname);
const newNameInfoStat = Deno.statSync(newname); const newNameInfoStat = Deno.statSync(newname);
@ -31,8 +31,8 @@ test(function symlinkSyncPerm() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
// Just for now, until we implement symlink for Windows. // Just for now, until we implement symlink for Windows.
@ -43,7 +43,7 @@ testPerm({ write: true }, function symlinkSyncNotImplemented() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.message, "Not implemented"); assertEquals(err.message, "Not implemented");
}); });
testPerm({ read: true, write: true }, async function symlinkSuccess() { testPerm({ read: true, write: true }, async function symlinkSuccess() {
@ -59,8 +59,8 @@ testPerm({ read: true, write: true }, async function symlinkSuccess() {
errOnWindows = e; errOnWindows = e;
} }
if (errOnWindows) { if (errOnWindows) {
assertEqual(errOnWindows.kind, Deno.ErrorKind.Other); assertEquals(errOnWindows.kind, Deno.ErrorKind.Other);
assertEqual(errOnWindows.message, "Not implemented"); assertEquals(errOnWindows.message, "Not implemented");
} else { } else {
const newNameInfoLStat = Deno.lstatSync(newname); const newNameInfoLStat = Deno.lstatSync(newname);
const newNameInfoStat = Deno.statSync(newname); const newNameInfoStat = Deno.statSync(newname);

View file

@ -8,7 +8,14 @@
// See tools/unit_tests.py for more details. // See tools/unit_tests.py for more details.
import * as testing from "./deps/https/deno.land/std/testing/mod.ts"; import * as testing from "./deps/https/deno.land/std/testing/mod.ts";
export { assert, assertEqual } from "./deps/https/deno.land/std/testing/mod.ts"; import {
assert,
assertEquals
} from "./deps/https/deno.land/std/testing/asserts.ts";
export {
assert,
assertEquals
} from "./deps/https/deno.land/std/testing/asserts.ts";
// testing.setFilter must be run before any tests are defined. // testing.setFilter must be run before any tests are defined.
testing.setFilter(Deno.args[1]); testing.setFilter(Deno.args[1]);
@ -64,7 +71,7 @@ test(function permSerialization() {
for (const run of [true, false]) { for (const run of [true, false]) {
for (const read of [true, false]) { for (const read of [true, false]) {
const perms: DenoPermissions = { write, net, env, run, read }; const perms: DenoPermissions = { write, net, env, run, read };
testing.assertEqual(perms, permFromString(permToString(perms))); assertEquals(perms, permFromString(permToString(perms)));
} }
} }
} }
@ -81,5 +88,5 @@ test(function permFromStringThrows() {
} catch (e) { } catch (e) {
threw = true; threw = true;
} }
testing.assert(threw); assert(threw);
}); });

View file

@ -1,16 +1,16 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assert, assertEqual } from "./test_util.ts"; import { test, assert, assertEquals } from "./test_util.ts";
test(function atobSuccess() { test(function atobSuccess() {
const text = "hello world"; const text = "hello world";
const encoded = btoa(text); const encoded = btoa(text);
assertEqual(encoded, "aGVsbG8gd29ybGQ="); assertEquals(encoded, "aGVsbG8gd29ybGQ=");
}); });
test(function btoaSuccess() { test(function btoaSuccess() {
const encoded = "aGVsbG8gd29ybGQ="; const encoded = "aGVsbG8gd29ybGQ=";
const decoded = atob(encoded); const decoded = atob(encoded);
assertEqual(decoded, "hello world"); assertEquals(decoded, "hello world");
}); });
test(function btoaFailed() { test(function btoaFailed() {
@ -22,7 +22,7 @@ test(function btoaFailed() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assertEqual(err.name, "InvalidInput"); assertEquals(err.name, "InvalidInput");
}); });
test(function textDecoder2() { test(function textDecoder2() {
@ -34,13 +34,13 @@ test(function textDecoder2() {
0xf0, 0x9d, 0x93, 0xbd 0xf0, 0x9d, 0x93, 0xbd
]); ]);
const decoder = new TextDecoder(); const decoder = new TextDecoder();
assertEqual(decoder.decode(fixture), "𝓽𝓮𝔁𝓽"); assertEquals(decoder.decode(fixture), "𝓽𝓮𝔁𝓽");
}); });
test(function textDecoderASCII() { test(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");
assertEqual(decoder.decode(fixture), "‰•Ÿ¿"); assertEquals(decoder.decode(fixture), "‰•Ÿ¿");
}); });
test(function textDecoderErrorEncoding() { test(function textDecoderErrorEncoding() {
@ -49,7 +49,7 @@ test(function textDecoderErrorEncoding() {
const decoder = new TextDecoder("foo"); const decoder = new TextDecoder("foo");
} catch (e) { } catch (e) {
didThrow = true; didThrow = true;
assertEqual(e.message, "The encoding label provided ('foo') is invalid."); assertEquals(e.message, "The encoding label provided ('foo') is invalid.");
} }
assert(didThrow); assert(didThrow);
}); });
@ -58,7 +58,7 @@ test(function textEncoder2() {
const fixture = "𝓽𝓮𝔁𝓽"; const fixture = "𝓽𝓮𝔁𝓽";
const encoder = new TextEncoder(); const encoder = new TextEncoder();
// prettier-ignore // prettier-ignore
assertEqual(Array.from(encoder.encode(fixture)), [ assertEquals(Array.from(encoder.encode(fixture)), [
0xf0, 0x9d, 0x93, 0xbd, 0xf0, 0x9d, 0x93, 0xbd,
0xf0, 0x9d, 0x93, 0xae, 0xf0, 0x9d, 0x93, 0xae,
0xf0, 0x9d, 0x94, 0x81, 0xf0, 0x9d, 0x94, 0x81,

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assertEqual } from "./test_util.ts"; import { test, assertEquals } from "./test_util.ts";
function deferred() { function deferred() {
let resolve; let resolve;
@ -28,7 +28,7 @@ test(async function timeoutSuccess() {
}, 500); }, 500);
await promise; await promise;
// count should increment // count should increment
assertEqual(count, 1); assertEquals(count, 1);
}); });
test(async function timeoutArgs() { test(async function timeoutArgs() {
@ -36,9 +36,9 @@ test(async function timeoutArgs() {
const arg = 1; const arg = 1;
setTimeout( setTimeout(
(a, b, c) => { (a, b, c) => {
assertEqual(a, arg); assertEquals(a, arg);
assertEqual(b, arg.toString()); assertEquals(b, arg.toString());
assertEqual(c, [arg]); assertEquals(c, [arg]);
resolve(); resolve();
}, },
10, 10,
@ -58,7 +58,7 @@ test(async function timeoutCancelSuccess() {
clearTimeout(id); clearTimeout(id);
// Wait a bit longer than 500ms // Wait a bit longer than 500ms
await waitForMs(600); await waitForMs(600);
assertEqual(count, 0); assertEquals(count, 0);
}); });
test(async function timeoutCancelMultiple() { test(async function timeoutCancelMultiple() {
@ -97,7 +97,7 @@ test(async function timeoutCancelInvalidSilentFail() {
resolve(); resolve();
}, 500); }, 500);
await promise; await promise;
assertEqual(count, 1); assertEquals(count, 1);
// Should silently fail (no panic) // Should silently fail (no panic)
clearTimeout(2147483647); clearTimeout(2147483647);
@ -120,7 +120,7 @@ test(async function intervalSuccess() {
// Clear interval // Clear interval
clearInterval(id); clearInterval(id);
// count should increment twice // count should increment twice
assertEqual(count, 2); assertEquals(count, 2);
}); });
test(async function intervalCancelSuccess() { test(async function intervalCancelSuccess() {
@ -132,7 +132,7 @@ test(async function intervalCancelSuccess() {
clearInterval(id); clearInterval(id);
// Wait a bit longer than 500ms // Wait a bit longer than 500ms
await waitForMs(600); await waitForMs(600);
assertEqual(count, 0); assertEquals(count, 0);
}); });
test(async function intervalOrdering() { test(async function intervalOrdering() {
@ -148,7 +148,7 @@ test(async function intervalOrdering() {
} }
} }
await waitForMs(100); await waitForMs(100);
assertEqual(timeouts, 1); assertEquals(timeouts, 1);
}); });
test(async function intervalCancelInvalidSilentFail() { test(async function intervalCancelInvalidSilentFail() {
@ -162,5 +162,5 @@ test(async function fireCallbackImmediatelyWhenDelayOverMaxValue() {
count++; count++;
}, 2 ** 31); }, 2 ** 31);
await waitForMs(1); await waitForMs(1);
assertEqual(count, 1); assertEquals(count, 1);
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assertEqual } from "./test_util.ts"; import { testPerm, assertEquals } from "./test_util.ts";
function readDataSync(name: string): string { function readDataSync(name: string): string {
const data = Deno.readFileSync(name); const data = Deno.readFileSync(name);
@ -22,13 +22,13 @@ testPerm({ read: true, write: true }, function truncateSyncSuccess() {
Deno.writeFileSync(filename, d); Deno.writeFileSync(filename, d);
Deno.truncateSync(filename, 20); Deno.truncateSync(filename, 20);
let data = readDataSync(filename); let data = readDataSync(filename);
assertEqual(data.length, 20); assertEquals(data.length, 20);
Deno.truncateSync(filename, 5); Deno.truncateSync(filename, 5);
data = readDataSync(filename); data = readDataSync(filename);
assertEqual(data.length, 5); assertEquals(data.length, 5);
Deno.truncateSync(filename, -5); Deno.truncateSync(filename, -5);
data = readDataSync(filename); data = readDataSync(filename);
assertEqual(data.length, 0); assertEquals(data.length, 0);
Deno.removeSync(filename); Deno.removeSync(filename);
}); });
@ -39,13 +39,13 @@ testPerm({ read: true, write: true }, async function truncateSuccess() {
await Deno.writeFile(filename, d); await Deno.writeFile(filename, d);
await Deno.truncate(filename, 20); await Deno.truncate(filename, 20);
let data = await readData(filename); let data = await readData(filename);
assertEqual(data.length, 20); assertEquals(data.length, 20);
await Deno.truncate(filename, 5); await Deno.truncate(filename, 5);
data = await readData(filename); data = await readData(filename);
assertEqual(data.length, 5); assertEquals(data.length, 5);
await Deno.truncate(filename, -5); await Deno.truncate(filename, -5);
data = await readData(filename); data = await readData(filename);
assertEqual(data.length, 0); assertEquals(data.length, 0);
await Deno.remove(filename); await Deno.remove(filename);
}); });
@ -56,8 +56,8 @@ testPerm({ write: false }, function truncateSyncPerm() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
testPerm({ write: false }, async function truncatePerm() { testPerm({ write: false }, async function truncatePerm() {
@ -67,6 +67,6 @@ testPerm({ write: false }, async function truncatePerm() {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assert, assertEqual } from "./test_util.ts"; import { test, assert, assertEquals } from "./test_util.ts";
test(function urlSearchParamsInitString() { test(function urlSearchParamsInitString() {
const init = "c=4&a=2&b=3&%C3%A1=1"; const init = "c=4&a=2&b=3&%C3%A1=1";
@ -13,42 +13,42 @@ test(function urlSearchParamsInitString() {
test(function urlSearchParamsInitIterable() { test(function urlSearchParamsInitIterable() {
const init = [["a", "54"], ["b", "true"]]; const init = [["a", "54"], ["b", "true"]];
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
assertEqual(searchParams.toString(), "a=54&b=true"); assertEquals(searchParams.toString(), "a=54&b=true");
}); });
test(function urlSearchParamsInitRecord() { test(function urlSearchParamsInitRecord() {
const init = { a: "54", b: "true" }; const init = { a: "54", b: "true" };
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
assertEqual(searchParams.toString(), "a=54&b=true"); assertEquals(searchParams.toString(), "a=54&b=true");
}); });
test(function urlSearchParamsAppendSuccess() { test(function urlSearchParamsAppendSuccess() {
const searchParams = new URLSearchParams(); const searchParams = new URLSearchParams();
searchParams.append("a", "true"); searchParams.append("a", "true");
assertEqual(searchParams.toString(), "a=true"); assertEquals(searchParams.toString(), "a=true");
}); });
test(function urlSearchParamsDeleteSuccess() { test(function urlSearchParamsDeleteSuccess() {
const init = "a=54&b=true"; const init = "a=54&b=true";
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
searchParams.delete("b"); searchParams.delete("b");
assertEqual(searchParams.toString(), "a=54"); assertEquals(searchParams.toString(), "a=54");
}); });
test(function urlSearchParamsGetAllSuccess() { test(function urlSearchParamsGetAllSuccess() {
const init = "a=54&b=true&a=true"; const init = "a=54&b=true&a=true";
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
assertEqual(searchParams.getAll("a"), ["54", "true"]); assertEquals(searchParams.getAll("a"), ["54", "true"]);
assertEqual(searchParams.getAll("b"), ["true"]); assertEquals(searchParams.getAll("b"), ["true"]);
assertEqual(searchParams.getAll("c"), []); assertEquals(searchParams.getAll("c"), []);
}); });
test(function urlSearchParamsGetSuccess() { test(function urlSearchParamsGetSuccess() {
const init = "a=54&b=true&a=true"; const init = "a=54&b=true&a=true";
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
assertEqual(searchParams.get("a"), "54"); assertEquals(searchParams.get("a"), "54");
assertEqual(searchParams.get("b"), "true"); assertEquals(searchParams.get("b"), "true");
assertEqual(searchParams.get("c"), null); assertEquals(searchParams.get("c"), null);
}); });
test(function urlSearchParamsHasSuccess() { test(function urlSearchParamsHasSuccess() {
@ -63,21 +63,21 @@ test(function urlSearchParamsSetReplaceFirstAndRemoveOthers() {
const init = "a=54&b=true&a=true"; const init = "a=54&b=true&a=true";
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
searchParams.set("a", "false"); searchParams.set("a", "false");
assertEqual(searchParams.toString(), "a=false&b=true"); assertEquals(searchParams.toString(), "a=false&b=true");
}); });
test(function urlSearchParamsSetAppendNew() { test(function urlSearchParamsSetAppendNew() {
const init = "a=54&b=true&a=true"; const init = "a=54&b=true&a=true";
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
searchParams.set("c", "foo"); searchParams.set("c", "foo");
assertEqual(searchParams.toString(), "a=54&b=true&a=true&c=foo"); assertEquals(searchParams.toString(), "a=54&b=true&a=true&c=foo");
}); });
test(function urlSearchParamsSortSuccess() { test(function urlSearchParamsSortSuccess() {
const init = "c=4&a=2&b=3&a=1"; const init = "c=4&a=2&b=3&a=1";
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
searchParams.sort(); searchParams.sort();
assertEqual(searchParams.toString(), "a=2&a=1&b=3&c=4"); assertEquals(searchParams.toString(), "a=2&a=1&b=3&c=4");
}); });
test(function urlSearchParamsForEachSuccess() { test(function urlSearchParamsForEachSuccess() {
@ -85,39 +85,39 @@ test(function urlSearchParamsForEachSuccess() {
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
let callNum = 0; let callNum = 0;
searchParams.forEach((value, key, parent) => { searchParams.forEach((value, key, parent) => {
assertEqual(searchParams, parent); assertEquals(searchParams, parent);
assertEqual(value, init[callNum][1]); assertEquals(value, init[callNum][1]);
assertEqual(key, init[callNum][0]); assertEquals(key, init[callNum][0]);
callNum++; callNum++;
}); });
assertEqual(callNum, init.length); assertEquals(callNum, init.length);
}); });
test(function urlSearchParamsMissingName() { test(function urlSearchParamsMissingName() {
const init = "=4"; const init = "=4";
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
assertEqual(searchParams.get(""), "4"); assertEquals(searchParams.get(""), "4");
assertEqual(searchParams.toString(), "=4"); assertEquals(searchParams.toString(), "=4");
}); });
test(function urlSearchParamsMissingValue() { test(function urlSearchParamsMissingValue() {
const init = "4="; const init = "4=";
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
assertEqual(searchParams.get("4"), ""); assertEquals(searchParams.get("4"), "");
assertEqual(searchParams.toString(), "4="); assertEquals(searchParams.toString(), "4=");
}); });
test(function urlSearchParamsMissingEqualSign() { test(function urlSearchParamsMissingEqualSign() {
const init = "4"; const init = "4";
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
assertEqual(searchParams.get("4"), ""); assertEquals(searchParams.get("4"), "");
assertEqual(searchParams.toString(), "4="); assertEquals(searchParams.toString(), "4=");
}); });
test(function urlSearchParamsMissingPair() { test(function urlSearchParamsMissingPair() {
const init = "c=4&&a=54&"; const init = "c=4&&a=54&";
const searchParams = new URLSearchParams(init); const searchParams = new URLSearchParams(init);
assertEqual(searchParams.toString(), "c=4&a=54"); assertEquals(searchParams.toString(), "c=4&a=54");
}); });
// If pair does not contain exactly two items, then throw a TypeError. // If pair does not contain exactly two items, then throw a TypeError.
@ -136,7 +136,7 @@ test(function urlSearchParamsShouldThrowTypeError() {
} }
} }
assertEqual(hasThrown, 2); assertEquals(hasThrown, 2);
}); });
test(function urlSearchParamsAppendArgumentsCheck() { test(function urlSearchParamsAppendArgumentsCheck() {
@ -157,7 +157,7 @@ test(function urlSearchParamsAppendArgumentsCheck() {
hasThrown = 3; hasThrown = 3;
} }
} }
assertEqual(hasThrown, 2); assertEquals(hasThrown, 2);
}); });
methodRequireTwoParams.forEach(method => { methodRequireTwoParams.forEach(method => {
@ -173,6 +173,6 @@ test(function urlSearchParamsAppendArgumentsCheck() {
hasThrown = 3; hasThrown = 3;
} }
} }
assertEqual(hasThrown, 2); assertEquals(hasThrown, 2);
}); });
}); });

View file

@ -1,31 +1,31 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assert, assertEqual } from "./test_util.ts"; import { test, assert, assertEquals } from "./test_util.ts";
test(function urlParsing() { test(function urlParsing() {
const url = new URL( const url = new URL(
"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat"
); );
assertEqual(url.hash, "#qat"); assertEquals(url.hash, "#qat");
assertEqual(url.host, "baz.qat:8000"); assertEquals(url.host, "baz.qat:8000");
assertEqual(url.hostname, "baz.qat"); assertEquals(url.hostname, "baz.qat");
assertEqual( assertEquals(
url.href, url.href,
"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat"
); );
assertEqual(url.origin, "https://baz.qat:8000"); assertEquals(url.origin, "https://baz.qat:8000");
assertEqual(url.password, "bar"); assertEquals(url.password, "bar");
assertEqual(url.pathname, "/qux/quux"); assertEquals(url.pathname, "/qux/quux");
assertEqual(url.port, "8000"); assertEquals(url.port, "8000");
assertEqual(url.protocol, "https:"); assertEquals(url.protocol, "https:");
assertEqual(url.search, "?foo=bar&baz=12"); assertEquals(url.search, "?foo=bar&baz=12");
assertEqual(url.searchParams.getAll("foo"), ["bar"]); assertEquals(url.searchParams.getAll("foo"), ["bar"]);
assertEqual(url.searchParams.getAll("baz"), ["12"]); assertEquals(url.searchParams.getAll("baz"), ["12"]);
assertEqual(url.username, "foo"); assertEquals(url.username, "foo");
assertEqual( assertEquals(
String(url), String(url),
"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat"
); );
assertEqual( assertEquals(
JSON.stringify({ key: url }), JSON.stringify({ key: url }),
`{"key":"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat"}` `{"key":"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat"}`
); );
@ -36,39 +36,51 @@ test(function urlModifications() {
"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat"
); );
url.hash = ""; url.hash = "";
assertEqual(url.href, "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12"); assertEquals(
url.href,
"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12"
);
url.host = "qat.baz:8080"; url.host = "qat.baz:8080";
assertEqual(url.href, "https://foo:bar@qat.baz:8080/qux/quux?foo=bar&baz=12"); assertEquals(
url.href,
"https://foo:bar@qat.baz:8080/qux/quux?foo=bar&baz=12"
);
url.hostname = "foo.bar"; url.hostname = "foo.bar";
assertEqual(url.href, "https://foo:bar@foo.bar:8080/qux/quux?foo=bar&baz=12"); assertEquals(
url.href,
"https://foo:bar@foo.bar:8080/qux/quux?foo=bar&baz=12"
);
url.password = "qux"; url.password = "qux";
assertEqual(url.href, "https://foo:qux@foo.bar:8080/qux/quux?foo=bar&baz=12"); assertEquals(
url.href,
"https://foo:qux@foo.bar:8080/qux/quux?foo=bar&baz=12"
);
url.pathname = "/foo/bar%qat"; url.pathname = "/foo/bar%qat";
assertEqual( assertEquals(
url.href, url.href,
"https://foo:qux@foo.bar:8080/foo/bar%qat?foo=bar&baz=12" "https://foo:qux@foo.bar:8080/foo/bar%qat?foo=bar&baz=12"
); );
url.port = ""; url.port = "";
assertEqual(url.href, "https://foo:qux@foo.bar/foo/bar%qat?foo=bar&baz=12"); assertEquals(url.href, "https://foo:qux@foo.bar/foo/bar%qat?foo=bar&baz=12");
url.protocol = "http:"; url.protocol = "http:";
assertEqual(url.href, "http://foo:qux@foo.bar/foo/bar%qat?foo=bar&baz=12"); assertEquals(url.href, "http://foo:qux@foo.bar/foo/bar%qat?foo=bar&baz=12");
url.search = "?foo=bar&foo=baz"; url.search = "?foo=bar&foo=baz";
assertEqual(url.href, "http://foo:qux@foo.bar/foo/bar%qat?foo=bar&foo=baz"); assertEquals(url.href, "http://foo:qux@foo.bar/foo/bar%qat?foo=bar&foo=baz");
assertEqual(url.searchParams.getAll("foo"), ["bar", "baz"]); assertEquals(url.searchParams.getAll("foo"), ["bar", "baz"]);
url.username = "foo@bar"; url.username = "foo@bar";
assertEqual( assertEquals(
url.href, url.href,
"http://foo%40bar:qux@foo.bar/foo/bar%qat?foo=bar&foo=baz" "http://foo%40bar:qux@foo.bar/foo/bar%qat?foo=bar&foo=baz"
); );
url.searchParams.set("bar", "qat"); url.searchParams.set("bar", "qat");
assertEqual( assertEquals(
url.href, url.href,
"http://foo%40bar:qux@foo.bar/foo/bar%qat?foo=bar&foo=baz&bar=qat" "http://foo%40bar:qux@foo.bar/foo/bar%qat?foo=bar&foo=baz&bar=qat"
); );
url.searchParams.delete("foo"); url.searchParams.delete("foo");
assertEqual(url.href, "http://foo%40bar:qux@foo.bar/foo/bar%qat?bar=qat"); assertEquals(url.href, "http://foo%40bar:qux@foo.bar/foo/bar%qat?bar=qat");
url.searchParams.append("foo", "bar"); url.searchParams.append("foo", "bar");
assertEqual( assertEquals(
url.href, url.href,
"http://foo%40bar:qux@foo.bar/foo/bar%qat?bar=qat&foo=bar" "http://foo%40bar:qux@foo.bar/foo/bar%qat?bar=qat&foo=bar"
); );
@ -77,32 +89,32 @@ test(function urlModifications() {
test(function urlModifyHref() { test(function urlModifyHref() {
const url = new URL("http://example.com/"); const url = new URL("http://example.com/");
url.href = "https://foo:bar@example.com:8080/baz/qat#qux"; url.href = "https://foo:bar@example.com:8080/baz/qat#qux";
assertEqual(url.protocol, "https:"); assertEquals(url.protocol, "https:");
assertEqual(url.username, "foo"); assertEquals(url.username, "foo");
assertEqual(url.password, "bar"); assertEquals(url.password, "bar");
assertEqual(url.host, "example.com:8080"); assertEquals(url.host, "example.com:8080");
assertEqual(url.hostname, "example.com"); assertEquals(url.hostname, "example.com");
assertEqual(url.pathname, "/baz/qat"); assertEquals(url.pathname, "/baz/qat");
assertEqual(url.hash, "#qux"); assertEquals(url.hash, "#qux");
}); });
test(function urlModifyPathname() { test(function urlModifyPathname() {
const url = new URL("http://foo.bar/baz%qat/qux%quux"); const url = new URL("http://foo.bar/baz%qat/qux%quux");
assertEqual(url.pathname, "/baz%qat/qux%quux"); assertEquals(url.pathname, "/baz%qat/qux%quux");
url.pathname = url.pathname; url.pathname = url.pathname;
assertEqual(url.pathname, "/baz%qat/qux%quux"); assertEquals(url.pathname, "/baz%qat/qux%quux");
url.pathname = "baz#qat qux"; url.pathname = "baz#qat qux";
assertEqual(url.pathname, "/baz%23qat%20qux"); assertEquals(url.pathname, "/baz%23qat%20qux");
url.pathname = url.pathname; url.pathname = url.pathname;
assertEqual(url.pathname, "/baz%23qat%20qux"); assertEquals(url.pathname, "/baz%23qat%20qux");
}); });
test(function urlModifyHash() { test(function urlModifyHash() {
const url = new URL("http://foo.bar"); const url = new URL("http://foo.bar");
url.hash = "%foo bar/qat%qux#bar"; url.hash = "%foo bar/qat%qux#bar";
assertEqual(url.hash, "#%foo%20bar/qat%qux#bar"); assertEquals(url.hash, "#%foo%20bar/qat%qux#bar");
url.hash = url.hash; url.hash = url.hash;
assertEqual(url.hash, "#%foo%20bar/qat%qux#bar"); assertEquals(url.hash, "#%foo%20bar/qat%qux#bar");
}); });
test(function urlSearchParamsReuse() { test(function urlSearchParamsReuse() {
@ -119,7 +131,7 @@ test(function urlBaseURL() {
"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat"
); );
const url = new URL("/foo/bar?baz=foo#qux", base); const url = new URL("/foo/bar?baz=foo#qux", base);
assertEqual(url.href, "https://foo:bar@baz.qat:8000/foo/bar?baz=foo#qux"); assertEquals(url.href, "https://foo:bar@baz.qat:8000/foo/bar?baz=foo#qux");
}); });
test(function urlBaseString() { test(function urlBaseString() {
@ -127,5 +139,5 @@ test(function urlBaseString() {
"/foo/bar?baz=foo#qux", "/foo/bar?baz=foo#qux",
"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat"
); );
assertEqual(url.href, "https://foo:bar@baz.qat:8000/foo/bar?baz=foo#qux"); assertEquals(url.href, "https://foo:bar@baz.qat:8000/foo/bar?baz=foo#qux");
}); });

View file

@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEqual } from "./test_util.ts"; import { testPerm, assert, assertEquals } from "./test_util.ts";
testPerm({ read: true, write: true }, function writeFileSyncSuccess() { testPerm({ read: true, write: true }, function writeFileSyncSuccess() {
const enc = new TextEncoder(); const enc = new TextEncoder();
@ -9,7 +9,7 @@ testPerm({ read: true, write: true }, function writeFileSyncSuccess() {
const dataRead = Deno.readFileSync(filename); const dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8"); const dec = new TextDecoder("utf-8");
const actual = dec.decode(dataRead); const actual = dec.decode(dataRead);
assertEqual("Hello", actual); assertEquals("Hello", actual);
}); });
testPerm({ write: true }, function writeFileSyncFail() { testPerm({ write: true }, function writeFileSyncFail() {
@ -22,8 +22,8 @@ testPerm({ write: true }, function writeFileSyncFail() {
Deno.writeFileSync(filename, data); Deno.writeFileSync(filename, data);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.NotFound); assertEquals(e.kind, Deno.ErrorKind.NotFound);
assertEqual(e.name, "NotFound"); assertEquals(e.name, "NotFound");
} }
assert(caughtError); assert(caughtError);
}); });
@ -38,8 +38,8 @@ testPerm({ write: false }, function writeFileSyncPerm() {
Deno.writeFileSync(filename, data); Deno.writeFileSync(filename, data);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -50,9 +50,9 @@ testPerm({ read: true, write: true }, function writeFileSyncUpdatePerm() {
const data = enc.encode("Hello"); const data = enc.encode("Hello");
const filename = Deno.makeTempDirSync() + "/test.txt"; const filename = Deno.makeTempDirSync() + "/test.txt";
Deno.writeFileSync(filename, data, { perm: 0o755 }); Deno.writeFileSync(filename, data, { perm: 0o755 });
assertEqual(Deno.statSync(filename).mode & 0o777, 0o755); assertEquals(Deno.statSync(filename).mode & 0o777, 0o755);
Deno.writeFileSync(filename, data, { perm: 0o666 }); Deno.writeFileSync(filename, data, { perm: 0o666 });
assertEqual(Deno.statSync(filename).mode & 0o777, 0o666); assertEquals(Deno.statSync(filename).mode & 0o777, 0o666);
} }
}); });
@ -66,8 +66,8 @@ testPerm({ read: true, write: true }, function writeFileSyncCreate() {
Deno.writeFileSync(filename, data, { create: false }); Deno.writeFileSync(filename, data, { create: false });
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.NotFound); assertEquals(e.kind, Deno.ErrorKind.NotFound);
assertEqual(e.name, "NotFound"); assertEquals(e.name, "NotFound");
} }
assert(caughtError); assert(caughtError);
@ -77,7 +77,7 @@ testPerm({ read: true, write: true }, function writeFileSyncCreate() {
const dataRead = Deno.readFileSync(filename); const dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8"); const dec = new TextDecoder("utf-8");
const actual = dec.decode(dataRead); const actual = dec.decode(dataRead);
assertEqual("Hello", actual); assertEquals("Hello", actual);
}); });
testPerm({ read: true, write: true }, function writeFileSyncAppend() { testPerm({ read: true, write: true }, function writeFileSyncAppend() {
@ -89,17 +89,17 @@ testPerm({ read: true, write: true }, function writeFileSyncAppend() {
let dataRead = Deno.readFileSync(filename); let dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8"); const dec = new TextDecoder("utf-8");
let actual = dec.decode(dataRead); let actual = dec.decode(dataRead);
assertEqual("HelloHello", actual); assertEquals("HelloHello", actual);
// Now attempt overwrite // Now attempt overwrite
Deno.writeFileSync(filename, data, { append: false }); Deno.writeFileSync(filename, data, { append: false });
dataRead = Deno.readFileSync(filename); dataRead = Deno.readFileSync(filename);
actual = dec.decode(dataRead); actual = dec.decode(dataRead);
assertEqual("Hello", actual); assertEquals("Hello", actual);
// append not set should also overwrite // append not set should also overwrite
Deno.writeFileSync(filename, data); Deno.writeFileSync(filename, data);
dataRead = Deno.readFileSync(filename); dataRead = Deno.readFileSync(filename);
actual = dec.decode(dataRead); actual = dec.decode(dataRead);
assertEqual("Hello", actual); assertEquals("Hello", actual);
}); });
testPerm({ read: true, write: true }, async function writeFileSuccess() { testPerm({ read: true, write: true }, async function writeFileSuccess() {
@ -110,7 +110,7 @@ testPerm({ read: true, write: true }, async function writeFileSuccess() {
const dataRead = Deno.readFileSync(filename); const dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8"); const dec = new TextDecoder("utf-8");
const actual = dec.decode(dataRead); const actual = dec.decode(dataRead);
assertEqual("Hello", actual); assertEquals("Hello", actual);
}); });
testPerm({ read: true, write: true }, async function writeFileNotFound() { testPerm({ read: true, write: true }, async function writeFileNotFound() {
@ -123,8 +123,8 @@ testPerm({ read: true, write: true }, async function writeFileNotFound() {
await Deno.writeFile(filename, data); await Deno.writeFile(filename, data);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.NotFound); assertEquals(e.kind, Deno.ErrorKind.NotFound);
assertEqual(e.name, "NotFound"); assertEquals(e.name, "NotFound");
} }
assert(caughtError); assert(caughtError);
}); });
@ -139,8 +139,8 @@ testPerm({ read: true, write: false }, async function writeFilePerm() {
await Deno.writeFile(filename, data); await Deno.writeFile(filename, data);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
assertEqual(e.name, "PermissionDenied"); assertEquals(e.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
}); });
@ -151,9 +151,9 @@ testPerm({ read: true, write: true }, async function writeFileUpdatePerm() {
const data = enc.encode("Hello"); const data = enc.encode("Hello");
const filename = Deno.makeTempDirSync() + "/test.txt"; const filename = Deno.makeTempDirSync() + "/test.txt";
await Deno.writeFile(filename, data, { perm: 0o755 }); await Deno.writeFile(filename, data, { perm: 0o755 });
assertEqual(Deno.statSync(filename).mode & 0o777, 0o755); assertEquals(Deno.statSync(filename).mode & 0o777, 0o755);
await Deno.writeFile(filename, data, { perm: 0o666 }); await Deno.writeFile(filename, data, { perm: 0o666 });
assertEqual(Deno.statSync(filename).mode & 0o777, 0o666); assertEquals(Deno.statSync(filename).mode & 0o777, 0o666);
} }
}); });
@ -167,8 +167,8 @@ testPerm({ read: true, write: true }, async function writeFileCreate() {
await Deno.writeFile(filename, data, { create: false }); await Deno.writeFile(filename, data, { create: false });
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assertEqual(e.kind, Deno.ErrorKind.NotFound); assertEquals(e.kind, Deno.ErrorKind.NotFound);
assertEqual(e.name, "NotFound"); assertEquals(e.name, "NotFound");
} }
assert(caughtError); assert(caughtError);
@ -178,7 +178,7 @@ testPerm({ read: true, write: true }, async function writeFileCreate() {
const dataRead = Deno.readFileSync(filename); const dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8"); const dec = new TextDecoder("utf-8");
const actual = dec.decode(dataRead); const actual = dec.decode(dataRead);
assertEqual("Hello", actual); assertEquals("Hello", actual);
}); });
testPerm({ read: true, write: true }, async function writeFileAppend() { testPerm({ read: true, write: true }, async function writeFileAppend() {
@ -190,15 +190,15 @@ testPerm({ read: true, write: true }, async function writeFileAppend() {
let dataRead = Deno.readFileSync(filename); let dataRead = Deno.readFileSync(filename);
const dec = new TextDecoder("utf-8"); const dec = new TextDecoder("utf-8");
let actual = dec.decode(dataRead); let actual = dec.decode(dataRead);
assertEqual("HelloHello", actual); assertEquals("HelloHello", actual);
// Now attempt overwrite // Now attempt overwrite
await Deno.writeFile(filename, data, { append: false }); await Deno.writeFile(filename, data, { append: false });
dataRead = Deno.readFileSync(filename); dataRead = Deno.readFileSync(filename);
actual = dec.decode(dataRead); actual = dec.decode(dataRead);
assertEqual("Hello", actual); assertEquals("Hello", actual);
// append not set should also overwrite // append not set should also overwrite
await Deno.writeFile(filename, data); await Deno.writeFile(filename, data);
dataRead = Deno.readFileSync(filename); dataRead = Deno.readFileSync(filename);
actual = dec.decode(dataRead); actual = dec.decode(dataRead);
assertEqual("Hello", actual); assertEquals("Hello", actual);
}); });

View file

@ -1,5 +1,5 @@
// Run ./tools/http_server.py too in order for this test to run. // Run ./tools/http_server.py too in order for this test to run.
import { assert } from "../js/deps/https/deno.land/std/testing/mod.ts"; import { assert } from "../js/deps/https/deno.land/std/testing/asserts.ts";
// TODO Top level await https://github.com/denoland/deno/issues/471 // TODO Top level await https://github.com/denoland/deno/issues/471
async function main() { async function main() {

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, testPerm, assert, assertEqual } from "../js/test_util.ts"; import { test, testPerm, assert, assertEquals } from "../js/test_util.ts";
import { import {
createBinarySizeColumns, createBinarySizeColumns,
createExecTimeColumns, createExecTimeColumns,
@ -134,7 +134,7 @@ const irregularData = [
test(function createExecTimeColumnsRegularData() { test(function createExecTimeColumnsRegularData() {
const columns = createExecTimeColumns(regularData); const columns = createExecTimeColumns(regularData);
assertEqual(columns, [ assertEquals(columns, [
["hello", 0.05, 0.055], ["hello", 0.05, 0.055],
["relative_import", 0.06, 0.065], ["relative_import", 0.06, 0.065],
["cold_hello", 0.05, 0.055], ["cold_hello", 0.05, 0.055],
@ -144,7 +144,7 @@ test(function createExecTimeColumnsRegularData() {
test(function createExecTimeColumnsIrregularData() { test(function createExecTimeColumnsIrregularData() {
const columns = createExecTimeColumns(irregularData); const columns = createExecTimeColumns(irregularData);
assertEqual(columns, [ assertEquals(columns, [
["hello", null, null], ["hello", null, null],
["relative_import", null, null], ["relative_import", null, null],
["cold_hello", null, null], ["cold_hello", null, null],
@ -154,7 +154,7 @@ test(function createExecTimeColumnsIrregularData() {
test(function createBinarySizeColumnsRegularData() { test(function createBinarySizeColumnsRegularData() {
const columns = createBinarySizeColumns(regularData); const columns = createBinarySizeColumns(regularData);
assertEqual(columns, [ assertEquals(columns, [
["deno", 100000000, 100000001], ["deno", 100000000, 100000001],
["main.js", 90000000, 90000001], ["main.js", 90000000, 90000001],
["main.js.map", 80000000, 80000001], ["main.js.map", 80000000, 80000001],
@ -164,30 +164,30 @@ test(function createBinarySizeColumnsRegularData() {
test(function createBinarySizeColumnsIrregularData() { test(function createBinarySizeColumnsIrregularData() {
const columns = createBinarySizeColumns(irregularData); const columns = createBinarySizeColumns(irregularData);
assertEqual(columns, [["deno", null, 1]]); assertEquals(columns, [["deno", null, 1]]);
}); });
test(function createThreadCountColumnsRegularData() { test(function createThreadCountColumnsRegularData() {
const columns = createThreadCountColumns(regularData); const columns = createThreadCountColumns(regularData);
assertEqual(columns, [["set_timeout", 4, 5], ["fetch_deps", 6, 7]]); assertEquals(columns, [["set_timeout", 4, 5], ["fetch_deps", 6, 7]]);
}); });
test(function createThreadCountColumnsIrregularData() { test(function createThreadCountColumnsIrregularData() {
const columns = createThreadCountColumns(irregularData); const columns = createThreadCountColumns(irregularData);
assertEqual(columns, [["set_timeout", null, 5], ["fetch_deps", null, 7]]); assertEquals(columns, [["set_timeout", null, 5], ["fetch_deps", null, 7]]);
}); });
test(function createSyscallCountColumnsRegularData() { test(function createSyscallCountColumnsRegularData() {
const columns = createSyscallCountColumns(regularData); const columns = createSyscallCountColumns(regularData);
assertEqual(columns, [["hello", 600, 700], ["fetch_deps", 700, 800]]); assertEquals(columns, [["hello", 600, 700], ["fetch_deps", 700, 800]]);
}); });
test(function createSyscallCountColumnsIrregularData() { test(function createSyscallCountColumnsIrregularData() {
const columns = createSyscallCountColumns(irregularData); const columns = createSyscallCountColumns(irregularData);
assertEqual(columns, [["hello", null, 700], ["fetch_deps", null, 800]]); assertEquals(columns, [["hello", null, 700], ["fetch_deps", null, 800]]);
}); });
test(function createSha1ListRegularData() { test(function createSha1ListRegularData() {
const sha1List = createSha1List(regularData); const sha1List = createSha1List(regularData);
assertEqual(sha1List, ["abcdef", "012345"]); assertEquals(sha1List, ["abcdef", "012345"]);
}); });

View file

@ -432,16 +432,16 @@ uses a URL to import a test runner library:
```ts ```ts
import { import {
test, test,
assertEqual, assertEquals,
runIfMain runIfMain
} from "https://deno.land/std/testing/mod.ts"; } from "https://deno.land/std/testing/mod.ts";
test(function t1() { test(function t1() {
assertEqual("hello", "hello"); assertEquals("hello", "hello");
}); });
test(function t2() { test(function t2() {
assertEqual("world", "world"); assertEquals("world", "world");
}); });
runIfMain(import.meta); runIfMain(import.meta);
@ -497,14 +497,14 @@ testing library across a large project. Rather than importing
`package.ts` file the exports the third-party code: `package.ts` file the exports the third-party code:
```ts ```ts
export { test, assertEqual } from "https://deno.land/std/testing/mod.ts"; export { test, assertEquals } from "https://deno.land/std/testing/mod.ts";
``` ```
And throughout project one can import from the `package.ts` and avoid having And throughout project one can import from the `package.ts` and avoid having
many references to the same URL: many references to the same URL:
```ts ```ts
import { test, assertEqual } from "./package.ts"; import { test, assertEquals } from "./package.ts";
``` ```
This design circumvents a plethora of complexity spawned by package management This design circumvents a plethora of complexity spawned by package management

View file

@ -100,4 +100,4 @@ code {
.hljs { .hljs {
background: transparent; background: transparent;
} }