@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.
Files changed (182) hide show
  1. package/esm/_dnt.shims.d.ts +2 -0
  2. package/esm/_dnt.shims.d.ts.map +1 -0
  3. package/esm/_dnt.shims.js +58 -0
  4. package/esm/_dnt.shims.js.map +1 -0
  5. package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts +29 -0
  6. package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts.map +1 -0
  7. package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.js +47 -0
  8. package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.js.map +1 -0
  9. package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts +24 -0
  10. package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.js +47 -0
  12. package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.js.map +1 -0
  13. package/esm/deps/jsr.io/@std/assert/1.0.16/assert.d.ts +16 -0
  14. package/esm/deps/jsr.io/@std/assert/1.0.16/assert.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@std/assert/1.0.16/assert.js +23 -0
  16. package/esm/deps/jsr.io/@std/assert/1.0.16/assert.js.map +1 -0
  17. package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts +26 -0
  18. package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.js +31 -0
  20. package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.js.map +1 -0
  21. package/esm/deps/jsr.io/@std/assert/1.0.16/equal.d.ts +17 -0
  22. package/esm/deps/jsr.io/@std/assert/1.0.16/equal.d.ts.map +1 -0
  23. package/esm/deps/jsr.io/@std/assert/1.0.16/equal.js +187 -0
  24. package/esm/deps/jsr.io/@std/assert/1.0.16/equal.js.map +1 -0
  25. package/esm/deps/jsr.io/@std/assert/1.0.16/equals.d.ts +35 -0
  26. package/esm/deps/jsr.io/@std/assert/1.0.16/equals.d.ts.map +1 -0
  27. package/esm/deps/jsr.io/@std/assert/1.0.16/equals.js +60 -0
  28. package/esm/deps/jsr.io/@std/assert/1.0.16/equals.js.map +1 -0
  29. package/esm/deps/jsr.io/@std/assert/1.0.16/exists.d.ts +18 -0
  30. package/esm/deps/jsr.io/@std/assert/1.0.16/exists.d.ts.map +1 -0
  31. package/esm/deps/jsr.io/@std/assert/1.0.16/exists.js +28 -0
  32. package/esm/deps/jsr.io/@std/assert/1.0.16/exists.js.map +1 -0
  33. package/esm/deps/jsr.io/@std/assert/1.0.16/fail.d.ts +15 -0
  34. package/esm/deps/jsr.io/@std/assert/1.0.16/fail.d.ts.map +1 -0
  35. package/esm/deps/jsr.io/@std/assert/1.0.16/fail.js +21 -0
  36. package/esm/deps/jsr.io/@std/assert/1.0.16/fail.js.map +1 -0
  37. package/esm/deps/jsr.io/@std/assert/1.0.16/false.d.ts +18 -0
  38. package/esm/deps/jsr.io/@std/assert/1.0.16/false.d.ts.map +1 -0
  39. package/esm/deps/jsr.io/@std/assert/1.0.16/false.js +23 -0
  40. package/esm/deps/jsr.io/@std/assert/1.0.16/false.js.map +1 -0
  41. package/esm/deps/jsr.io/@std/assert/1.0.16/greater.d.ts +20 -0
  42. package/esm/deps/jsr.io/@std/assert/1.0.16/greater.d.ts.map +1 -0
  43. package/esm/deps/jsr.io/@std/assert/1.0.16/greater.js +30 -0
  44. package/esm/deps/jsr.io/@std/assert/1.0.16/greater.js.map +1 -0
  45. package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts +20 -0
  46. package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts.map +1 -0
  47. package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js +30 -0
  48. package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js.map +1 -0
  49. package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts +23 -0
  50. package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts.map +1 -0
  51. package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js +53 -0
  52. package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js.map +1 -0
  53. package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts +25 -0
  54. package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts.map +1 -0
  55. package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.js +54 -0
  56. package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.js.map +1 -0
  57. package/esm/deps/jsr.io/@std/assert/1.0.16/less.d.ts +19 -0
  58. package/esm/deps/jsr.io/@std/assert/1.0.16/less.d.ts.map +1 -0
  59. package/esm/deps/jsr.io/@std/assert/1.0.16/less.js +29 -0
  60. package/esm/deps/jsr.io/@std/assert/1.0.16/less.js.map +1 -0
  61. package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts +20 -0
  62. package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts.map +1 -0
  63. package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js +30 -0
  64. package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js.map +1 -0
  65. package/esm/deps/jsr.io/@std/assert/1.0.16/match.d.ts +18 -0
  66. package/esm/deps/jsr.io/@std/assert/1.0.16/match.d.ts.map +1 -0
  67. package/esm/deps/jsr.io/@std/assert/1.0.16/match.js +27 -0
  68. package/esm/deps/jsr.io/@std/assert/1.0.16/match.js.map +1 -0
  69. package/esm/deps/jsr.io/@std/assert/1.0.16/mod.d.ts +44 -0
  70. package/esm/deps/jsr.io/@std/assert/1.0.16/mod.d.ts.map +1 -0
  71. package/esm/deps/jsr.io/@std/assert/1.0.16/mod.js +46 -0
  72. package/esm/deps/jsr.io/@std/assert/1.0.16/mod.js.map +1 -0
  73. package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts +21 -0
  74. package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts.map +1 -0
  75. package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.js +34 -0
  76. package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.js.map +1 -0
  77. package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts +20 -0
  78. package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts.map +1 -0
  79. package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js +30 -0
  80. package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js.map +1 -0
  81. package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts +18 -0
  82. package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts.map +1 -0
  83. package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.js +27 -0
  84. package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.js.map +1 -0
  85. package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts +23 -0
  86. package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts.map +1 -0
  87. package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js +33 -0
  88. package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js.map +1 -0
  89. package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts +29 -0
  90. package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts.map +1 -0
  91. package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.js +168 -0
  92. package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.js.map +1 -0
  93. package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts +42 -0
  94. package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts.map +1 -0
  95. package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.js +54 -0
  96. package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.js.map +1 -0
  97. package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts +24 -0
  98. package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts.map +1 -0
  99. package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.js +59 -0
  100. package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.js.map +1 -0
  101. package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts +18 -0
  102. package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts.map +1 -0
  103. package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.js +27 -0
  104. package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.js.map +1 -0
  105. package/esm/deps/jsr.io/@std/assert/1.0.16/throws.d.ts +45 -0
  106. package/esm/deps/jsr.io/@std/assert/1.0.16/throws.d.ts.map +1 -0
  107. package/esm/deps/jsr.io/@std/assert/1.0.16/throws.js +45 -0
  108. package/esm/deps/jsr.io/@std/assert/1.0.16/throws.js.map +1 -0
  109. package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts +15 -0
  110. package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts.map +1 -0
  111. package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.js +21 -0
  112. package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.js.map +1 -0
  113. package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts +15 -0
  114. package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts.map +1 -0
  115. package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.js +21 -0
  116. package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.js.map +1 -0
  117. package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts +80 -0
  118. package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts.map +1 -0
  119. package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.js +117 -0
  120. package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.js.map +1 -0
  121. package/esm/deps/jsr.io/@std/internal/1.0.12/diff.d.ts +140 -0
  122. package/esm/deps/jsr.io/@std/internal/1.0.12/diff.d.ts.map +1 -0
  123. package/esm/deps/jsr.io/@std/internal/1.0.12/diff.js +277 -0
  124. package/esm/deps/jsr.io/@std/internal/1.0.12/diff.js.map +1 -0
  125. package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts +99 -0
  126. package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts.map +1 -0
  127. package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.js +183 -0
  128. package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.js.map +1 -0
  129. package/esm/deps/jsr.io/@std/internal/1.0.12/format.d.ts +29 -0
  130. package/esm/deps/jsr.io/@std/internal/1.0.12/format.d.ts.map +1 -0
  131. package/esm/deps/jsr.io/@std/internal/1.0.12/format.js +71 -0
  132. package/esm/deps/jsr.io/@std/internal/1.0.12/format.js.map +1 -0
  133. package/esm/deps/jsr.io/@std/internal/1.0.12/styles.d.ts +159 -0
  134. package/esm/deps/jsr.io/@std/internal/1.0.12/styles.d.ts.map +1 -0
  135. package/esm/deps/jsr.io/@std/internal/1.0.12/styles.js +208 -0
  136. package/esm/deps/jsr.io/@std/internal/1.0.12/styles.js.map +1 -0
  137. package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts +25 -0
  138. package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts.map +1 -0
  139. package/esm/deps/jsr.io/@std/internal/1.0.12/types.js +4 -0
  140. package/esm/deps/jsr.io/@std/internal/1.0.12/types.js.map +1 -0
  141. package/esm/package.json +3 -0
  142. package/esm/test-utils.d.ts +3 -0
  143. package/esm/test-utils.d.ts.map +1 -0
  144. package/esm/test-utils.js +12 -0
  145. package/esm/test-utils.js.map +1 -0
  146. package/package.json +5 -2
  147. package/src/_dnt.shims.ts +60 -0
  148. package/src/deps/jsr.io/@std/assert/1.0.16/almost_equals.ts +55 -0
  149. package/src/deps/jsr.io/@std/assert/1.0.16/array_includes.ts +57 -0
  150. package/src/deps/jsr.io/@std/assert/1.0.16/assert.ts +23 -0
  151. package/src/deps/jsr.io/@std/assert/1.0.16/assertion_error.ts +31 -0
  152. package/src/deps/jsr.io/@std/assert/1.0.16/equal.ts +218 -0
  153. package/src/deps/jsr.io/@std/assert/1.0.16/equals.ts +66 -0
  154. package/src/deps/jsr.io/@std/assert/1.0.16/exists.ts +31 -0
  155. package/src/deps/jsr.io/@std/assert/1.0.16/fail.ts +21 -0
  156. package/src/deps/jsr.io/@std/assert/1.0.16/false.ts +26 -0
  157. package/src/deps/jsr.io/@std/assert/1.0.16/greater.ts +30 -0
  158. package/src/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.ts +36 -0
  159. package/src/deps/jsr.io/@std/assert/1.0.16/instance_of.ts +64 -0
  160. package/src/deps/jsr.io/@std/assert/1.0.16/is_error.ts +65 -0
  161. package/src/deps/jsr.io/@std/assert/1.0.16/less.ts +29 -0
  162. package/src/deps/jsr.io/@std/assert/1.0.16/less_or_equal.ts +36 -0
  163. package/src/deps/jsr.io/@std/assert/1.0.16/match.ts +30 -0
  164. package/src/deps/jsr.io/@std/assert/1.0.16/mod.ts +47 -0
  165. package/src/deps/jsr.io/@std/assert/1.0.16/not_equals.ts +37 -0
  166. package/src/deps/jsr.io/@std/assert/1.0.16/not_instance_of.ts +33 -0
  167. package/src/deps/jsr.io/@std/assert/1.0.16/not_match.ts +30 -0
  168. package/src/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.ts +42 -0
  169. package/src/deps/jsr.io/@std/assert/1.0.16/object_match.ts +214 -0
  170. package/src/deps/jsr.io/@std/assert/1.0.16/rejects.ts +123 -0
  171. package/src/deps/jsr.io/@std/assert/1.0.16/strict_equals.ts +68 -0
  172. package/src/deps/jsr.io/@std/assert/1.0.16/string_includes.ts +30 -0
  173. package/src/deps/jsr.io/@std/assert/1.0.16/throws.ts +111 -0
  174. package/src/deps/jsr.io/@std/assert/1.0.16/unimplemented.ts +21 -0
  175. package/src/deps/jsr.io/@std/assert/1.0.16/unreachable.ts +21 -0
  176. package/src/deps/jsr.io/@std/internal/1.0.12/build_message.ts +147 -0
  177. package/src/deps/jsr.io/@std/internal/1.0.12/diff.ts +317 -0
  178. package/src/deps/jsr.io/@std/internal/1.0.12/diff_str.ts +208 -0
  179. package/src/deps/jsr.io/@std/internal/1.0.12/format.ts +89 -0
  180. package/src/deps/jsr.io/@std/internal/1.0.12/styles.ts +233 -0
  181. package/src/deps/jsr.io/@std/internal/1.0.12/types.ts +30 -0
  182. package/src/test-utils.ts +12 -0
