mirror of
https://github.com/denoland/deno.git
synced 2025-03-04 01:44:26 -05:00
This reverts commit 22a834ff5b
.
Appears this commit might have broken tests on `main`.
This commit is contained in:
parent
a58494483a
commit
b6c74aab24
20 changed files with 223 additions and 487 deletions
|
@ -117,10 +117,6 @@ util::unit_test_factory!(
|
||||||
);
|
);
|
||||||
|
|
||||||
fn js_unit_test(test: String) {
|
fn js_unit_test(test: String) {
|
||||||
js_unit_test_inner(test, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn js_unit_test_inner(test: String, future: bool) {
|
|
||||||
let _g = util::http_server();
|
let _g = util::http_server();
|
||||||
|
|
||||||
let deno = util::deno_cmd()
|
let deno = util::deno_cmd()
|
||||||
|
@ -133,12 +129,6 @@ pub fn js_unit_test_inner(test: String, future: bool) {
|
||||||
.arg("--location=http://127.0.0.1:4545/")
|
.arg("--location=http://127.0.0.1:4545/")
|
||||||
.arg("--no-prompt");
|
.arg("--no-prompt");
|
||||||
|
|
||||||
let deno = if future {
|
|
||||||
deno.env("DENO_FUTURE", "1")
|
|
||||||
} else {
|
|
||||||
deno
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO(mmastrac): it would be better to just load a test CA for all tests
|
// TODO(mmastrac): it would be better to just load a test CA for all tests
|
||||||
let deno = if test == "websocket_test" || test == "tls_sni_test" {
|
let deno = if test == "websocket_test" || test == "tls_sni_test" {
|
||||||
deno.arg("--unsafely-ignore-certificate-errors")
|
deno.arg("--unsafely-ignore-certificate-errors")
|
||||||
|
|
|
@ -1,118 +0,0 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
||||||
|
|
||||||
use super::js_unit_tests::js_unit_test_inner;
|
|
||||||
use test_util as util;
|
|
||||||
|
|
||||||
util::unit_test_factory!(
|
|
||||||
js_unit_test_future,
|
|
||||||
"../tests/unit",
|
|
||||||
"*.ts",
|
|
||||||
[
|
|
||||||
abort_controller_test,
|
|
||||||
blob_test,
|
|
||||||
body_test,
|
|
||||||
broadcast_channel_test,
|
|
||||||
buffer_test,
|
|
||||||
build_test,
|
|
||||||
cache_api_test,
|
|
||||||
chmod_test,
|
|
||||||
chown_test,
|
|
||||||
command_test,
|
|
||||||
console_test,
|
|
||||||
copy_file_test,
|
|
||||||
custom_event_test,
|
|
||||||
cron_test,
|
|
||||||
dir_test,
|
|
||||||
dom_exception_test,
|
|
||||||
error_stack_test,
|
|
||||||
error_test,
|
|
||||||
esnext_test,
|
|
||||||
event_source_test,
|
|
||||||
event_target_test,
|
|
||||||
event_test,
|
|
||||||
fetch_test,
|
|
||||||
ffi_test,
|
|
||||||
file_test,
|
|
||||||
filereader_test,
|
|
||||||
files_test,
|
|
||||||
flock_test,
|
|
||||||
fs_events_test,
|
|
||||||
get_random_values_test,
|
|
||||||
globals_test,
|
|
||||||
headers_test,
|
|
||||||
http_test,
|
|
||||||
image_bitmap_test,
|
|
||||||
image_data_test,
|
|
||||||
internals_test,
|
|
||||||
intl_test,
|
|
||||||
io_test,
|
|
||||||
jupyter_test,
|
|
||||||
kv_test,
|
|
||||||
kv_queue_test_no_db_close,
|
|
||||||
kv_queue_test,
|
|
||||||
kv_queue_undelivered_test,
|
|
||||||
link_test,
|
|
||||||
make_temp_test,
|
|
||||||
message_channel_test,
|
|
||||||
mkdir_test,
|
|
||||||
navigator_test,
|
|
||||||
net_test,
|
|
||||||
network_interfaces_test,
|
|
||||||
os_test,
|
|
||||||
ops_test,
|
|
||||||
path_from_url_test,
|
|
||||||
performance_test,
|
|
||||||
permissions_test,
|
|
||||||
process_test,
|
|
||||||
progressevent_test,
|
|
||||||
promise_hooks_test,
|
|
||||||
read_dir_test,
|
|
||||||
read_file_test,
|
|
||||||
read_link_test,
|
|
||||||
read_text_file_test,
|
|
||||||
real_path_test,
|
|
||||||
ref_unref_test,
|
|
||||||
remove_test,
|
|
||||||
rename_test,
|
|
||||||
request_test,
|
|
||||||
resources_test,
|
|
||||||
response_test,
|
|
||||||
serve_test,
|
|
||||||
signal_test,
|
|
||||||
stat_test,
|
|
||||||
stdio_test,
|
|
||||||
streams_test,
|
|
||||||
structured_clone_test,
|
|
||||||
symbol_test,
|
|
||||||
symlink_test,
|
|
||||||
sync_test,
|
|
||||||
test_util,
|
|
||||||
testing_test,
|
|
||||||
text_encoding_test,
|
|
||||||
timers_test,
|
|
||||||
tls_test,
|
|
||||||
tls_sni_test,
|
|
||||||
truncate_test,
|
|
||||||
tty_color_test,
|
|
||||||
tty_test,
|
|
||||||
umask_test,
|
|
||||||
url_search_params_test,
|
|
||||||
url_test,
|
|
||||||
urlpattern_test,
|
|
||||||
utime_test,
|
|
||||||
version_test,
|
|
||||||
wasm_test,
|
|
||||||
webcrypto_test,
|
|
||||||
webgpu_test,
|
|
||||||
websocket_test,
|
|
||||||
webstorage_test,
|
|
||||||
worker_permissions_test,
|
|
||||||
worker_test,
|
|
||||||
write_file_test,
|
|
||||||
write_text_file_test,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
fn js_unit_test_future(test: String) {
|
|
||||||
js_unit_test_inner(test, true);
|
|
||||||
}
|
|
|
@ -37,8 +37,6 @@ mod inspector;
|
||||||
mod install;
|
mod install;
|
||||||
#[path = "js_unit_tests.rs"]
|
#[path = "js_unit_tests.rs"]
|
||||||
mod js_unit_tests;
|
mod js_unit_tests;
|
||||||
#[path = "js_unit_tests_future.rs"]
|
|
||||||
mod js_unit_tests_future;
|
|
||||||
#[path = "jsr_tests.rs"]
|
#[path = "jsr_tests.rs"]
|
||||||
mod jsr;
|
mod jsr;
|
||||||
#[path = "jupyter_tests.rs"]
|
#[path = "jupyter_tests.rs"]
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
assertEquals,
|
assertEquals,
|
||||||
assertRejects,
|
assertRejects,
|
||||||
assertThrows,
|
assertThrows,
|
||||||
DENO_FUTURE,
|
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
import { writeAllSync } from "@std/io/write-all";
|
import { writeAllSync } from "@std/io/write-all";
|
||||||
|
|
||||||
|
@ -88,7 +87,7 @@ function repeat(c: string, bytes: number): Uint8Array {
|
||||||
return ui8;
|
return ui8;
|
||||||
}
|
}
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function bufferNewBuffer() {
|
Deno.test(function bufferNewBuffer() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
assert(testString);
|
assert(testString);
|
||||||
|
@ -96,7 +95,7 @@ Deno.test({ ignore: DENO_FUTURE }, function bufferNewBuffer() {
|
||||||
check(buf, testString);
|
check(buf, testString);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function bufferBasicOperations() {
|
Deno.test(async function bufferBasicOperations() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
assert(testString);
|
assert(testString);
|
||||||
|
@ -136,7 +135,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferBasicOperations() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function bufferReadEmptyAtEOF() {
|
Deno.test(async function bufferReadEmptyAtEOF() {
|
||||||
// check that EOF of 'buf' is not reached (even though it's empty) if
|
// check that EOF of 'buf' is not reached (even though it's empty) if
|
||||||
// results are written to buffer that has 0 length (ie. it can't store any data)
|
// results are written to buffer that has 0 length (ie. it can't store any data)
|
||||||
const buf = new Deno.Buffer();
|
const buf = new Deno.Buffer();
|
||||||
|
@ -145,7 +144,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferReadEmptyAtEOF() {
|
||||||
assertEquals(result, 0);
|
assertEquals(result, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteWrites() {
|
Deno.test(async function bufferLargeByteWrites() {
|
||||||
init();
|
init();
|
||||||
const buf = new Deno.Buffer();
|
const buf = new Deno.Buffer();
|
||||||
const limit = 9;
|
const limit = 9;
|
||||||
|
@ -156,7 +155,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteWrites() {
|
||||||
check(buf, "");
|
check(buf, "");
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function bufferTooLargeByteWrites() {
|
Deno.test(async function bufferTooLargeByteWrites() {
|
||||||
init();
|
init();
|
||||||
const tmp = new Uint8Array(72);
|
const tmp = new Uint8Array(72);
|
||||||
const growLen = Number.MAX_VALUE;
|
const growLen = Number.MAX_VALUE;
|
||||||
|
@ -174,7 +173,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferTooLargeByteWrites() {
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: ignoreMaxSizeTests || DENO_FUTURE },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
function bufferGrowWriteMaxBuffer() {
|
function bufferGrowWriteMaxBuffer() {
|
||||||
const bufSize = 16 * 1024;
|
const bufSize = 16 * 1024;
|
||||||
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
||||||
|
@ -196,7 +195,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: ignoreMaxSizeTests || DENO_FUTURE },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
async function bufferGrowReadCloseMaxBufferPlus1() {
|
async function bufferGrowReadCloseMaxBufferPlus1() {
|
||||||
const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1));
|
const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1));
|
||||||
const buf = new Deno.Buffer();
|
const buf = new Deno.Buffer();
|
||||||
|
@ -212,7 +211,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: ignoreMaxSizeTests || DENO_FUTURE },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
function bufferGrowReadSyncCloseMaxBufferPlus1() {
|
function bufferGrowReadSyncCloseMaxBufferPlus1() {
|
||||||
const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1));
|
const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1));
|
||||||
const buf = new Deno.Buffer();
|
const buf = new Deno.Buffer();
|
||||||
|
@ -228,7 +227,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: ignoreMaxSizeTests || DENO_FUTURE },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
function bufferGrowReadSyncCloseToMaxBuffer() {
|
function bufferGrowReadSyncCloseToMaxBuffer() {
|
||||||
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
||||||
for (const capacity of capacities) {
|
for (const capacity of capacities) {
|
||||||
|
@ -242,7 +241,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: ignoreMaxSizeTests || DENO_FUTURE },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
async function bufferGrowReadCloseToMaxBuffer() {
|
async function bufferGrowReadCloseToMaxBuffer() {
|
||||||
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
const capacities = [MAX_SIZE, MAX_SIZE - 1];
|
||||||
for (const capacity of capacities) {
|
for (const capacity of capacities) {
|
||||||
|
@ -255,7 +254,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: ignoreMaxSizeTests || DENO_FUTURE },
|
{ ignore: ignoreMaxSizeTests },
|
||||||
async function bufferReadCloseToMaxBufferWithInitialGrow() {
|
async function bufferReadCloseToMaxBufferWithInitialGrow() {
|
||||||
const capacities = [MAX_SIZE, MAX_SIZE - 1, MAX_SIZE - 512];
|
const capacities = [MAX_SIZE, MAX_SIZE - 1, MAX_SIZE - 512];
|
||||||
for (const capacity of capacities) {
|
for (const capacity of capacities) {
|
||||||
|
@ -268,7 +267,7 @@ Deno.test(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteReads() {
|
Deno.test(async function bufferLargeByteReads() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
assert(testString);
|
assert(testString);
|
||||||
|
@ -281,12 +280,12 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteReads() {
|
||||||
check(buf, "");
|
check(buf, "");
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function bufferCapWithPreallocatedSlice() {
|
Deno.test(function bufferCapWithPreallocatedSlice() {
|
||||||
const buf = new Deno.Buffer(new ArrayBuffer(10));
|
const buf = new Deno.Buffer(new ArrayBuffer(10));
|
||||||
assertEquals(buf.capacity, 10);
|
assertEquals(buf.capacity, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFrom() {
|
Deno.test(async function bufferReadFrom() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
assert(testString);
|
assert(testString);
|
||||||
|
@ -308,7 +307,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFrom() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFromSync() {
|
Deno.test(async function bufferReadFromSync() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
assert(testString);
|
assert(testString);
|
||||||
|
@ -330,7 +329,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFromSync() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function bufferTestGrow() {
|
Deno.test(async function bufferTestGrow() {
|
||||||
const tmp = new Uint8Array(72);
|
const tmp = new Uint8Array(72);
|
||||||
for (const startLen of [0, 100, 1000, 10000]) {
|
for (const startLen of [0, 100, 1000, 10000]) {
|
||||||
const xBytes = repeat("x", startLen);
|
const xBytes = repeat("x", startLen);
|
||||||
|
@ -354,7 +353,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferTestGrow() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function testReadAll() {
|
Deno.test(async function testReadAll() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer);
|
const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer);
|
||||||
|
@ -365,7 +364,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function testReadAll() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function testReadAllSync() {
|
Deno.test(function testReadAllSync() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer);
|
const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer);
|
||||||
|
@ -376,7 +375,7 @@ Deno.test({ ignore: DENO_FUTURE }, function testReadAllSync() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function testWriteAll() {
|
Deno.test(async function testWriteAll() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
const writer = new Deno.Buffer();
|
const writer = new Deno.Buffer();
|
||||||
|
@ -388,7 +387,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function testWriteAll() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function testWriteAllSync() {
|
Deno.test(function testWriteAllSync() {
|
||||||
init();
|
init();
|
||||||
assert(testBytes);
|
assert(testBytes);
|
||||||
const writer = new Deno.Buffer();
|
const writer = new Deno.Buffer();
|
||||||
|
@ -400,7 +399,7 @@ Deno.test({ ignore: DENO_FUTURE }, function testWriteAllSync() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesArrayBufferLength() {
|
Deno.test(function testBufferBytesArrayBufferLength() {
|
||||||
// defaults to copy
|
// defaults to copy
|
||||||
const args = [{}, { copy: undefined }, undefined, { copy: true }];
|
const args = [{}, { copy: undefined }, undefined, { copy: true }];
|
||||||
for (const arg of args) {
|
for (const arg of args) {
|
||||||
|
@ -419,7 +418,7 @@ Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesArrayBufferLength() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesCopyFalse() {
|
Deno.test(function testBufferBytesCopyFalse() {
|
||||||
const bufSize = 64 * 1024;
|
const bufSize = 64 * 1024;
|
||||||
const bytes = new TextEncoder().encode("a".repeat(bufSize));
|
const bytes = new TextEncoder().encode("a".repeat(bufSize));
|
||||||
const reader = new Deno.Buffer();
|
const reader = new Deno.Buffer();
|
||||||
|
@ -434,9 +433,7 @@ Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesCopyFalse() {
|
||||||
assert(actualBytes.buffer.byteLength > actualBytes.byteLength);
|
assert(actualBytes.buffer.byteLength > actualBytes.byteLength);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(function testBufferBytesCopyFalseGrowExactBytes() {
|
||||||
{ ignore: DENO_FUTURE },
|
|
||||||
function testBufferBytesCopyFalseGrowExactBytes() {
|
|
||||||
const bufSize = 64 * 1024;
|
const bufSize = 64 * 1024;
|
||||||
const bytes = new TextEncoder().encode("a".repeat(bufSize));
|
const bytes = new TextEncoder().encode("a".repeat(bufSize));
|
||||||
const reader = new Deno.Buffer();
|
const reader = new Deno.Buffer();
|
||||||
|
@ -449,12 +446,9 @@ Deno.test(
|
||||||
|
|
||||||
assertEquals(actualBytes.byteLength, bufSize);
|
assertEquals(actualBytes.byteLength, bufSize);
|
||||||
assertEquals(actualBytes.buffer.byteLength, actualBytes.byteLength);
|
assertEquals(actualBytes.buffer.byteLength, actualBytes.byteLength);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(function testThrowsErrorWhenBufferExceedsMaxLength() {
|
||||||
{ ignore: DENO_FUTURE },
|
|
||||||
function testThrowsErrorWhenBufferExceedsMaxLength() {
|
|
||||||
const kStringMaxLengthPlusOne = 536870888 + 1;
|
const kStringMaxLengthPlusOne = 536870888 + 1;
|
||||||
const bytes = new Uint8Array(kStringMaxLengthPlusOne);
|
const bytes = new Uint8Array(kStringMaxLengthPlusOne);
|
||||||
|
|
||||||
|
@ -465,5 +459,4 @@ Deno.test(
|
||||||
TypeError,
|
TypeError,
|
||||||
"buffer exceeds maximum length",
|
"buffer exceeds maximum length",
|
||||||
);
|
);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import {
|
||||||
assertStringIncludes,
|
assertStringIncludes,
|
||||||
assertThrows,
|
assertThrows,
|
||||||
delay,
|
delay,
|
||||||
DENO_FUTURE,
|
|
||||||
fail,
|
fail,
|
||||||
unimplemented,
|
unimplemented,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
@ -1356,7 +1355,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, net: true }, ignore: DENO_FUTURE },
|
{ permissions: { read: true, net: true } },
|
||||||
async function fetchCustomClientPrivateKey(): Promise<
|
async function fetchCustomClientPrivateKey(): Promise<
|
||||||
void
|
void
|
||||||
> {
|
> {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import {
|
||||||
assertEquals,
|
assertEquals,
|
||||||
assertRejects,
|
assertRejects,
|
||||||
assertThrows,
|
assertThrows,
|
||||||
DENO_FUTURE,
|
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
import { copy } from "@std/io/copy";
|
import { copy } from "@std/io/copy";
|
||||||
|
|
||||||
|
@ -19,9 +18,7 @@ Deno.test(function filesStdioFileDescriptors() {
|
||||||
assertEquals(Deno.stderr.rid, 2);
|
assertEquals(Deno.stderr.rid, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(
|
Deno.test({ permissions: { read: true } }, async function filesCopyToStdout() {
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true } },
|
|
||||||
async function filesCopyToStdout() {
|
|
||||||
const filename = "tests/testdata/assets/fixture.json";
|
const filename = "tests/testdata/assets/fixture.json";
|
||||||
using file = await Deno.open(filename);
|
using file = await Deno.open(filename);
|
||||||
assert(file instanceof Deno.File);
|
assert(file instanceof Deno.File);
|
||||||
|
@ -30,12 +27,9 @@ Deno.test(
|
||||||
const bytesWritten = await copy(file, Deno.stdout);
|
const bytesWritten = await copy(file, Deno.stdout);
|
||||||
const fileSize = Deno.statSync(filename).size;
|
const fileSize = Deno.statSync(filename).size;
|
||||||
assertEquals(bytesWritten, fileSize);
|
assertEquals(bytesWritten, fileSize);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
Deno.test(
|
Deno.test({ permissions: { read: true } }, async function filesIter() {
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true } },
|
|
||||||
async function filesIter() {
|
|
||||||
const filename = "tests/testdata/assets/hello.txt";
|
const filename = "tests/testdata/assets/hello.txt";
|
||||||
using file = await Deno.open(filename);
|
using file = await Deno.open(filename);
|
||||||
|
|
||||||
|
@ -45,11 +39,10 @@ Deno.test(
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(totalSize, 12);
|
assertEquals(totalSize, 12);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true } },
|
{ permissions: { read: true } },
|
||||||
async function filesIterCustomBufSize() {
|
async function filesIterCustomBufSize() {
|
||||||
const filename = "tests/testdata/assets/hello.txt";
|
const filename = "tests/testdata/assets/hello.txt";
|
||||||
using file = await Deno.open(filename);
|
using file = await Deno.open(filename);
|
||||||
|
@ -66,9 +59,7 @@ Deno.test(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test({ permissions: { read: true } }, function filesIterSync() {
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true } },
|
|
||||||
function filesIterSync() {
|
|
||||||
const filename = "tests/testdata/assets/hello.txt";
|
const filename = "tests/testdata/assets/hello.txt";
|
||||||
using file = Deno.openSync(filename);
|
using file = Deno.openSync(filename);
|
||||||
|
|
||||||
|
@ -78,11 +69,10 @@ Deno.test(
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(totalSize, 12);
|
assertEquals(totalSize, 12);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true } },
|
{ permissions: { read: true } },
|
||||||
function filesIterSyncCustomBufSize() {
|
function filesIterSyncCustomBufSize() {
|
||||||
const filename = "tests/testdata/assets/hello.txt";
|
const filename = "tests/testdata/assets/hello.txt";
|
||||||
using file = Deno.openSync(filename);
|
using file = Deno.openSync(filename);
|
||||||
|
@ -99,7 +89,7 @@ Deno.test(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function readerIter() {
|
Deno.test(async function readerIter() {
|
||||||
// ref: https://github.com/denoland/deno/issues/2330
|
// ref: https://github.com/denoland/deno/issues/2330
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
|
|
||||||
|
@ -134,7 +124,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function readerIter() {
|
||||||
assertEquals(totalSize, 12);
|
assertEquals(totalSize, 12);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function readerIterSync() {
|
Deno.test(async function readerIterSync() {
|
||||||
// ref: https://github.com/denoland/deno/issues/2330
|
// ref: https://github.com/denoland/deno/issues/2330
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertEquals, DENO_FUTURE } from "./test_util.ts";
|
import { assertEquals } from "./test_util.ts";
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true, run: true, hrtime: true } },
|
{ permissions: { read: true, run: true, hrtime: true } },
|
||||||
async function flockFileSync() {
|
async function flockFileSync() {
|
||||||
await runFlockTests({ sync: true });
|
await runFlockTests({ sync: true });
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true, run: true, hrtime: true } },
|
{ permissions: { read: true, run: true, hrtime: true } },
|
||||||
async function flockFileAsync() {
|
async function flockFileAsync() {
|
||||||
await runFlockTests({ sync: false });
|
await runFlockTests({ sync: false });
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,6 @@ import {
|
||||||
assertEquals,
|
assertEquals,
|
||||||
assertRejects,
|
assertRejects,
|
||||||
assertThrows,
|
assertThrows,
|
||||||
DENO_FUTURE,
|
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
Deno.test(function globalThisExists() {
|
Deno.test(function globalThisExists() {
|
||||||
|
@ -20,7 +19,7 @@ Deno.test(function noInternalGlobals() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function windowExists() {
|
Deno.test(function windowExists() {
|
||||||
assert(window != null);
|
assert(window != null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -28,15 +27,15 @@ Deno.test(function selfExists() {
|
||||||
assert(self != null);
|
assert(self != null);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function windowWindowExists() {
|
Deno.test(function windowWindowExists() {
|
||||||
assert(window.window === window);
|
assert(window.window === window);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function windowSelfExists() {
|
Deno.test(function windowSelfExists() {
|
||||||
assert(window.self === window);
|
assert(window.self === window);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function globalThisEqualsWindow() {
|
Deno.test(function globalThisEqualsWindow() {
|
||||||
assert(globalThis === window);
|
assert(globalThis === window);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -44,7 +43,7 @@ Deno.test(function globalThisEqualsSelf() {
|
||||||
assert(globalThis === self);
|
assert(globalThis === self);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function globalThisInstanceofWindow() {
|
Deno.test(function globalThisInstanceofWindow() {
|
||||||
assert(globalThis instanceof Window);
|
assert(globalThis instanceof Window);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -66,7 +65,7 @@ Deno.test(function DenoNamespaceExists() {
|
||||||
assert(Deno != null);
|
assert(Deno != null);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function DenoNamespaceEqualsWindowDeno() {
|
Deno.test(function DenoNamespaceEqualsWindowDeno() {
|
||||||
assert(Deno === window.Deno);
|
assert(Deno === window.Deno);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -120,11 +119,7 @@ Deno.test(async function windowQueueMicrotask() {
|
||||||
res();
|
res();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
if (DENO_FUTURE) {
|
|
||||||
globalThis.queueMicrotask(resolve1!);
|
|
||||||
} else {
|
|
||||||
window.queueMicrotask(resolve1!);
|
window.queueMicrotask(resolve1!);
|
||||||
}
|
|
||||||
setTimeout(resolve2!, 0);
|
setTimeout(resolve2!, 0);
|
||||||
await p1;
|
await p1;
|
||||||
await p2;
|
await p2;
|
||||||
|
@ -143,18 +138,12 @@ Deno.test(function webApiGlobalThis() {
|
||||||
Deno.test(function windowNameIsDefined() {
|
Deno.test(function windowNameIsDefined() {
|
||||||
assertEquals(typeof globalThis.name, "string");
|
assertEquals(typeof globalThis.name, "string");
|
||||||
assertEquals(name, "");
|
assertEquals(name, "");
|
||||||
if (!DENO_FUTURE) {
|
|
||||||
assertEquals(window.name, name);
|
assertEquals(window.name, name);
|
||||||
}
|
|
||||||
name = "foobar";
|
name = "foobar";
|
||||||
if (!DENO_FUTURE) {
|
|
||||||
assertEquals(window.name, "foobar");
|
assertEquals(window.name, "foobar");
|
||||||
}
|
|
||||||
assertEquals(name, "foobar");
|
assertEquals(name, "foobar");
|
||||||
name = "";
|
name = "";
|
||||||
if (!DENO_FUTURE) {
|
|
||||||
assertEquals(window.name, "");
|
assertEquals(window.name, "");
|
||||||
}
|
|
||||||
assertEquals(name, "");
|
assertEquals(name, "");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertEquals, DENO_FUTURE } from "./test_util.ts";
|
import { assertEquals } from "./test_util.ts";
|
||||||
import { Buffer } from "@std/io/buffer";
|
import { Buffer } from "@std/io/buffer";
|
||||||
|
|
||||||
const DEFAULT_BUF_SIZE = 32 * 1024;
|
const DEFAULT_BUF_SIZE = 32 * 1024;
|
||||||
|
@ -28,7 +28,7 @@ function spyRead(obj: Buffer): Spy {
|
||||||
return spy;
|
return spy;
|
||||||
}
|
}
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function copyWithDefaultBufferSize() {
|
Deno.test(async function copyWithDefaultBufferSize() {
|
||||||
const xBytes = repeat("b", DEFAULT_BUF_SIZE);
|
const xBytes = repeat("b", DEFAULT_BUF_SIZE);
|
||||||
const reader = new Buffer(xBytes.buffer as ArrayBuffer);
|
const reader = new Buffer(xBytes.buffer as ArrayBuffer);
|
||||||
const write = new Buffer();
|
const write = new Buffer();
|
||||||
|
@ -43,7 +43,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function copyWithDefaultBufferSize() {
|
||||||
assertEquals(readSpy.calls, 2); // read with DEFAULT_BUF_SIZE bytes + read with 0 bytes
|
assertEquals(readSpy.calls, 2); // read with DEFAULT_BUF_SIZE bytes + read with 0 bytes
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function copyWithCustomBufferSize() {
|
Deno.test(async function copyWithCustomBufferSize() {
|
||||||
const bufSize = 1024;
|
const bufSize = 1024;
|
||||||
const xBytes = repeat("b", DEFAULT_BUF_SIZE);
|
const xBytes = repeat("b", DEFAULT_BUF_SIZE);
|
||||||
const reader = new Buffer(xBytes.buffer as ArrayBuffer);
|
const reader = new Buffer(xBytes.buffer as ArrayBuffer);
|
||||||
|
@ -59,9 +59,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function copyWithCustomBufferSize() {
|
||||||
assertEquals(readSpy.calls, DEFAULT_BUF_SIZE / bufSize + 1);
|
assertEquals(readSpy.calls, DEFAULT_BUF_SIZE / bufSize + 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(
|
Deno.test({ permissions: { write: true } }, async function copyBufferToFile() {
|
||||||
{ ignore: DENO_FUTURE, permissions: { write: true } },
|
|
||||||
async function copyBufferToFile() {
|
|
||||||
const filePath = "test-file.txt";
|
const filePath = "test-file.txt";
|
||||||
// bigger than max File possible buffer 16kb
|
// bigger than max File possible buffer 16kb
|
||||||
const bufSize = 32 * 1024;
|
const bufSize = 32 * 1024;
|
||||||
|
@ -76,5 +74,4 @@ Deno.test(
|
||||||
|
|
||||||
write.close();
|
write.close();
|
||||||
await Deno.remove(filePath);
|
await Deno.remove(filePath);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import {
|
||||||
assertRejects,
|
assertRejects,
|
||||||
assertThrows,
|
assertThrows,
|
||||||
delay,
|
delay,
|
||||||
DENO_FUTURE,
|
|
||||||
execCode,
|
execCode,
|
||||||
execCode2,
|
execCode2,
|
||||||
tmpUnixSocketPath,
|
tmpUnixSocketPath,
|
||||||
|
@ -28,9 +27,7 @@ Deno.test({ permissions: { net: true } }, function netTcpListenClose() {
|
||||||
assert(listener.addr.transport === "tcp");
|
assert(listener.addr.transport === "tcp");
|
||||||
assertEquals(listener.addr.hostname, "127.0.0.1");
|
assertEquals(listener.addr.hostname, "127.0.0.1");
|
||||||
assertEquals(listener.addr.port, listenPort);
|
assertEquals(listener.addr.port, listenPort);
|
||||||
if (!DENO_FUTURE) {
|
|
||||||
assertNotEquals(listener.rid, 0);
|
assertNotEquals(listener.rid, 0);
|
||||||
}
|
|
||||||
listener.close();
|
listener.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -236,9 +233,7 @@ Deno.test({ permissions: { net: true } }, async function netTcpDialListen() {
|
||||||
assertEquals(1, buf[0]);
|
assertEquals(1, buf[0]);
|
||||||
assertEquals(2, buf[1]);
|
assertEquals(2, buf[1]);
|
||||||
assertEquals(3, buf[2]);
|
assertEquals(3, buf[2]);
|
||||||
if (!DENO_FUTURE) {
|
|
||||||
assert(conn.rid > 0);
|
assert(conn.rid > 0);
|
||||||
}
|
|
||||||
|
|
||||||
assert(readResult !== null);
|
assert(readResult !== null);
|
||||||
|
|
||||||
|
@ -274,9 +269,7 @@ Deno.test({ permissions: { net: true } }, async function netTcpSetNoDelay() {
|
||||||
assertEquals(1, buf[0]);
|
assertEquals(1, buf[0]);
|
||||||
assertEquals(2, buf[1]);
|
assertEquals(2, buf[1]);
|
||||||
assertEquals(3, buf[2]);
|
assertEquals(3, buf[2]);
|
||||||
if (!DENO_FUTURE) {
|
|
||||||
assert(conn.rid > 0);
|
assert(conn.rid > 0);
|
||||||
}
|
|
||||||
|
|
||||||
assert(readResult !== null);
|
assert(readResult !== null);
|
||||||
|
|
||||||
|
@ -312,9 +305,7 @@ Deno.test({ permissions: { net: true } }, async function netTcpSetKeepAlive() {
|
||||||
assertEquals(1, buf[0]);
|
assertEquals(1, buf[0]);
|
||||||
assertEquals(2, buf[1]);
|
assertEquals(2, buf[1]);
|
||||||
assertEquals(3, buf[2]);
|
assertEquals(3, buf[2]);
|
||||||
if (!DENO_FUTURE) {
|
|
||||||
assert(conn.rid > 0);
|
assert(conn.rid > 0);
|
||||||
}
|
|
||||||
|
|
||||||
assert(readResult !== null);
|
assert(readResult !== null);
|
||||||
|
|
||||||
|
@ -352,9 +343,7 @@ Deno.test(
|
||||||
assertEquals(1, buf[0]);
|
assertEquals(1, buf[0]);
|
||||||
assertEquals(2, buf[1]);
|
assertEquals(2, buf[1]);
|
||||||
assertEquals(3, buf[2]);
|
assertEquals(3, buf[2]);
|
||||||
if (!DENO_FUTURE) {
|
|
||||||
assert(conn.rid > 0);
|
assert(conn.rid > 0);
|
||||||
}
|
|
||||||
|
|
||||||
assert(readResult !== null);
|
assert(readResult !== null);
|
||||||
|
|
||||||
|
@ -850,9 +839,7 @@ Deno.test(
|
||||||
assertEquals(1, buf[0]);
|
assertEquals(1, buf[0]);
|
||||||
assertEquals(2, buf[1]);
|
assertEquals(2, buf[1]);
|
||||||
assertEquals(3, buf[2]);
|
assertEquals(3, buf[2]);
|
||||||
if (!DENO_FUTURE) {
|
|
||||||
assert(conn.rid > 0);
|
assert(conn.rid > 0);
|
||||||
}
|
|
||||||
|
|
||||||
assert(readResult !== null);
|
assert(readResult !== null);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import {
|
||||||
assertStrictEquals,
|
assertStrictEquals,
|
||||||
assertStringIncludes,
|
assertStringIncludes,
|
||||||
assertThrows,
|
assertThrows,
|
||||||
DENO_FUTURE,
|
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
|
@ -364,11 +363,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{
|
{ permissions: { run: true, write: true, read: true } },
|
||||||
// Ignoring because uses `file.rid`
|
|
||||||
ignore: DENO_FUTURE,
|
|
||||||
permissions: { run: true, write: true, read: true },
|
|
||||||
},
|
|
||||||
async function runRedirectStdoutStderr() {
|
async function runRedirectStdoutStderr() {
|
||||||
const tempDir = await Deno.makeTempDir();
|
const tempDir = await Deno.makeTempDir();
|
||||||
const fileName = tempDir + "/redirected_stdio.txt";
|
const fileName = tempDir + "/redirected_stdio.txt";
|
||||||
|
@ -397,16 +392,11 @@ Deno.test(
|
||||||
|
|
||||||
assertStringIncludes(text, "error");
|
assertStringIncludes(text, "error");
|
||||||
assertStringIncludes(text, "output");
|
assertStringIncludes(text, "output");
|
||||||
console.log("finished tgis test");
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{
|
{ permissions: { run: true, write: true, read: true } },
|
||||||
// Ignoring because uses `file.rid`
|
|
||||||
ignore: DENO_FUTURE,
|
|
||||||
permissions: { run: true, write: true, read: true },
|
|
||||||
},
|
|
||||||
async function runRedirectStdin() {
|
async function runRedirectStdin() {
|
||||||
const tempDir = await Deno.makeTempDir();
|
const tempDir = await Deno.makeTempDir();
|
||||||
const fileName = tempDir + "/redirected_stdio.txt";
|
const fileName = tempDir + "/redirected_stdio.txt";
|
||||||
|
|
|
@ -2,12 +2,7 @@
|
||||||
|
|
||||||
// deno-lint-ignore-file no-deprecated-deno-api
|
// deno-lint-ignore-file no-deprecated-deno-api
|
||||||
|
|
||||||
import {
|
import { assert, assertEquals, assertThrows } from "./test_util.ts";
|
||||||
assert,
|
|
||||||
assertEquals,
|
|
||||||
assertThrows,
|
|
||||||
DENO_FUTURE,
|
|
||||||
} from "./test_util.ts";
|
|
||||||
|
|
||||||
const listenPort = 4505;
|
const listenPort = 4505;
|
||||||
|
|
||||||
|
@ -17,7 +12,7 @@ Deno.test(function resourcesCloseBadArgs() {
|
||||||
}, TypeError);
|
}, TypeError);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, function resourcesStdio() {
|
Deno.test(function resourcesStdio() {
|
||||||
const res = Deno.resources();
|
const res = Deno.resources();
|
||||||
|
|
||||||
assertEquals(res[0], "stdin");
|
assertEquals(res[0], "stdin");
|
||||||
|
@ -25,9 +20,7 @@ Deno.test({ ignore: DENO_FUTURE }, function resourcesStdio() {
|
||||||
assertEquals(res[2], "stderr");
|
assertEquals(res[2], "stderr");
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(
|
Deno.test({ permissions: { net: true } }, async function resourcesNet() {
|
||||||
{ ignore: DENO_FUTURE, permissions: { net: true } },
|
|
||||||
async function resourcesNet() {
|
|
||||||
const listener = Deno.listen({ port: listenPort });
|
const listener = Deno.listen({ port: listenPort });
|
||||||
const dialerConn = await Deno.connect({ port: listenPort });
|
const dialerConn = await Deno.connect({ port: listenPort });
|
||||||
const listenerConn = await listener.accept();
|
const listenerConn = await listener.accept();
|
||||||
|
@ -45,12 +38,9 @@ Deno.test(
|
||||||
listenerConn.close();
|
listenerConn.close();
|
||||||
dialerConn.close();
|
dialerConn.close();
|
||||||
listener.close();
|
listener.close();
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
Deno.test(
|
Deno.test({ permissions: { read: true } }, async function resourcesFile() {
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true } },
|
|
||||||
async function resourcesFile() {
|
|
||||||
const resourcesBefore = Deno.resources();
|
const resourcesBefore = Deno.resources();
|
||||||
const f = await Deno.open("tests/testdata/assets/hello.txt");
|
const f = await Deno.open("tests/testdata/assets/hello.txt");
|
||||||
const resourcesAfter = Deno.resources();
|
const resourcesAfter = Deno.resources();
|
||||||
|
@ -65,5 +55,4 @@ Deno.test(
|
||||||
return !Object.prototype.hasOwnProperty.call(resourcesBefore, rid);
|
return !Object.prototype.hasOwnProperty.call(resourcesBefore, rid);
|
||||||
})!;
|
})!;
|
||||||
assertEquals(resourcesAfter[newRid], "fsFile");
|
assertEquals(resourcesAfter[newRid], "fsFile");
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
|
@ -7,13 +7,10 @@ import {
|
||||||
assertEquals,
|
assertEquals,
|
||||||
assertRejects,
|
assertRejects,
|
||||||
assertThrows,
|
assertThrows,
|
||||||
DENO_FUTURE,
|
|
||||||
pathToAbsoluteFileUrl,
|
pathToAbsoluteFileUrl,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
Deno.test(
|
Deno.test({ permissions: { read: true } }, function fstatSyncSuccess() {
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true } },
|
|
||||||
function fstatSyncSuccess() {
|
|
||||||
using file = Deno.openSync("README.md");
|
using file = Deno.openSync("README.md");
|
||||||
const fileInfo = Deno.fstatSync(file.rid);
|
const fileInfo = Deno.fstatSync(file.rid);
|
||||||
assert(fileInfo.isFile);
|
assert(fileInfo.isFile);
|
||||||
|
@ -24,12 +21,9 @@ Deno.test(
|
||||||
assert(fileInfo.mtime);
|
assert(fileInfo.mtime);
|
||||||
// The `birthtime` field is not available on Linux before kernel version 4.11.
|
// The `birthtime` field is not available on Linux before kernel version 4.11.
|
||||||
assert(fileInfo.birthtime || Deno.build.os === "linux");
|
assert(fileInfo.birthtime || Deno.build.os === "linux");
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
Deno.test(
|
Deno.test({ permissions: { read: true } }, async function fstatSuccess() {
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true } },
|
|
||||||
async function fstatSuccess() {
|
|
||||||
using file = await Deno.open("README.md");
|
using file = await Deno.open("README.md");
|
||||||
const fileInfo = await Deno.fstat(file.rid);
|
const fileInfo = await Deno.fstat(file.rid);
|
||||||
assert(fileInfo.isFile);
|
assert(fileInfo.isFile);
|
||||||
|
@ -40,8 +34,7 @@ Deno.test(
|
||||||
assert(fileInfo.mtime);
|
assert(fileInfo.mtime);
|
||||||
// The `birthtime` field is not available on Linux before kernel version 4.11.
|
// The `birthtime` field is not available on Linux before kernel version 4.11.
|
||||||
assert(fileInfo.birthtime || Deno.build.os === "linux");
|
assert(fileInfo.birthtime || Deno.build.os === "linux");
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, write: true } },
|
{ permissions: { read: true, write: true } },
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertEquals, DENO_FUTURE } from "./test_util.ts";
|
import { assertEquals } from "./test_util.ts";
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true, write: true } },
|
{ permissions: { read: true, write: true } },
|
||||||
function fdatasyncSyncSuccess() {
|
function fdatasyncSyncSuccess() {
|
||||||
const filename = Deno.makeTempDirSync() + "/test_fdatasyncSync.txt";
|
const filename = Deno.makeTempDirSync() + "/test_fdatasyncSync.txt";
|
||||||
using file = Deno.openSync(filename, {
|
using file = Deno.openSync(filename, {
|
||||||
|
@ -18,7 +18,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true, write: true } },
|
{ permissions: { read: true, write: true } },
|
||||||
async function fdatasyncSuccess() {
|
async function fdatasyncSuccess() {
|
||||||
const filename = (await Deno.makeTempDir()) + "/test_fdatasync.txt";
|
const filename = (await Deno.makeTempDir()) + "/test_fdatasync.txt";
|
||||||
using file = await Deno.open(filename, {
|
using file = await Deno.open(filename, {
|
||||||
|
@ -35,7 +35,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true, write: true } },
|
{ permissions: { read: true, write: true } },
|
||||||
function fsyncSyncSuccess() {
|
function fsyncSyncSuccess() {
|
||||||
const filename = Deno.makeTempDirSync() + "/test_fsyncSync.txt";
|
const filename = Deno.makeTempDirSync() + "/test_fsyncSync.txt";
|
||||||
using file = Deno.openSync(filename, {
|
using file = Deno.openSync(filename, {
|
||||||
|
@ -52,7 +52,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true, write: true } },
|
{ permissions: { read: true, write: true } },
|
||||||
async function fsyncSuccess() {
|
async function fsyncSuccess() {
|
||||||
const filename = (await Deno.makeTempDir()) + "/test_fsync.txt";
|
const filename = (await Deno.makeTempDir()) + "/test_fsync.txt";
|
||||||
using file = await Deno.open(filename, {
|
using file = await Deno.open(filename, {
|
||||||
|
|
|
@ -25,8 +25,6 @@ export { delay } from "@std/async/delay";
|
||||||
export { readLines } from "@std/io/read-lines";
|
export { readLines } from "@std/io/read-lines";
|
||||||
export { parseArgs } from "@std/cli/parse-args";
|
export { parseArgs } from "@std/cli/parse-args";
|
||||||
|
|
||||||
export const DENO_FUTURE = Deno.env.get("DENO_FUTURE") === "1";
|
|
||||||
|
|
||||||
export function pathToAbsoluteFileUrl(path: string): URL {
|
export function pathToAbsoluteFileUrl(path: string): URL {
|
||||||
path = resolve(path);
|
path = resolve(path);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
assertEquals,
|
assertEquals,
|
||||||
assertNotEquals,
|
assertNotEquals,
|
||||||
delay,
|
delay,
|
||||||
DENO_FUTURE,
|
|
||||||
execCode,
|
execCode,
|
||||||
unreachable,
|
unreachable,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
@ -309,63 +308,11 @@ Deno.test(async function timeoutCallbackThis() {
|
||||||
};
|
};
|
||||||
setTimeout(obj.foo, 1);
|
setTimeout(obj.foo, 1);
|
||||||
await promise;
|
await promise;
|
||||||
if (!DENO_FUTURE) {
|
|
||||||
assertEquals(capturedThis, window);
|
assertEquals(capturedThis, window);
|
||||||
} else {
|
|
||||||
assertEquals(capturedThis, globalThis);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ ignore: DENO_FUTURE }, async function timeoutBindThis() {
|
Deno.test(async function timeoutBindThis() {
|
||||||
const thisCheckPassed = [null, undefined, globalThis, window];
|
const thisCheckPassed = [null, undefined, window, globalThis];
|
||||||
|
|
||||||
const thisCheckFailed = [
|
|
||||||
0,
|
|
||||||
"",
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
{},
|
|
||||||
[],
|
|
||||||
"foo",
|
|
||||||
() => {},
|
|
||||||
Object.prototype,
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const thisArg of thisCheckPassed) {
|
|
||||||
const { promise, resolve } = Promise.withResolvers<void>();
|
|
||||||
let hasThrown = 0;
|
|
||||||
try {
|
|
||||||
setTimeout.call(thisArg, () => resolve(), 1);
|
|
||||||
hasThrown = 1;
|
|
||||||
} catch (err) {
|
|
||||||
if (err instanceof TypeError) {
|
|
||||||
hasThrown = 2;
|
|
||||||
} else {
|
|
||||||
hasThrown = 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await promise;
|
|
||||||
assertEquals(hasThrown, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const thisArg of thisCheckFailed) {
|
|
||||||
let hasThrown = 0;
|
|
||||||
try {
|
|
||||||
setTimeout.call(thisArg, () => {}, 1);
|
|
||||||
hasThrown = 1;
|
|
||||||
} catch (err) {
|
|
||||||
if (err instanceof TypeError) {
|
|
||||||
hasThrown = 2;
|
|
||||||
} else {
|
|
||||||
hasThrown = 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertEquals(hasThrown, 2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Deno.test({ ignore: !DENO_FUTURE }, async function timeoutBindThis() {
|
|
||||||
const thisCheckPassed = [null, undefined, globalThis];
|
|
||||||
|
|
||||||
const thisCheckFailed = [
|
const thisCheckFailed = [
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -6,7 +6,6 @@ import {
|
||||||
assertRejects,
|
assertRejects,
|
||||||
assertStrictEquals,
|
assertStrictEquals,
|
||||||
assertThrows,
|
assertThrows,
|
||||||
DENO_FUTURE,
|
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
import { BufReader, BufWriter } from "@std/io";
|
import { BufReader, BufWriter } from "@std/io";
|
||||||
import { readAll } from "@std/io/read-all";
|
import { readAll } from "@std/io/read-all";
|
||||||
|
@ -68,7 +67,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { net: true, read: false }, ignore: DENO_FUTURE },
|
{ permissions: { net: true, read: false } },
|
||||||
async function connectTLSCertFileNoReadPerm() {
|
async function connectTLSCertFileNoReadPerm() {
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await Deno.connectTls({
|
await Deno.connectTls({
|
||||||
|
@ -81,7 +80,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, net: true }, ignore: DENO_FUTURE },
|
{ permissions: { read: true, net: true } },
|
||||||
function listenTLSNonExistentCertKeyFiles() {
|
function listenTLSNonExistentCertKeyFiles() {
|
||||||
const options = {
|
const options = {
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
|
@ -107,7 +106,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { net: true, read: false }, ignore: DENO_FUTURE },
|
{ permissions: { net: true, read: false } },
|
||||||
function listenTLSNoReadPerm() {
|
function listenTLSNoReadPerm() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.listenTls({
|
Deno.listenTls({
|
||||||
|
@ -123,7 +122,6 @@ Deno.test(
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{
|
{
|
||||||
permissions: { read: true, write: true, net: true },
|
permissions: { read: true, write: true, net: true },
|
||||||
ignore: DENO_FUTURE,
|
|
||||||
},
|
},
|
||||||
function listenTLSEmptyKeyFile() {
|
function listenTLSEmptyKeyFile() {
|
||||||
const options = {
|
const options = {
|
||||||
|
@ -221,7 +219,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
const conn = await Deno.connectTls({ hostname, port, caCerts });
|
const conn = await Deno.connectTls({ hostname, port, caCerts });
|
||||||
assert(DENO_FUTURE || conn.rid > 0);
|
assert(conn.rid > 0);
|
||||||
const w = new BufWriter(conn);
|
const w = new BufWriter(conn);
|
||||||
const r = new BufReader(conn);
|
const r = new BufReader(conn);
|
||||||
const body = `GET / HTTP/1.1\r\nHost: ${hostname}:${port}\r\n\r\n`;
|
const body = `GET / HTTP/1.1\r\nHost: ${hostname}:${port}\r\n\r\n`;
|
||||||
|
@ -273,7 +271,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
const conn = await Deno.connectTls({ hostname, port, caCerts });
|
const conn = await Deno.connectTls({ hostname, port, caCerts });
|
||||||
assert(DENO_FUTURE || conn.rid > 0);
|
assert(conn.rid > 0);
|
||||||
const w = new BufWriter(conn);
|
const w = new BufWriter(conn);
|
||||||
const r = new BufReader(conn);
|
const r = new BufReader(conn);
|
||||||
const body = `GET / HTTP/1.1\r\nHost: ${hostname}:${port}\r\n\r\n`;
|
const body = `GET / HTTP/1.1\r\nHost: ${hostname}:${port}\r\n\r\n`;
|
||||||
|
@ -1148,7 +1146,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, net: true }, ignore: DENO_FUTURE },
|
{ permissions: { read: true, net: true } },
|
||||||
async function connectTLSBadClientCertPrivateKey(): Promise<void> {
|
async function connectTLSBadClientCertPrivateKey(): Promise<void> {
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await Deno.connectTls({
|
await Deno.connectTls({
|
||||||
|
@ -1164,7 +1162,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, net: true }, ignore: DENO_FUTURE },
|
{ permissions: { read: true, net: true } },
|
||||||
async function connectTLSBadCertKey(): Promise<void> {
|
async function connectTLSBadCertKey(): Promise<void> {
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await Deno.connectTls({
|
await Deno.connectTls({
|
||||||
|
@ -1180,7 +1178,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, net: true }, ignore: DENO_FUTURE },
|
{ permissions: { read: true, net: true } },
|
||||||
async function connectTLSBadPrivateKey(): Promise<void> {
|
async function connectTLSBadPrivateKey(): Promise<void> {
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await Deno.connectTls({
|
await Deno.connectTls({
|
||||||
|
@ -1212,7 +1210,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, net: true }, ignore: DENO_FUTURE },
|
{ permissions: { read: true, net: true } },
|
||||||
async function connectTLSNotPrivateKey(): Promise<void> {
|
async function connectTLSNotPrivateKey(): Promise<void> {
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await Deno.connectTls({
|
await Deno.connectTls({
|
||||||
|
@ -1228,7 +1226,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, net: true }, ignore: DENO_FUTURE },
|
{ permissions: { read: true, net: true } },
|
||||||
async function connectTLSNotKey(): Promise<void> {
|
async function connectTLSNotKey(): Promise<void> {
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await Deno.connectTls({
|
await Deno.connectTls({
|
||||||
|
@ -1244,7 +1242,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, net: true }, ignore: DENO_FUTURE },
|
{ permissions: { read: true, net: true } },
|
||||||
async function connectWithClientCert() {
|
async function connectWithClientCert() {
|
||||||
// The test_server running on port 4552 responds with 'PASS' if client
|
// The test_server running on port 4552 responds with 'PASS' if client
|
||||||
// authentication was successful. Try it by running test_server and
|
// authentication was successful. Try it by running test_server and
|
||||||
|
@ -1294,7 +1292,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, net: true }, ignore: DENO_FUTURE },
|
{ permissions: { read: true, net: true } },
|
||||||
async function connectTlsConflictingCertOptions(): Promise<void> {
|
async function connectTlsConflictingCertOptions(): Promise<void> {
|
||||||
await assertRejects(
|
await assertRejects(
|
||||||
async () => {
|
async () => {
|
||||||
|
@ -1319,7 +1317,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, net: true }, ignore: DENO_FUTURE },
|
{ permissions: { read: true, net: true } },
|
||||||
async function connectTlsConflictingKeyOptions(): Promise<void> {
|
async function connectTlsConflictingKeyOptions(): Promise<void> {
|
||||||
await assertRejects(
|
await assertRejects(
|
||||||
async () => {
|
async () => {
|
||||||
|
@ -1637,7 +1635,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: DENO_FUTURE, permissions: { net: true, read: true } },
|
{ permissions: { net: true, read: true } },
|
||||||
function listenTLSEcKey() {
|
function listenTLSEcKey() {
|
||||||
const listener = Deno.listenTls({
|
const listener = Deno.listenTls({
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// deno-lint-ignore-file no-deprecated-deno-api
|
// deno-lint-ignore-file no-deprecated-deno-api
|
||||||
|
|
||||||
import { assert, DENO_FUTURE } from "./test_util.ts";
|
import { assert } from "./test_util.ts";
|
||||||
|
|
||||||
// Note tests for Deno.stdin.setRaw is in integration tests.
|
// Note tests for Deno.stdin.setRaw is in integration tests.
|
||||||
|
|
||||||
|
@ -15,15 +15,12 @@ Deno.test(function consoleSize() {
|
||||||
assert(typeof result.rows !== "undefined");
|
assert(typeof result.rows !== "undefined");
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(
|
Deno.test({ permissions: { read: true } }, function isatty() {
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true } },
|
|
||||||
function isatty() {
|
|
||||||
// CI not under TTY, so cannot test stdin/stdout/stderr.
|
// CI not under TTY, so cannot test stdin/stdout/stderr.
|
||||||
const f = Deno.openSync("tests/testdata/assets/hello.txt");
|
const f = Deno.openSync("tests/testdata/assets/hello.txt");
|
||||||
assert(!Deno.isatty(f.rid));
|
assert(!Deno.isatty(f.rid));
|
||||||
f.close();
|
f.close();
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
Deno.test(function isattyError() {
|
Deno.test(function isattyError() {
|
||||||
let caught = false;
|
let caught = false;
|
||||||
|
|
|
@ -6,12 +6,11 @@ import {
|
||||||
assertEquals,
|
assertEquals,
|
||||||
assertRejects,
|
assertRejects,
|
||||||
assertThrows,
|
assertThrows,
|
||||||
DENO_FUTURE,
|
|
||||||
pathToAbsoluteFileUrl,
|
pathToAbsoluteFileUrl,
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true, write: true } },
|
{ permissions: { read: true, write: true } },
|
||||||
async function futimeSyncSuccess() {
|
async function futimeSyncSuccess() {
|
||||||
const testDir = await Deno.makeTempDir();
|
const testDir = await Deno.makeTempDir();
|
||||||
const filename = testDir + "/file.txt";
|
const filename = testDir + "/file.txt";
|
||||||
|
@ -53,7 +52,7 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ ignore: DENO_FUTURE, permissions: { read: true, write: true } },
|
{ permissions: { read: true, write: true } },
|
||||||
function futimeSyncSuccess() {
|
function futimeSyncSuccess() {
|
||||||
const testDir = Deno.makeTempDirSync();
|
const testDir = Deno.makeTempDirSync();
|
||||||
const filename = testDir + "/file.txt";
|
const filename = testDir + "/file.txt";
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
|
|
||||||
// https://github.com/denoland/deno/issues/11664
|
// https://github.com/denoland/deno/issues/11664
|
||||||
Deno.test(async function testImportArrayBufferKey() {
|
Deno.test(async function testImportArrayBufferKey() {
|
||||||
const subtle = globalThis.crypto.subtle;
|
const subtle = window.crypto.subtle;
|
||||||
assert(subtle);
|
assert(subtle);
|
||||||
|
|
||||||
// deno-fmt-ignore
|
// deno-fmt-ignore
|
||||||
|
@ -29,7 +29,7 @@ Deno.test(async function testImportArrayBufferKey() {
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(async function testSignVerify() {
|
Deno.test(async function testSignVerify() {
|
||||||
const subtle = globalThis.crypto.subtle;
|
const subtle = window.crypto.subtle;
|
||||||
assert(subtle);
|
assert(subtle);
|
||||||
for (const algorithm of ["RSA-PSS", "RSASSA-PKCS1-v1_5"]) {
|
for (const algorithm of ["RSA-PSS", "RSASSA-PKCS1-v1_5"]) {
|
||||||
for (
|
for (
|
||||||
|
@ -101,7 +101,7 @@ const hashPlainTextVector = [
|
||||||
];
|
];
|
||||||
|
|
||||||
Deno.test(async function testEncryptDecrypt() {
|
Deno.test(async function testEncryptDecrypt() {
|
||||||
const subtle = globalThis.crypto.subtle;
|
const subtle = window.crypto.subtle;
|
||||||
assert(subtle);
|
assert(subtle);
|
||||||
for (
|
for (
|
||||||
const { hash, plainText } of hashPlainTextVector
|
const { hash, plainText } of hashPlainTextVector
|
||||||
|
@ -154,7 +154,7 @@ Deno.test(async function testEncryptDecrypt() {
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(async function testGenerateRSAKey() {
|
Deno.test(async function testGenerateRSAKey() {
|
||||||
const subtle = globalThis.crypto.subtle;
|
const subtle = window.crypto.subtle;
|
||||||
assert(subtle);
|
assert(subtle);
|
||||||
|
|
||||||
const keyPair = await subtle.generateKey(
|
const keyPair = await subtle.generateKey(
|
||||||
|
@ -175,7 +175,7 @@ Deno.test(async function testGenerateRSAKey() {
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(async function testGenerateHMACKey() {
|
Deno.test(async function testGenerateHMACKey() {
|
||||||
const key = await globalThis.crypto.subtle.generateKey(
|
const key = await window.crypto.subtle.generateKey(
|
||||||
{
|
{
|
||||||
name: "HMAC",
|
name: "HMAC",
|
||||||
hash: "SHA-512",
|
hash: "SHA-512",
|
||||||
|
@ -190,7 +190,7 @@ Deno.test(async function testGenerateHMACKey() {
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(async function testECDSASignVerify() {
|
Deno.test(async function testECDSASignVerify() {
|
||||||
const key = await globalThis.crypto.subtle.generateKey(
|
const key = await window.crypto.subtle.generateKey(
|
||||||
{
|
{
|
||||||
name: "ECDSA",
|
name: "ECDSA",
|
||||||
namedCurve: "P-384",
|
namedCurve: "P-384",
|
||||||
|
@ -201,7 +201,7 @@ Deno.test(async function testECDSASignVerify() {
|
||||||
|
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const encoded = encoder.encode("Hello, World!");
|
const encoded = encoder.encode("Hello, World!");
|
||||||
const signature = await globalThis.crypto.subtle.sign(
|
const signature = await window.crypto.subtle.sign(
|
||||||
{ name: "ECDSA", hash: "SHA-384" },
|
{ name: "ECDSA", hash: "SHA-384" },
|
||||||
key.privateKey,
|
key.privateKey,
|
||||||
encoded,
|
encoded,
|
||||||
|
@ -210,7 +210,7 @@ Deno.test(async function testECDSASignVerify() {
|
||||||
assert(signature);
|
assert(signature);
|
||||||
assert(signature instanceof ArrayBuffer);
|
assert(signature instanceof ArrayBuffer);
|
||||||
|
|
||||||
const verified = await globalThis.crypto.subtle.verify(
|
const verified = await window.crypto.subtle.verify(
|
||||||
{ hash: { name: "SHA-384" }, name: "ECDSA" },
|
{ hash: { name: "SHA-384" }, name: "ECDSA" },
|
||||||
key.publicKey,
|
key.publicKey,
|
||||||
signature,
|
signature,
|
||||||
|
@ -221,7 +221,7 @@ Deno.test(async function testECDSASignVerify() {
|
||||||
|
|
||||||
// Tests the "bad paths" as a temporary replacement for sign_verify/ecdsa WPT.
|
// Tests the "bad paths" as a temporary replacement for sign_verify/ecdsa WPT.
|
||||||
Deno.test(async function testECDSASignVerifyFail() {
|
Deno.test(async function testECDSASignVerifyFail() {
|
||||||
const key = await globalThis.crypto.subtle.generateKey(
|
const key = await window.crypto.subtle.generateKey(
|
||||||
{
|
{
|
||||||
name: "ECDSA",
|
name: "ECDSA",
|
||||||
namedCurve: "P-384",
|
namedCurve: "P-384",
|
||||||
|
@ -233,7 +233,7 @@ Deno.test(async function testECDSASignVerifyFail() {
|
||||||
const encoded = new Uint8Array([1]);
|
const encoded = new Uint8Array([1]);
|
||||||
// Signing with a public key (InvalidAccessError)
|
// Signing with a public key (InvalidAccessError)
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await globalThis.crypto.subtle.sign(
|
await window.crypto.subtle.sign(
|
||||||
{ name: "ECDSA", hash: "SHA-384" },
|
{ name: "ECDSA", hash: "SHA-384" },
|
||||||
key.publicKey,
|
key.publicKey,
|
||||||
new Uint8Array([1]),
|
new Uint8Array([1]),
|
||||||
|
@ -242,7 +242,7 @@ Deno.test(async function testECDSASignVerifyFail() {
|
||||||
}, DOMException);
|
}, DOMException);
|
||||||
|
|
||||||
// Do a valid sign for later verifying.
|
// Do a valid sign for later verifying.
|
||||||
const signature = await globalThis.crypto.subtle.sign(
|
const signature = await window.crypto.subtle.sign(
|
||||||
{ name: "ECDSA", hash: "SHA-384" },
|
{ name: "ECDSA", hash: "SHA-384" },
|
||||||
key.privateKey,
|
key.privateKey,
|
||||||
encoded,
|
encoded,
|
||||||
|
@ -250,7 +250,7 @@ Deno.test(async function testECDSASignVerifyFail() {
|
||||||
|
|
||||||
// Verifying with a private key (InvalidAccessError)
|
// Verifying with a private key (InvalidAccessError)
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await globalThis.crypto.subtle.verify(
|
await window.crypto.subtle.verify(
|
||||||
{ hash: { name: "SHA-384" }, name: "ECDSA" },
|
{ hash: { name: "SHA-384" }, name: "ECDSA" },
|
||||||
key.privateKey,
|
key.privateKey,
|
||||||
signature,
|
signature,
|
||||||
|
@ -262,7 +262,7 @@ Deno.test(async function testECDSASignVerifyFail() {
|
||||||
|
|
||||||
// https://github.com/denoland/deno/issues/11313
|
// https://github.com/denoland/deno/issues/11313
|
||||||
Deno.test(async function testSignRSASSAKey() {
|
Deno.test(async function testSignRSASSAKey() {
|
||||||
const subtle = globalThis.crypto.subtle;
|
const subtle = window.crypto.subtle;
|
||||||
assert(subtle);
|
assert(subtle);
|
||||||
|
|
||||||
const keyPair = await subtle.generateKey(
|
const keyPair = await subtle.generateKey(
|
||||||
|
@ -284,7 +284,7 @@ Deno.test(async function testSignRSASSAKey() {
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const encoded = encoder.encode("Hello, World!");
|
const encoded = encoder.encode("Hello, World!");
|
||||||
|
|
||||||
const signature = await globalThis.crypto.subtle.sign(
|
const signature = await window.crypto.subtle.sign(
|
||||||
{ name: "RSASSA-PKCS1-v1_5" },
|
{ name: "RSASSA-PKCS1-v1_5" },
|
||||||
keyPair.privateKey,
|
keyPair.privateKey,
|
||||||
encoded,
|
encoded,
|
||||||
|
@ -1056,7 +1056,7 @@ const jwtRSAKeys = {
|
||||||
};
|
};
|
||||||
|
|
||||||
Deno.test(async function testImportRsaJwk() {
|
Deno.test(async function testImportRsaJwk() {
|
||||||
const subtle = globalThis.crypto.subtle;
|
const subtle = window.crypto.subtle;
|
||||||
assert(subtle);
|
assert(subtle);
|
||||||
|
|
||||||
for (const [_key, jwkData] of Object.entries(jwtRSAKeys)) {
|
for (const [_key, jwkData] of Object.entries(jwtRSAKeys)) {
|
||||||
|
@ -1496,7 +1496,7 @@ const ecTestKeys = [
|
||||||
];
|
];
|
||||||
|
|
||||||
Deno.test(async function testImportEcSpkiPkcs8() {
|
Deno.test(async function testImportEcSpkiPkcs8() {
|
||||||
const subtle = globalThis.crypto.subtle;
|
const subtle = window.crypto.subtle;
|
||||||
assert(subtle);
|
assert(subtle);
|
||||||
|
|
||||||
for (
|
for (
|
||||||
|
|
Loading…
Add table
Reference in a new issue