proby 0.2.1 → 0.2.3

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 (2) hide show
  1. package/lib/run.js +26 -2
  2. package/package.json +1 -1
package/lib/run.js CHANGED
@@ -4,6 +4,30 @@ import red from "@rcompat/cli/color/red";
4
4
  import print from "@rcompat/cli/print";
5
5
  import repository from "@rcompat/test/repository";
6
6
  const endings = [".spec.ts", ".spec.js"];
7
+ function stringify(value) {
8
+ if (value === null)
9
+ return "null";
10
+ if (value === undefined)
11
+ return "undefined";
12
+ if (["string", "number", "boolean", "symbol"].includes(typeof value)) {
13
+ return value.toString();
14
+ }
15
+ if (typeof value === "bigint") {
16
+ return value.toString() + "n";
17
+ }
18
+ if (typeof value === "function") {
19
+ return `[Function${value.name ? `: ${value.name}` : ""}]`;
20
+ }
21
+ if (typeof value === "object") {
22
+ try {
23
+ return JSON.stringify(value, (_, sub) => stringify(sub));
24
+ }
25
+ catch {
26
+ return "[Object (circular or unserializable)]";
27
+ }
28
+ }
29
+ return String(value);
30
+ }
7
31
  export default async (root, subrepo) => {
8
32
  const files = await root.list(file => endings.some(ending => file.path.endsWith(ending)), { recursive: true });
9
33
  if (files.length === 0) {
@@ -33,8 +57,8 @@ export default async (root, subrepo) => {
33
57
  print("\n");
34
58
  for (const [test, result] of failed) {
35
59
  print(`${test.file.debase(root)} ${red(test.name)} \n`);
36
- print(` expected ${result.expected}\n`);
37
- print(` actual ${result.actual}\n`);
60
+ print(` expected ${stringify(result.expected)}\n`);
61
+ print(` actual ${stringify(result.actual)}\n`);
38
62
  }
39
63
  }
40
64
  print("\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proby",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Standard library test runner",
5
5
  "bugs": "https://github.com/rcompat/rcompat/issues",
6
6
  "license": "MIT",