@@ -0,0 +1,25 @@
1
+ /** Ways that lines in a diff can be different. */
2
+ export type DiffType = DiffResult<unknown>["type"];
3
+ /**
4
+ * Represents the result of a diff operation.
5
+ * @typeParam T The type of the value in the diff result.
6
+ */
7
+ export type DiffResult<T> = ChangedDiffResult<T> | CommonDiffResult<T>;
8
+ /**
9
+ * Represents the result of a common diff operation.
10
+ * @typeParam T The type of the value in the diff result.
11
+ */
12
+ export type CommonDiffResult<T> = {
13
+ type: "common" | "truncation";
14
+ value: T;
15
+ };
16
+ /**
17
+ * Represents the result of a changed diff operation.
18
+ * @typeParam T The type of the value in the diff result.
19
+ */
20
+ export type ChangedDiffResult<T> = {
21
+ type: "removed" | "added";
22
+ value: T;
23
+ details?: DiffResult<T>[];
24
+ };
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.12/types.ts"],"names":[],"mappings":"AAGA,kDAAkD;AAClD,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,IAAI,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC9B,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,KAAK,EAAE,CAAC,CAAC;IACT,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;CAC3B,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.12/types.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,qCAAqC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,3 @@
1
+ export { assertEquals } from './deps/jsr.io/@std/assert/1.0.16/mod.js';
2
+ export declare function trimLines(args: TemplateStringsArray): string;
3
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,wBAAgB,SAAS,CAAC,IAAI,EAAE,oBAAoB,UASnD"}
@@ -0,0 +1,12 @@
1
+ export { assertEquals } from './deps/jsr.io/@std/assert/1.0.16/mod.js';
2
+ export function trimLines(args) {
3
+ const lines = args[0].split('\n');
4
+ if (!lines[0].trim()) {
5
+ lines.shift();
6
+ }
7
+ if (!lines[lines.length - 1].trim()) {
8
+ lines[lines.length - 1] = '';
9
+ }
10
+ return lines.join('\n');
11
+ }
12
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,MAAM,UAAU,SAAS,CAAC,IAA0B;IAClD,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QACrB,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QACpC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kerebron/test-utils",
3
- "version": "0.4.27",
3
+ "version": "0.4.29",
4
4
  "license": "MIT",
