@kerebron/test-utils 0.4.27 → 0.4.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/_dnt.shims.d.ts +2 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +58 -0
- package/esm/_dnt.shims.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts +29 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.js +47 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts +24 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.js +47 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.d.ts +16 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.js +23 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts +26 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.js +31 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.d.ts +17 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.js +187 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.d.ts +35 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.js +60 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.d.ts +18 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.js +28 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.d.ts +15 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.js +21 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.d.ts +18 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.js +23 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.d.ts +20 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.js +30 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts +20 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js +30 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts +23 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js +53 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts +25 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.js +54 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.d.ts +19 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.js +29 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts +20 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js +30 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.d.ts +18 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.js +27 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.d.ts +44 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.js +46 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts +21 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.js +34 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts +20 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js +30 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts +18 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.js +27 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts +23 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js +33 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts +29 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.js +168 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts +42 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.js +54 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts +24 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.js +59 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts +18 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.js +27 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.d.ts +45 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.js +45 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts +15 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.js +21 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts +15 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.js +21 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts +80 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.js +117 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.d.ts +140 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.js +277 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts +99 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.js +183 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.d.ts +29 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.js +71 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.d.ts +159 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.js +208 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts +25 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.js +4 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.js.map +1 -0
- package/esm/package.json +3 -0
- package/esm/test-utils.d.ts +3 -0
- package/esm/test-utils.d.ts.map +1 -0
- package/esm/test-utils.js +12 -0
- package/esm/test-utils.js.map +1 -0
- package/package.json +5 -2
- package/src/_dnt.shims.ts +60 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/almost_equals.ts +55 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/array_includes.ts +57 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/assert.ts +23 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/assertion_error.ts +31 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/equal.ts +218 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/equals.ts +66 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/exists.ts +31 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/fail.ts +21 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/false.ts +26 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/greater.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.ts +36 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/instance_of.ts +64 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/is_error.ts +65 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/less.ts +29 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/less_or_equal.ts +36 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/match.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/mod.ts +47 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/not_equals.ts +37 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/not_instance_of.ts +33 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/not_match.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.ts +42 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/object_match.ts +214 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/rejects.ts +123 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/strict_equals.ts +68 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/string_includes.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/throws.ts +111 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/unimplemented.ts +21 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/unreachable.ts +21 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/build_message.ts +147 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/diff.ts +317 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/diff_str.ts +208 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/format.ts +89 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/styles.ts +233 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/types.ts +30 -0
- package/src/test-utils.ts +12 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executes a function which returns a promise, expecting it to reject.
|
|
3
|
+
*
|
|
4
|
+
* To assert that a synchronous function throws, use {@linkcode assertThrows}.
|
|
5
|
+
*
|
|
6
|
+
* @example Usage
|
|
7
|
+
* ```ts ignore
|
|
8
|
+
* import { assertRejects } from "@std/assert";
|
|
9
|
+
*
|
|
10
|
+
* await assertRejects(async () => Promise.reject(new Error())); // Doesn't throw
|
|
11
|
+
* await assertRejects(async () => console.log("Hello world")); // Throws
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param fn The function to execute.
|
|
15
|
+
* @param msg The optional message to display if the assertion fails.
|
|
16
|
+
* @returns The promise which resolves to the thrown error.
|
|
17
|
+
*/
|
|
18
|
+
export declare function assertRejects(fn: () => PromiseLike<unknown>, msg?: string): Promise<unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* Executes a function which returns a promise, expecting it to reject.
|
|
21
|
+
* If it does not, then it throws. An error class and a string that should be
|
|
22
|
+
* included in the error message can also be asserted.
|
|
23
|
+
*
|
|
24
|
+
* To assert that a synchronous function throws, use {@linkcode assertThrows}.
|
|
25
|
+
*
|
|
26
|
+
* @example Usage
|
|
27
|
+
* ```ts ignore
|
|
28
|
+
* import { assertRejects } from "@std/assert";
|
|
29
|
+
*
|
|
30
|
+
* await assertRejects(async () => Promise.reject(new Error()), Error); // Doesn't throw
|
|
31
|
+
* await assertRejects(async () => Promise.reject(new Error()), SyntaxError); // Throws
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @typeParam E The error class to assert.
|
|
35
|
+
* @param fn The function to execute.
|
|
36
|
+
* @param ErrorClass The error class to assert.
|
|
37
|
+
* @param msgIncludes The string that should be included in the error message.
|
|
38
|
+
* @param msg The optional message to display if the assertion fails.
|
|
39
|
+
* @returns The promise which resolves to the thrown error.
|
|
40
|
+
*/
|
|
41
|
+
export declare function assertRejects<E extends Error = Error>(fn: () => PromiseLike<unknown>, ErrorClass: abstract new (...args: any[]) => E, msgIncludes?: string, msg?: string): Promise<E>;
|
|
42
|
+
//# sourceMappingURL=rejects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rejects.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/rejects.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,MAAM,WAAW,CAAC,OAAO,CAAC,EAC9B,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAAC;AACpB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EACnD,EAAE,EAAE,MAAM,WAAW,CAAC,OAAO,CAAC,EAE9B,UAAU,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAC9C,WAAW,CAAC,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
import { AssertionError } from "./assertion_error.js";
|
|
4
|
+
import { assertIsError } from "./is_error.js";
|
|
5
|
+
export async function assertRejects(fn, errorClassOrMsg, msgIncludesOrMsg, msg) {
|
|
6
|
+
// deno-lint-ignore no-explicit-any
|
|
7
|
+
let ErrorClass;
|
|
8
|
+
let msgIncludes;
|
|
9
|
+
let err;
|
|
10
|
+
if (typeof errorClassOrMsg !== "string") {
|
|
11
|
+
if (errorClassOrMsg === undefined ||
|
|
12
|
+
errorClassOrMsg.prototype instanceof Error ||
|
|
13
|
+
errorClassOrMsg.prototype === Error.prototype) {
|
|
14
|
+
ErrorClass = errorClassOrMsg;
|
|
15
|
+
msgIncludes = msgIncludesOrMsg;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
msg = errorClassOrMsg;
|
|
20
|
+
}
|
|
21
|
+
let doesThrow = false;
|
|
22
|
+
let isPromiseReturned = false;
|
|
23
|
+
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
24
|
+
try {
|
|
25
|
+
const possiblePromise = fn();
|
|
26
|
+
if (possiblePromise &&
|
|
27
|
+
typeof possiblePromise === "object" &&
|
|
28
|
+
typeof possiblePromise.then === "function") {
|
|
29
|
+
isPromiseReturned = true;
|
|
30
|
+
await possiblePromise;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
throw new Error();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (!isPromiseReturned) {
|
|
38
|
+
throw new AssertionError(`Function throws when expected to reject${msgSuffix}`);
|
|
39
|
+
}
|
|
40
|
+
if (ErrorClass) {
|
|
41
|
+
if (!(error instanceof Error)) {
|
|
42
|
+
throw new AssertionError(`A non-Error object was rejected${msgSuffix}`);
|
|
43
|
+
}
|
|
44
|
+
assertIsError(error, ErrorClass, msgIncludes, msg);
|
|
45
|
+
}
|
|
46
|
+
err = error;
|
|
47
|
+
doesThrow = true;
|
|
48
|
+
}
|
|
49
|
+
if (!doesThrow) {
|
|
50
|
+
throw new AssertionError(`Expected function to reject${msgSuffix}`);
|
|
51
|
+
}
|
|
52
|
+
return err;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=rejects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rejects.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/rejects.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,qCAAqC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAoD9C,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,EAA8B,EAC9B,eAGU,EACV,gBAAyB,EACzB,GAAY;IAEZ,mCAAmC;IACnC,IAAI,UAA4D,CAAC;IACjE,IAAI,WAA+B,CAAC;IACpC,IAAI,GAAG,CAAC;IAER,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE,CAAC;QACxC,IACE,eAAe,KAAK,SAAS;YAC7B,eAAe,CAAC,SAAS,YAAY,KAAK;YAC1C,eAAe,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,EAC7C,CAAC;YACD,UAAU,GAAG,eAAe,CAAC;YAC7B,WAAW,GAAG,gBAAgB,CAAC;QACjC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,eAAe,CAAC;IACxB,CAAC;IACD,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAC9B,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACzC,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,EAAE,EAAE,CAAC;QAC7B,IACE,eAAe;YACf,OAAO,eAAe,KAAK,QAAQ;YACnC,OAAO,eAAe,CAAC,IAAI,KAAK,UAAU,EAC1C,CAAC;YACD,iBAAiB,GAAG,IAAI,CAAC;YACzB,MAAM,eAAe,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,MAAM,IAAI,cAAc,CACtB,0CAA0C,SAAS,EAAE,CACtD,CAAC;QACJ,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,cAAc,CAAC,kCAAkC,SAAS,EAAE,CAAC,CAAC;YAC1E,CAAC;YACD,aAAa,CACX,KAAK,EACL,UAAU,EACV,WAAW,EACX,GAAG,CACJ,CAAC;QACJ,CAAC;QACD,GAAG,GAAG,KAAK,CAAC;QACZ,SAAS,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,cAAc,CACtB,8BAA8B,SAAS,EAAE,CAC1C,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make an assertion that `actual` and `expected` are strictly equal, using
|
|
3
|
+
* {@linkcode Object.is} for equality comparison. If not, then throw.
|
|
4
|
+
*
|
|
5
|
+
* @example Usage
|
|
6
|
+
* ```ts ignore
|
|
7
|
+
* import { assertStrictEquals } from "@std/assert";
|
|
8
|
+
*
|
|
9
|
+
* const a = {};
|
|
10
|
+
* const b = a;
|
|
11
|
+
* assertStrictEquals(a, b); // Doesn't throw
|
|
12
|
+
*
|
|
13
|
+
* const c = {};
|
|
14
|
+
* const d = {};
|
|
15
|
+
* assertStrictEquals(c, d); // Throws
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @typeParam T The type of the expected value.
|
|
19
|
+
* @param actual The actual value to compare.
|
|
20
|
+
* @param expected The expected value to compare.
|
|
21
|
+
* @param msg The optional message to display if the assertion fails.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertStrictEquals<T>(actual: unknown, expected: T, msg?: string): asserts actual is T;
|
|
24
|
+
//# sourceMappingURL=strict_equals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/strict_equals.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,IAAI,CAAC,CAgCrB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
import { buildMessage } from "../../internal/1.0.12/build_message.js";
|
|
4
|
+
import { diff } from "../../internal/1.0.12/diff.js";
|
|
5
|
+
import { diffStr } from "../../internal/1.0.12/diff_str.js";
|
|
6
|
+
import { format } from "../../internal/1.0.12/format.js";
|
|
7
|
+
import { red } from "../../internal/1.0.12/styles.js";
|
|
8
|
+
import { AssertionError } from "./assertion_error.js";
|
|
9
|
+
/**
|
|
10
|
+
* Make an assertion that `actual` and `expected` are strictly equal, using
|
|
11
|
+
* {@linkcode Object.is} for equality comparison. If not, then throw.
|
|
12
|
+
*
|
|
13
|
+
* @example Usage
|
|
14
|
+
* ```ts ignore
|
|
15
|
+
* import { assertStrictEquals } from "@std/assert";
|
|
16
|
+
*
|
|
17
|
+
* const a = {};
|
|
18
|
+
* const b = a;
|
|
19
|
+
* assertStrictEquals(a, b); // Doesn't throw
|
|
20
|
+
*
|
|
21
|
+
* const c = {};
|
|
22
|
+
* const d = {};
|
|
23
|
+
* assertStrictEquals(c, d); // Throws
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @typeParam T The type of the expected value.
|
|
27
|
+
* @param actual The actual value to compare.
|
|
28
|
+
* @param expected The expected value to compare.
|
|
29
|
+
* @param msg The optional message to display if the assertion fails.
|
|
30
|
+
*/
|
|
31
|
+
export function assertStrictEquals(actual, expected, msg) {
|
|
32
|
+
if (Object.is(actual, expected)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
36
|
+
let message;
|
|
37
|
+
const actualString = format(actual);
|
|
38
|
+
const expectedString = format(expected);
|
|
39
|
+
if (actualString === expectedString) {
|
|
40
|
+
const withOffset = actualString
|
|
41
|
+
.split("\n")
|
|
42
|
+
.map((l) => ` ${l}`)
|
|
43
|
+
.join("\n");
|
|
44
|
+
message =
|
|
45
|
+
`Values have the same structure but are not reference-equal${msgSuffix}\n\n${red(withOffset)}\n`;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const stringDiff = (typeof actual === "string") &&
|
|
49
|
+
(typeof expected === "string");
|
|
50
|
+
const diffResult = stringDiff
|
|
51
|
+
? diffStr(actual, expected)
|
|
52
|
+
: diff(actualString.split("\n"), expectedString.split("\n"));
|
|
53
|
+
const diffMsg = buildMessage(diffResult, { stringDiff }, arguments[3])
|
|
54
|
+
.join("\n");
|
|
55
|
+
message = `Values are not strictly equal${msgSuffix}\n${diffMsg}`;
|
|
56
|
+
}
|
|
57
|
+
throw new AssertionError(message);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=strict_equals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict_equals.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/strict_equals.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,qCAAqC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAe,EACf,QAAW,EACX,GAAY;IAEZ,IAAI,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;QAChC,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACzC,IAAI,OAAe,CAAC;IAEpB,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAExC,IAAI,YAAY,KAAK,cAAc,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,YAAY;aAC5B,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;aACtB,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,OAAO;YACL,6DAA6D,SAAS,OACpE,GAAG,CAAC,UAAU,CAChB,IAAI,CAAC;IACT,CAAC;SAAM,CAAC;QACN,MAAM,UAAU,GAAG,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC;YAC7C,CAAC,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC;QACjC,MAAM,UAAU,GAAG,UAAU;YAC3B,CAAC,CAAC,OAAO,CAAC,MAAgB,EAAE,QAAkB,CAAC;YAC/C,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/D,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;aACnE,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,OAAO,GAAG,gCAAgC,SAAS,KAAK,OAAO,EAAE,CAAC;IACpE,CAAC;IAED,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make an assertion that actual includes expected. If not
|
|
3
|
+
* then throw.
|
|
4
|
+
*
|
|
5
|
+
* @example Usage
|
|
6
|
+
* ```ts ignore
|
|
7
|
+
* import { assertStringIncludes } from "@std/assert";
|
|
8
|
+
*
|
|
9
|
+
* assertStringIncludes("Hello", "ello"); // Doesn't throw
|
|
10
|
+
* assertStringIncludes("Hello", "world"); // Throws
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param actual The actual string to check for inclusion.
|
|
14
|
+
* @param expected The expected string to check for inclusion.
|
|
15
|
+
* @param msg The optional message to display if the assertion fails.
|
|
16
|
+
*/
|
|
17
|
+
export declare function assertStringIncludes(actual: string, expected: string, msg?: string): void;
|
|
18
|
+
//# sourceMappingURL=string_includes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string_includes.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/string_includes.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,QAMb"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
import { AssertionError } from "./assertion_error.js";
|
|
4
|
+
/**
|
|
5
|
+
* Make an assertion that actual includes expected. If not
|
|
6
|
+
* then throw.
|
|
7
|
+
*
|
|
8
|
+
* @example Usage
|
|
9
|
+
* ```ts ignore
|
|
10
|
+
* import { assertStringIncludes } from "@std/assert";
|
|
11
|
+
*
|
|
12
|
+
* assertStringIncludes("Hello", "ello"); // Doesn't throw
|
|
13
|
+
* assertStringIncludes("Hello", "world"); // Throws
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param actual The actual string to check for inclusion.
|
|
17
|
+
* @param expected The expected string to check for inclusion.
|
|
18
|
+
* @param msg The optional message to display if the assertion fails.
|
|
19
|
+
*/
|
|
20
|
+
export function assertStringIncludes(actual, expected, msg) {
|
|
21
|
+
if (actual.includes(expected))
|
|
22
|
+
return;
|
|
23
|
+
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
24
|
+
msg = `Expected actual: "${actual}" to contain: "${expected}"${msgSuffix}`;
|
|
25
|
+
throw new AssertionError(msg);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=string_includes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string_includes.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/string_includes.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,qCAAqC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAc,EACd,QAAgB,EAChB,GAAY;IAEZ,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO;IACtC,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACzC,GAAG,GAAG,qBAAqB,MAAM,kBAAkB,QAAQ,IAAI,SAAS,EAAE,CAAC;IAC3E,MAAM,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executes a function, expecting it to throw. If it does not, then it
|
|
3
|
+
* throws.
|
|
4
|
+
*
|
|
5
|
+
* To assert that an asynchronous function rejects, use
|
|
6
|
+
* {@linkcode assertRejects}.
|
|
7
|
+
*
|
|
8
|
+
* @example Usage
|
|
9
|
+
* ```ts ignore
|
|
10
|
+
* import { assertThrows } from "@std/assert";
|
|
11
|
+
*
|
|
12
|
+
* assertThrows(() => { throw new TypeError("hello world!"); }); // Doesn't throw
|
|
13
|
+
* assertThrows(() => console.log("hello world!")); // Throws
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param fn The function to execute.
|
|
17
|
+
* @param msg The optional message to display if the assertion fails.
|
|
18
|
+
* @returns The error that was thrown.
|
|
19
|
+
*/
|
|
20
|
+
export declare function assertThrows(fn: () => unknown, msg?: string): unknown;
|
|
21
|
+
/**
|
|
22
|
+
* Executes a function, expecting it to throw. If it does not, then it
|
|
23
|
+
* throws. An error class and a string that should be included in the
|
|
24
|
+
* error message can also be asserted.
|
|
25
|
+
*
|
|
26
|
+
* To assert that an asynchronous function rejects, use
|
|
27
|
+
* {@linkcode assertRejects}.
|
|
28
|
+
*
|
|
29
|
+
* @example Usage
|
|
30
|
+
* ```ts ignore
|
|
31
|
+
* import { assertThrows } from "@std/assert";
|
|
32
|
+
*
|
|
33
|
+
* assertThrows(() => { throw new TypeError("hello world!"); }, TypeError); // Doesn't throw
|
|
34
|
+
* assertThrows(() => { throw new TypeError("hello world!"); }, RangeError); // Throws
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @typeParam E The error class to assert.
|
|
38
|
+
* @param fn The function to execute.
|
|
39
|
+
* @param ErrorClass The error class to assert.
|
|
40
|
+
* @param msgIncludes The string that should be included in the error message.
|
|
41
|
+
* @param msg The optional message to display if the assertion fails.
|
|
42
|
+
* @returns The error that was thrown.
|
|
43
|
+
*/
|
|
44
|
+
export declare function assertThrows<E extends Error = Error>(fn: () => unknown, ErrorClass: abstract new (...args: any[]) => E, msgIncludes?: string, msg?: string): E;
|
|
45
|
+
//# sourceMappingURL=throws.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throws.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/throws.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,OAAO,EACjB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC;AACX;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAClD,EAAE,EAAE,MAAM,OAAO,EAEjB,UAAU,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAC9C,WAAW,CAAC,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,MAAM,GACX,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
import { assertIsError } from "./is_error.js";
|
|
4
|
+
import { AssertionError } from "./assertion_error.js";
|
|
5
|
+
export function assertThrows(fn, errorClassOrMsg, msgIncludesOrMsg, msg) {
|
|
6
|
+
// deno-lint-ignore no-explicit-any
|
|
7
|
+
let ErrorClass;
|
|
8
|
+
let msgIncludes;
|
|
9
|
+
let err;
|
|
10
|
+
if (typeof errorClassOrMsg !== "string") {
|
|
11
|
+
if (errorClassOrMsg === undefined ||
|
|
12
|
+
errorClassOrMsg?.prototype instanceof Error ||
|
|
13
|
+
errorClassOrMsg?.prototype === Error.prototype) {
|
|
14
|
+
ErrorClass = errorClassOrMsg;
|
|
15
|
+
msgIncludes = msgIncludesOrMsg;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
msg = msgIncludesOrMsg;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
msg = errorClassOrMsg;
|
|
23
|
+
}
|
|
24
|
+
let doesThrow = false;
|
|
25
|
+
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
26
|
+
try {
|
|
27
|
+
fn();
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (ErrorClass) {
|
|
31
|
+
if (error instanceof Error === false) {
|
|
32
|
+
throw new AssertionError(`A non-Error object was thrown${msgSuffix}`);
|
|
33
|
+
}
|
|
34
|
+
assertIsError(error, ErrorClass, msgIncludes, msg);
|
|
35
|
+
}
|
|
36
|
+
err = error;
|
|
37
|
+
doesThrow = true;
|
|
38
|
+
}
|
|
39
|
+
if (!doesThrow) {
|
|
40
|
+
msg = `Expected function to throw${msgSuffix}`;
|
|
41
|
+
throw new AssertionError(msg);
|
|
42
|
+
}
|
|
43
|
+
return err;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=throws.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throws.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/throws.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,qCAAqC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAuDtD,MAAM,UAAU,YAAY,CAC1B,EAAiB,EACjB,eAGU,EACV,gBAAyB,EACzB,GAAY;IAEZ,mCAAmC;IACnC,IAAI,UAA4D,CAAC;IACjE,IAAI,WAA+B,CAAC;IACpC,IAAI,GAAG,CAAC;IAER,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE,CAAC;QACxC,IACE,eAAe,KAAK,SAAS;YAC7B,eAAe,EAAE,SAAS,YAAY,KAAK;YAC3C,eAAe,EAAE,SAAS,KAAK,KAAK,CAAC,SAAS,EAC9C,CAAC;YACD,UAAU,GAAG,eAAe,CAAC;YAC7B,WAAW,GAAG,gBAAgB,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,GAAG,GAAG,gBAAgB,CAAC;QACzB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,eAAe,CAAC;IACxB,CAAC;IACD,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACzC,IAAI,CAAC;QACH,EAAE,EAAE,CAAC;IACP,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,KAAK,KAAK,KAAK,EAAE,CAAC;gBACrC,MAAM,IAAI,cAAc,CAAC,gCAAgC,SAAS,EAAE,CAAC,CAAC;YACxE,CAAC;YACD,aAAa,CACX,KAAK,EACL,UAAU,EACV,WAAW,EACX,GAAG,CACJ,CAAC;QACJ,CAAC;QACD,GAAG,GAAG,KAAK,CAAC;QACZ,SAAS,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,GAAG,GAAG,6BAA6B,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use this to stub out methods that will throw when invoked.
|
|
3
|
+
*
|
|
4
|
+
* @example Usage
|
|
5
|
+
* ```ts ignore
|
|
6
|
+
* import { unimplemented } from "@std/assert";
|
|
7
|
+
*
|
|
8
|
+
* unimplemented(); // Throws
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param msg Optional message to include in the error.
|
|
12
|
+
* @returns Never returns, always throws.
|
|
13
|
+
*/
|
|
14
|
+
export declare function unimplemented(msg?: string): never;
|
|
15
|
+
//# sourceMappingURL=unimplemented.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unimplemented.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/unimplemented.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAGjD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
import { AssertionError } from "./assertion_error.js";
|
|
4
|
+
/**
|
|
5
|
+
* Use this to stub out methods that will throw when invoked.
|
|
6
|
+
*
|
|
7
|
+
* @example Usage
|
|
8
|
+
* ```ts ignore
|
|
9
|
+
* import { unimplemented } from "@std/assert";
|
|
10
|
+
*
|
|
11
|
+
* unimplemented(); // Throws
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param msg Optional message to include in the error.
|
|
15
|
+
* @returns Never returns, always throws.
|
|
16
|
+
*/
|
|
17
|
+
export function unimplemented(msg) {
|
|
18
|
+
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
19
|
+
throw new AssertionError(`Unimplemented${msgSuffix}`);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=unimplemented.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unimplemented.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/unimplemented.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,qCAAqC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACzC,MAAM,IAAI,cAAc,CAAC,gBAAgB,SAAS,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use this to assert unreachable code.
|
|
3
|
+
*
|
|
4
|
+
* @example Usage
|
|
5
|
+
* ```ts ignore
|
|
6
|
+
* import { unreachable } from "@std/assert";
|
|
7
|
+
*
|
|
8
|
+
* unreachable(); // Throws
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param msg Optional message to include in the error.
|
|
12
|
+
* @returns Never returns, always throws.
|
|
13
|
+
*/
|
|
14
|
+
export declare function unreachable(msg?: string): never;
|
|
15
|
+
//# sourceMappingURL=unreachable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unreachable.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/unreachable.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAG/C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
import { AssertionError } from "./assertion_error.js";
|
|
4
|
+
/**
|
|
5
|
+
* Use this to assert unreachable code.
|
|
6
|
+
*
|
|
7
|
+
* @example Usage
|
|
8
|
+
* ```ts ignore
|
|
9
|
+
* import { unreachable } from "@std/assert";
|
|
10
|
+
*
|
|
11
|
+
* unreachable(); // Throws
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param msg Optional message to include in the error.
|
|
15
|
+
* @returns Never returns, always throws.
|
|
16
|
+
*/
|
|
17
|
+
export function unreachable(msg) {
|
|
18
|
+
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
19
|
+
throw new AssertionError(`Unreachable${msgSuffix}`);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=unreachable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unreachable.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/unreachable.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,qCAAqC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACzC,MAAM,IAAI,cAAc,CAAC,cAAc,SAAS,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { DiffResult, DiffType } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Colors the output of assertion diffs.
|
|
4
|
+
*
|
|
5
|
+
* @param diffType Difference type, either added or removed.
|
|
6
|
+
* @param background If true, colors the background instead of the text.
|
|
7
|
+
*
|
|
8
|
+
* @returns A function that colors the input string.
|
|
9
|
+
*
|
|
10
|
+
* @example Usage
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { createColor } from "@std/internal";
|
|
13
|
+
* import { assertEquals } from "@std/assert";
|
|
14
|
+
* import { bold, green, red, white } from "@std/fmt/colors";
|
|
15
|
+
*
|
|
16
|
+
* assertEquals(createColor("added")("foo"), green(bold("foo")));
|
|
17
|
+
* assertEquals(createColor("removed")("foo"), red(bold("foo")));
|
|
18
|
+
* assertEquals(createColor("common")("foo"), white("foo"));
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function createColor(diffType: DiffType,
|
|
22
|
+
/**
|
|
23
|
+
* TODO(@littledivy): Remove this when we can detect true color terminals. See
|
|
24
|
+
* https://github.com/denoland/std/issues/2575.
|
|
25
|
+
*/
|
|
26
|
+
background?: boolean): (s: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Prefixes `+` or `-` in diff output.
|
|
29
|
+
*
|
|
30
|
+
* @param diffType Difference type, either added or removed
|
|
31
|
+
*
|
|
32
|
+
* @returns A string representing the sign.
|
|
33
|
+
*
|
|
34
|
+
* @example Usage
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { createSign } from "@std/internal";
|
|
37
|
+
* import { assertEquals } from "@std/assert";
|
|
38
|
+
*
|
|
39
|
+
* assertEquals(createSign("added"), "+ ");
|
|
40
|
+
* assertEquals(createSign("removed"), "- ");
|
|
41
|
+
* assertEquals(createSign("common"), " ");
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function createSign(diffType: DiffType): string;
|
|
45
|
+
/** Options for {@linkcode buildMessage}. */
|
|
46
|
+
export interface BuildMessageOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Whether to output the diff as a single string.
|
|
49
|
+
* @default {false}
|
|
50
|
+
*/
|
|
51
|
+
stringDiff?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Builds a message based on the provided diff result.
|
|
55
|
+
*
|
|
56
|
+
* @param diffResult The diff result array.
|
|
57
|
+
* @param options Optional parameters for customizing the message.
|
|
58
|
+
* @param truncateDiff Function to truncate the diff (default is no truncation).
|
|
59
|
+
*
|
|
60
|
+
* @returns An array of strings representing the built message.
|
|
61
|
+
*
|
|
62
|
+
* @example Usage
|
|
63
|
+
* ```ts no-assert
|
|
64
|
+
* import { diffStr, buildMessage } from "@std/internal";
|
|
65
|
+
*
|
|
66
|
+
* diffStr("Hello, world!", "Hello, world");
|
|
67
|
+
* // [
|
|
68
|
+
* // "",
|
|
69
|
+
* // "",
|
|
70
|
+
* // " [Diff] Actual / Expected",
|
|
71
|
+
* // "",
|
|
72
|
+
* // "",
|
|
73
|
+
* // "- Hello, world!",
|
|
74
|
+
* // "+ Hello, world",
|
|
75
|
+
* // "",
|
|
76
|
+
* // ]
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function buildMessage(diffResult: ReadonlyArray<DiffResult<string>>, options?: BuildMessageOptions, truncateDiff?: (diffResult: ReadonlyArray<DiffResult<string>>, stringDiff: boolean, contextLength?: number | null) => ReadonlyArray<DiffResult<string>>): string[];
|
|
80
|
+
//# sourceMappingURL=build_message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_message.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.12/build_message.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,QAAQ;AAClB;;;GAGG;AACH,UAAU,UAAQ,GACjB,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAWvB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CASrD;AAED,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC7C,OAAO,GAAE,mBAAwB,EACjC,YAAY,CAAC,EAAE,CACb,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC7C,UAAU,EAAE,OAAO,EACnB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,KAC1B,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GACrC,MAAM,EAAE,CA8BV"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
import { bgGreen, bgRed, bold, gray, green, red, white } from "./styles.js";
|
|
4
|
+
/**
|
|
5
|
+
* Colors the output of assertion diffs.
|
|
6
|
+
*
|
|
7
|
+
* @param diffType Difference type, either added or removed.
|
|
8
|
+
* @param background If true, colors the background instead of the text.
|
|
9
|
+
*
|
|
10
|
+
* @returns A function that colors the input string.
|
|
11
|
+
*
|
|
12
|
+
* @example Usage
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { createColor } from "@std/internal";
|
|
15
|
+
* import { assertEquals } from "@std/assert";
|
|
16
|
+
* import { bold, green, red, white } from "@std/fmt/colors";
|
|
17
|
+
*
|
|
18
|
+
* assertEquals(createColor("added")("foo"), green(bold("foo")));
|
|
19
|
+
* assertEquals(createColor("removed")("foo"), red(bold("foo")));
|
|
20
|
+
* assertEquals(createColor("common")("foo"), white("foo"));
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function createColor(diffType,
|
|
24
|
+
/**
|
|
25
|
+
* TODO(@littledivy): Remove this when we can detect true color terminals. See
|
|
26
|
+
* https://github.com/denoland/std/issues/2575.
|
|
27
|
+
*/
|
|
28
|
+
background = false) {
|
|
29
|
+
switch (diffType) {
|
|
30
|
+
case "added":
|
|
31
|
+
return (s) => background ? bgGreen(white(s)) : green(bold(s));
|
|
32
|
+
case "removed":
|
|
33
|
+
return (s) => background ? bgRed(white(s)) : red(bold(s));
|
|
34
|
+
case "truncation":
|
|
35
|
+
return gray;
|
|
36
|
+
default:
|
|
37
|
+
return white;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Prefixes `+` or `-` in diff output.
|
|
42
|
+
*
|
|
43
|
+
* @param diffType Difference type, either added or removed
|
|
44
|
+
*
|
|
45
|
+
* @returns A string representing the sign.
|
|
46
|
+
*
|
|
47
|
+
* @example Usage
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { createSign } from "@std/internal";
|
|
50
|
+
* import { assertEquals } from "@std/assert";
|
|
51
|
+
*
|
|
52
|
+
* assertEquals(createSign("added"), "+ ");
|
|
53
|
+
* assertEquals(createSign("removed"), "- ");
|
|
54
|
+
* assertEquals(createSign("common"), " ");
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function createSign(diffType) {
|
|
58
|
+
switch (diffType) {
|
|
59
|
+
case "added":
|
|
60
|
+
return "+ ";
|
|
61
|
+
case "removed":
|
|
62
|
+
return "- ";
|
|
63
|
+
default:
|
|
64
|
+
return " ";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Builds a message based on the provided diff result.
|
|
69
|
+
*
|
|
70
|
+
* @param diffResult The diff result array.
|
|
71
|
+
* @param options Optional parameters for customizing the message.
|
|
72
|
+
* @param truncateDiff Function to truncate the diff (default is no truncation).
|
|
73
|
+
*
|
|
74
|
+
* @returns An array of strings representing the built message.
|
|
75
|
+
*
|
|
76
|
+
* @example Usage
|
|
77
|
+
* ```ts no-assert
|
|
78
|
+
* import { diffStr, buildMessage } from "@std/internal";
|
|
79
|
+
*
|
|
80
|
+
* diffStr("Hello, world!", "Hello, world");
|
|
81
|
+
* // [
|
|
82
|
+
* // "",
|
|
83
|
+
* // "",
|
|
84
|
+
* // " [Diff] Actual / Expected",
|
|
85
|
+
* // "",
|
|
86
|
+
* // "",
|
|
87
|
+
* // "- Hello, world!",
|
|
88
|
+
* // "+ Hello, world",
|
|
89
|
+
* // "",
|
|
90
|
+
* // ]
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export function buildMessage(diffResult, options = {}, truncateDiff) {
|
|
94
|
+
if (truncateDiff != null) {
|
|
95
|
+
diffResult = truncateDiff(diffResult, options.stringDiff ?? false);
|
|
96
|
+
}
|
|
97
|
+
const { stringDiff = false } = options;
|
|
98
|
+
const messages = [
|
|
99
|
+
"",
|
|
100
|
+
"",
|
|
101
|
+
` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${green(bold("Expected"))}`,
|
|
102
|
+
"",
|
|
103
|
+
"",
|
|
104
|
+
];
|
|
105
|
+
const diffMessages = diffResult.map((result) => {
|
|
106
|
+
const color = createColor(result.type);
|
|
107
|
+
const line = result.type === "added" || result.type === "removed"
|
|
108
|
+
? result.details?.map((detail) => detail.type !== "common"
|
|
109
|
+
? createColor(detail.type, true)(detail.value)
|
|
110
|
+
: detail.value).join("") ?? result.value
|
|
111
|
+
: result.value;
|
|
112
|
+
return color(`${createSign(result.type)}${line}`);
|
|
113
|
+
});
|
|
114
|
+
messages.push(...(stringDiff ? [diffMessages.join("")] : diffMessages), "");
|
|
115
|
+
return messages;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=build_message.js.map
|