5
5
  "module": "./esm/test-utils.js",
6
6
  "exports": {
@@ -9,7 +9,10 @@
9
9
  }
10
10
  },
11
11
  "scripts": {},
12
- "files": [],
12
+ "files": [
13
+ "esm",
14
+ "src"
15
+ ],
13
16
  "devDependencies": {
14
17
  "@types/node": "^20.9.0"
15
18
  },
@@ -0,0 +1,60 @@
1
+ const dntGlobals = {
2
+ };
3
+ export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
4
+
5
+ function createMergeProxy<T extends object, U extends object>(
6
+ baseObj: T,
7
+ extObj: U,
8
+ ): Omit<T, keyof U> & U {
9
+ return new Proxy(baseObj, {
10
+ get(_target, prop, _receiver) {
11
+ if (prop in extObj) {
12
+ return (extObj as any)[prop];
13
+ } else {
14
+ return (baseObj as any)[prop];
15
+ }
16
+ },
17
+ set(_target, prop, value) {
18
+ if (prop in extObj) {
19
+ delete (extObj as any)[prop];
20
+ }
21
+ (baseObj as any)[prop] = value;
22
+ return true;
23
+ },
24
+ deleteProperty(_target, prop) {
25
+ let success = false;
26
+ if (prop in extObj) {
27
+ delete (extObj as any)[prop];
28
+ success = true;
29
+ }
30
+ if (prop in baseObj) {
31
+ delete (baseObj as any)[prop];
32
+ success = true;
33
+ }
34
+ return success;
35
+ },
36
+ ownKeys(_target) {
37
+ const baseKeys = Reflect.ownKeys(baseObj);
38
+ const extKeys = Reflect.ownKeys(extObj);
39
+ const extKeysSet = new Set(extKeys);
40
+ return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
41
+ },
42
+ defineProperty(_target, prop, desc) {
43
+ if (prop in extObj) {
44
+ delete (extObj as any)[prop];
45
+ }
46
+ Reflect.defineProperty(baseObj, prop, desc);
47
+ return true;
48
+ },
49
+ getOwnPropertyDescriptor(_target, prop) {
50
+ if (prop in extObj) {
51
+ return Reflect.getOwnPropertyDescriptor(extObj, prop);
52
+ } else {
53
+ return Reflect.getOwnPropertyDescriptor(baseObj, prop);
54
+ }
55
+ },
56
+ has(_target, prop) {
57
+ return prop in extObj || prop in baseObj;
58
+ },
59
+ }) as any;
60
+ }
@@ -0,0 +1,55 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { AssertionError } from "./assertion_error.js";
4
+
5
+ /**
6
+ * Make an assertion that `actual` and `expected` are almost equal numbers
7
+ * through a given tolerance. It can be used to take into account IEEE-754
8
+ * double-precision floating-point representation limitations. If the values
9
+ * are not almost equal then throw.
10
+ *
11
+ * The default tolerance is one hundred thousandth of a percent of the
12
+ * expected value.
13
+ *
14
+ * @example Usage
15
+ * ```ts ignore
16
+ * import { assertAlmostEquals } from "@std/assert";
17
+ *
18
+ * assertAlmostEquals(0.01, 0.02); // Throws
19
+ * assertAlmostEquals(1e-8, 1e-9); // Throws
20
+ * assertAlmostEquals(1.000000001e-8, 1.000000002e-8); // Doesn't throw
21
+ * assertAlmostEquals(0.01, 0.02, 0.1); // Doesn't throw
22
+ * assertAlmostEquals(0.1 + 0.2, 0.3, 1e-16); // Doesn't throw
23
+ * assertAlmostEquals(0.1 + 0.2, 0.3, 1e-17); // Throws
24
+ * ```
25
+ *
26
+ * @param actual The actual value to compare.
27
+ * @param expected The expected value to compare.
28
+ * @param tolerance The tolerance to consider the values almost equal. The
29
+ * default is one hundred thousandth of a percent of the expected value.
30
+ * @param msg The optional message to include in the error.
31
+ */
32
+ export function assertAlmostEquals(
33
+ actual: number,
34
+ expected: number,
35
+ tolerance?: number,
36
+ msg?: string,
37
+ ) {
38
+ if (Object.is(actual, expected)) {
39
+ return;
40
+ }
41
+ const delta = Math.abs(expected - actual);
42
+ if (tolerance === undefined) {
43
+ tolerance = isFinite(expected) ? Math.abs(expected * 1e-7) : 1e-7;
44
+ }
45
+ if (delta <= tolerance) {
46
+ return;
47
+ }
48
+
49
+ const msgSuffix = msg ? `: ${msg}` : ".";
50
+ const f = (n: number) => Number.isInteger(n) ? n : n.toExponential();
51
+ throw new AssertionError(
52
+ `Expected actual: "${f(actual)}" to be close to "${f(expected)}": \
53
+ delta "${f(delta)}" is greater than "${f(tolerance)}"${msgSuffix}`,
54
+ );
55
+ }
@@ -0,0 +1,57 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { equal } from "./equal.js";
4
+ import { format } from "../../internal/1.0.12/format.js";
5
+ import { AssertionError } from "./assertion_error.js";
6
+
7
+ /** An array-like object (`Array`, `Uint8Array`, `NodeList`, etc.) that is not a string */
8
+ export type ArrayLikeArg<T> = ArrayLike<T> & object;
9
+
10
+ /**
11
+ * Make an assertion that `actual` includes the `expected` values. If not then
12
+ * an error will be thrown.
13
+ *
14
+ * Type parameter can be specified to ensure values under comparison have the
15
+ * same type.
16
+ *
17
+ * @example Usage
18
+ * ```ts ignore
19
+ * import { assertArrayIncludes } from "@std/assert";
20
+ *
21
+ * assertArrayIncludes([1, 2], [2]); // Doesn't throw
22
+ * assertArrayIncludes([1, 2], [3]); // Throws
23
+ * ```
24
+ *
25
+ * @typeParam T The type of the elements in the array to compare.
26
+ * @param actual The array-like object to check for.
27
+ * @param expected The array-like object to check for.
28
+ * @param msg The optional message to display if the assertion fails.
29
+ */
30
+ export function assertArrayIncludes<T>(
31
+ actual: ArrayLikeArg<T>,
32
+ expected: ArrayLikeArg<T>,
33
+ msg?: string,
34
+ ) {
35
+ const missing: unknown[] = [];
36
+ for (let i = 0; i < expected.length; i++) {
37
+ let found = false;
38
+ for (let j = 0; j < actual.length; j++) {
39
+ if (equal(expected[i], actual[j])) {
40
+ found = true;
41
+ break;
42
+ }
43
+ }
44
+ if (!found) {
45
+ missing.push(expected[i]);
46
+ }
47
+ }
48
+ if (missing.length === 0) {
49
+ return;
50
+ }
51
+
52
+ const msgSuffix = msg ? `: ${msg}` : ".";
53
+ msg = `Expected actual: "${format(actual)}" to include: "${
54
+ format(expected)
55
+ }"${msgSuffix}\nmissing: ${format(missing)}`;
56
+ throw new AssertionError(msg);
57
+ }
@@ -0,0 +1,23 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { AssertionError } from "./assertion_error.js";
4
+
5
+ /**
6
+ * Make an assertion, error will be thrown if `expr` does not have truthy value.
7
+ *
8
+ * @example Usage
9
+ * ```ts ignore
10
+ * import { assert } from "@std/assert";
11
+ *
12
+ * assert("hello".includes("ello")); // Doesn't throw
13
+ * assert("hello".includes("world")); // Throws
14
+ * ```
15
+ *
16
+ * @param expr The expression to test.
17
+ * @param msg The optional message to display if the assertion fails.
18
+ */
19
+ export function assert(expr: unknown, msg = ""): asserts expr {
20
+ if (!expr) {
21
+ throw new AssertionError(msg);
22
+ }
23
+ }
@@ -0,0 +1,31 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /**
5
+ * Error thrown when an assertion fails.
6
+ *
7
+ * @example Usage
8
+ * ```ts ignore
9
+ * import { AssertionError } from "@std/assert";
10
+ *
11
+ * try {
12
+ * throw new AssertionError("foo", { cause: "bar" });
13
+ * } catch (error) {
14
+ * if (error instanceof AssertionError) {
15
+ * error.message === "foo"; // true
16
+ * error.cause === "bar"; // true
17
+ * }
18
+ * }
19
+ * ```
20
+ */
21
+ export class AssertionError extends Error {
22
+ /** Constructs a new instance.
23
+ *
24
+ * @param message The error message.
25
+ * @param options Additional options. This argument is still unstable. It may change in the future release.
26
+ */
27
+ constructor(message: string, options?: ErrorOptions) {
28
+ super(message, options);
29
+ this.name = "AssertionError";
30
+ }
31
+ }
@@ -0,0 +1,218 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import * as dntShim from "../../../../../_dnt.shims.js";
4
+
5
+
6
+ type KeyedCollection = Set<unknown> | Map<unknown, unknown>;
7
+ function isKeyedCollection(x: unknown): x is KeyedCollection {
8
+ return x instanceof Set || x instanceof Map;
9
+ }
10
+
11
+ function prototypesEqual(a: object, b: object) {
12
+ const pa = Object.getPrototypeOf(a);
13
+ const pb = Object.getPrototypeOf(b);
14
+ return pa === pb ||
15
+ pa === Object.prototype && pb === null ||
16
+ pa === null && pb === Object.prototype;
17
+ }
18
+
19
+ function isBasicObjectOrArray(obj: object) {
20
+ const proto = Object.getPrototypeOf(obj);
21
+ return proto === null || proto === Object.prototype ||
22
+ proto === Array.prototype;
23
+ }
24
+
25
+ // Slightly faster than Reflect.ownKeys in V8 as of 12.9.202.13-rusty (2024-10-28)
26
+ function ownKeys(obj: object) {
27
+ return [
28
+ ...Object.getOwnPropertyNames(obj),
29
+ ...Object.getOwnPropertySymbols(obj),
30
+ ];
31
+ }
32
+
33
+ function getKeysDeep(obj: object) {
34
+ const keys = new Set<string | symbol>();
35
+
36
+ while (obj !== Object.prototype && obj !== Array.prototype && obj != null) {
37
+ for (const key of ownKeys(obj)) {
38
+ keys.add(key);
39
+ }
40
+ obj = Object.getPrototypeOf(obj);
41
+ }
42
+
43
+ return keys;
44
+ }
45
+
46
+ // deno-lint-ignore no-explicit-any
47
+ const Temporal = (dntShim.dntGlobalThis as any).Temporal ?? Object.create(null);
48
+
49
+ /** A non-exhaustive list of prototypes that can be accurately fast-path compared with `String(instance)` */
50
+ const stringComparablePrototypes = new Set<unknown>(
51
+ [
52
+ Intl.Locale,
53
+ RegExp,
54
+ Temporal.Duration,
55
+ Temporal.Instant,
56
+ Temporal.PlainDate,
57
+ Temporal.PlainDateTime,
58
+ Temporal.PlainTime,
59
+ Temporal.PlainYearMonth,
60
+ Temporal.PlainMonthDay,
61
+ Temporal.ZonedDateTime,
62
+ URL,
63
+ URLSearchParams,
64
+ ].filter((x) => x != null).map((x) => x.prototype),
65
+ );
66
+
67
+ function isPrimitive(x: unknown) {
68
+ return typeof x === "string" ||
69
+ typeof x === "number" ||
70
+ typeof x === "boolean" ||
71
+ typeof x === "bigint" ||
72
+ typeof x === "symbol" ||
73
+ x == null;
74
+ }
75
+
76
+ type TypedArray = Pick<Uint8Array | BigUint64Array, "length" | number>;
77
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
78
+ function compareTypedArrays(a: TypedArray, b: TypedArray) {
79
+ if (a.length !== b.length) return false;
80
+ for (let i = 0; i < b.length; i++) {
81
+ if (!sameValueZero(a[i], b[i])) return false;
82
+ }
83
+ return true;
84
+ }
85
+
86
+ /** Check both strict equality (`0 == -0`) and `Object.is` (`NaN == NaN`) */
87
+ function sameValueZero(a: unknown, b: unknown) {
88
+ return a === b || Object.is(a, b);
89
+ }
90
+
91
+ /**
92
+ * Deep equality comparison used in assertions.
93
+ *
94
+ * @param a The actual value
95
+ * @param b The expected value
96
+ * @returns `true` if the values are deeply equal, `false` otherwise
97
+ *
98
+ * @example Usage
99
+ * ```ts
100
+ * import { equal } from "@std/assert/equal";
101
+ *
102
+ * equal({ foo: "bar" }, { foo: "bar" }); // Returns `true`
103
+ * equal({ foo: "bar" }, { foo: "baz" }); // Returns `false`
104
+ * ```
105
+ */
106
+ export function equal(a: unknown, b: unknown): boolean {
107
+ const seen = new Map<unknown, unknown>();
108
+ return (function compare(a: unknown, b: unknown): boolean {
109
+ if (sameValueZero(a, b)) return true;
110
+ if (isPrimitive(a) || isPrimitive(b)) return false;
111
+
112
+ if (a instanceof Date && b instanceof Date) {
113
+ return Object.is(a.getTime(), b.getTime());
114
+ }
115
+ if (a && typeof a === "object" && b && typeof b === "object") {
116
+ if (!prototypesEqual(a, b)) {
117
+ return false;
118
+ }
119
+ if (a instanceof TypedArray) {
120
+ return compareTypedArrays(a as TypedArray, b as TypedArray);
121
+ }
122
+ if (
123
+ a instanceof ArrayBuffer ||
124
+ (globalThis.SharedArrayBuffer && a instanceof SharedArrayBuffer)
125
+ ) {
126
+ return compareTypedArrays(
127
+ new Uint8Array(a),
128
+ new Uint8Array(b as ArrayBuffer | SharedArrayBuffer),
129
+ );
130
+ }
131
+ if (a instanceof WeakMap) {
132
+ throw new TypeError("Cannot compare WeakMap instances");
133
+ }
134
+ if (a instanceof WeakSet) {
135
+ throw new TypeError("Cannot compare WeakSet instances");
136
+ }
137
+ if (a instanceof WeakRef) {
138
+ return compare(a.deref(), (b as WeakRef<WeakKey>).deref());
139
+ }
140
+ if (seen.get(a) === b) {
141
+ return true;
142
+ }
143
+ if (Object.keys(a).length !== Object.keys(b).length) {
144
+ return false;
145
+ }
146
+ seen.set(a, b);
147
+ if (isKeyedCollection(a) && isKeyedCollection(b)) {
148
+ if (a.size !== b.size) {
149
+ return false;
150
+ }
151
+
152
+ const aKeys = [...a.keys()];
153
+ const primitiveKeysFastPath = aKeys.every(isPrimitive);
154
+ if (primitiveKeysFastPath) {
155
+ if (a instanceof Set) {
156
+ return a.symmetricDifference(b).size === 0;
157
+ }
158
+
159
+ for (const key of aKeys) {
160
+ if (
161
+ !b.has(key) ||
162
+ !compare(a.get(key), (b as Map<unknown, unknown>).get(key))
163
+ ) {
164
+ return false;
165
+ }
166
+ }
167
+ return true;
168
+ }
169
+
170
+ let unmatchedEntries = a.size;
171
+
172
+ for (const [aKey, aValue] of a.entries()) {
173
+ for (const [bKey, bValue] of b.entries()) {
174
+ /* Given that Map keys can be references, we need
175
+ * to ensure that they are also deeply equal */
176
+
177
+ if (!compare(aKey, bKey)) continue;
178
+
179
+ if (
180
+ (aKey === aValue && bKey === bValue) ||
181
+ (compare(aValue, bValue))
182
+ ) {
183
+ unmatchedEntries--;
184
+ break;
185
+ }
186
+ }
187
+ }
188
+
189
+ return unmatchedEntries === 0;
190
+ }
191
+
192
+ let keys: Iterable<string | symbol>;
193
+
194
+ if (isBasicObjectOrArray(a)) {
195
+ // fast path
196
+ keys = ownKeys({ ...a, ...b });
197
+ } else if (stringComparablePrototypes.has(Object.getPrototypeOf(a))) {
198
+ // medium path
199
+ return String(a) === String(b);
200
+ } else {
201
+ // slow path
202
+ keys = getKeysDeep(a).union(getKeysDeep(b));
203
+ }
204
+
205
+ for (const key of keys) {
206
+ type Key = keyof typeof a;
207
+ if (!compare(a[key as Key], b[key as Key])) {
208
+ return false;
209
+ }
210
+ if (((key in a) && (!(key in b))) || ((key in b) && (!(key in a)))) {
211
+ return false;
212
+ }
213
+ }
214
+ return true;
215
+ }
216
+ return false;
217
+ })(a, b);
218
+ }
@@ -0,0 +1,66 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { equal } from "./equal.js";
4
+ import { buildMessage } from "../../internal/1.0.12/build_message.js";
5
+ import { diff } from "../../internal/1.0.12/diff.js";
6
+ import { diffStr } from "../../internal/1.0.12/diff_str.js";
7
+ import { format } from "../../internal/1.0.12/format.js";
8
+
9
+ import { AssertionError } from "./assertion_error.js";
10
+
11
+ /**
12
+ * Make an assertion that `actual` and `expected` are equal, deeply. If not
13
+ * deeply equal, then throw.
14
+ *
15
+ * Type parameter can be specified to ensure values under comparison have the
16
+ * same type.
17
+ *
18
+ * Note: When comparing `Blob` objects, you should first convert them to
19
+ * `Uint8Array` using the `Blob.bytes()` method and then compare their
20
+ * contents.
21
+ *
22
+ * @example Usage
23
+ * ```ts ignore
24
+ * import { assertEquals } from "@std/assert";
25
+ *
26
+ * assertEquals("world", "world"); // Doesn't throw
27
+ * assertEquals("hello", "world"); // Throws
28
+ * ```
29
+ * @example Compare `Blob` objects
30
+ * ```ts ignore
31
+ * import { assertEquals } from "@std/assert";
32
+ *
33
+ * const bytes1 = await new Blob(["foo"]).bytes();
34
+ * const bytes2 = await new Blob(["foo"]).bytes();
35
+ *
36
+ * assertEquals(bytes1, bytes2);
37
+ * ```
38
+ *
39
+ * @typeParam T The type of the values to compare. This is usually inferred.
40
+ * @param actual The actual value to compare.
41
+ * @param expected The expected value to compare.
42
+ * @param msg The optional message to display if the assertion fails.
43
+ */
44
+ export function assertEquals<T>(
45
+ actual: T,
46
+ expected: T,
47
+ msg?: string,
48
+ ) {
49
+ if (equal(actual, expected)) {
50
+ return;
51
+ }
52
+ const msgSuffix = msg ? `: ${msg}` : ".";
53
+ let message = `Values are not equal${msgSuffix}`;
54
+
55
+ const actualString = format(actual);
56
+ const expectedString = format(expected);
57
+ const stringDiff = (typeof actual === "string") &&
58
+ (typeof expected === "string");
59
+ const diffResult = stringDiff
60
+ ? diffStr(actual as string, expected as string)
61
+ : diff(actualString.split("\n"), expectedString.split("\n"));
62
+ const diffMsg = buildMessage(diffResult, { stringDiff }, arguments[3])
63
+ .join("\n");
64
+ message = `${message}\n${diffMsg}`;
65
+ throw new AssertionError(message);
66
+ }
@@ -0,0 +1,31 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { AssertionError } from "./assertion_error.js";
4
+
5
+ /**
6
+ * Make an assertion that actual is not null or undefined.
7
+ * If not then throw.
8
+ *
9
+ * @example Usage
10
+ * ```ts ignore
11
+ * import { assertExists } from "@std/assert";
12
+ *
13
+ * assertExists("something"); // Doesn't throw
14
+ * assertExists(undefined); // Throws
15
+ * ```
16
+ *
17
+ * @typeParam T The type of the actual value.
18
+ * @param actual The actual value to check.
19
+ * @param msg The optional message to include in the error if the assertion fails.
20
+ */
21
+ export function assertExists<T>(
22
+ actual: T,
23
+ msg?: string,
24
+ ): asserts actual is NonNullable<T> {
25
+ if (actual === undefined || actual === null) {
26
+ const msgSuffix = msg ? `: ${msg}` : ".";
27
+ msg =
28
+ `Expected actual: "${actual}" to not be null or undefined${msgSuffix}`;
29
+ throw new AssertionError(msg);
30
+ }
31
+ }
@@ -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
+ /**
6
+ * Forcefully throws a failed assertion.
7
+ *
8
+ * @example Usage
9
+ * ```ts ignore
10
+ * import { fail } from "@std/assert";
11
+ *
12
+ * fail("Deliberately failed!"); // Throws
13
+ * ```
14
+ *
15
+ * @param msg Optional message to include in the error.
16
+ * @returns Never returns, always throws.
17
+ */
18
+ export function fail(msg?: string): never {
19
+ const msgSuffix = msg ? `: ${msg}` : ".";
20
+ throw new AssertionError(`Failed assertion${msgSuffix}`);
21
+ }
@@ -0,0 +1,26 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { AssertionError } from "./assertion_error.js";
4
+
5
+ /** Assertion condition for {@linkcode assertFalse}. */
6
+ export type Falsy = false | 0 | 0n | "" | null | undefined;
7
+
8
+ /**
9
+ * Make an assertion, error will be thrown if `expr` have truthy value.
10
+ *
11
+ * @example Usage
12
+ * ```ts ignore
13
+ * import { assertFalse } from "@std/assert";
14
+ *
15
+ * assertFalse(false); // Doesn't throw
16
+ * assertFalse(true); // Throws
17
+ * ```
18
+ *
19
+ * @param expr The expression to test.
20
+ * @param msg The optional message to display if the assertion fails.
21
+ */
22
+ export function assertFalse(expr: unknown, msg = ""): asserts expr is Falsy {
23
+ if (expr) {
24
+ throw new AssertionError(msg);
25
+ }
26
+ }