@rezi-ui/testkit 0.1.0-alpha.1

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 (86) hide show
  1. package/README.md +8 -0
  2. package/dist/__tests__/fixtures.test.d.ts +2 -0
  3. package/dist/__tests__/fixtures.test.d.ts.map +1 -0
  4. package/dist/__tests__/fixtures.test.js +7 -0
  5. package/dist/__tests__/fixtures.test.js.map +1 -0
  6. package/dist/__tests__/golden.test.d.ts +2 -0
  7. package/dist/__tests__/golden.test.d.ts.map +1 -0
  8. package/dist/__tests__/golden.test.js +22 -0
  9. package/dist/__tests__/golden.test.js.map +1 -0
  10. package/dist/__tests__/rng.test.d.ts +2 -0
  11. package/dist/__tests__/rng.test.d.ts.map +1 -0
  12. package/dist/__tests__/rng.test.js +33 -0
  13. package/dist/__tests__/rng.test.js.map +1 -0
  14. package/dist/__tests__/test-runner-smoke.test.d.ts +2 -0
  15. package/dist/__tests__/test-runner-smoke.test.d.ts.map +1 -0
  16. package/dist/__tests__/test-runner-smoke.test.js +5 -0
  17. package/dist/__tests__/test-runner-smoke.test.js.map +1 -0
  18. package/dist/fixtures.d.ts +2 -0
  19. package/dist/fixtures.d.ts.map +1 -0
  20. package/dist/fixtures.js +19 -0
  21. package/dist/fixtures.js.map +1 -0
  22. package/dist/golden.d.ts +7 -0
  23. package/dist/golden.d.ts.map +1 -0
  24. package/dist/golden.js +75 -0
  25. package/dist/golden.js.map +1 -0
  26. package/dist/index.d.ts +5 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +5 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/nodeTest.d.ts +4 -0
  31. package/dist/nodeTest.d.ts.map +1 -0
  32. package/dist/nodeTest.js +4 -0
  33. package/dist/nodeTest.js.map +1 -0
  34. package/dist/rng.d.ts +6 -0
  35. package/dist/rng.d.ts.map +1 -0
  36. package/dist/rng.js +43 -0
  37. package/dist/rng.js.map +1 -0
  38. package/fixtures/README.md +99 -0
  39. package/fixtures/__selftest__/hello.bin +1 -0
  40. package/fixtures/focus/.gitkeep +1 -0
  41. package/fixtures/focus/focus_list.json +68 -0
  42. package/fixtures/layout/hit_test_cases.json +93 -0
  43. package/fixtures/layout/hit_test_ties.json +43 -0
  44. package/fixtures/layout/layout_cases.json +138 -0
  45. package/fixtures/routing/.gitkeep +1 -0
  46. package/fixtures/routing/input_editing.json +316 -0
  47. package/fixtures/routing/key_routing.json +81 -0
  48. package/fixtures/routing/mouse_routing.json +167 -0
  49. package/fixtures/text-measure/graphemes.json +18 -0
  50. package/fixtures/text-measure/invalid-surrogates.json +12 -0
  51. package/fixtures/text-measure/strings.json +15 -0
  52. package/fixtures/zrdl-v1/.gitkeep +1 -0
  53. package/fixtures/zrdl-v1/README.md +78 -0
  54. package/fixtures/zrdl-v1/golden/clear_only.bin +0 -0
  55. package/fixtures/zrdl-v1/golden/clip_nested.bin +0 -0
  56. package/fixtures/zrdl-v1/golden/draw_text_interned.bin +0 -0
  57. package/fixtures/zrdl-v1/golden/fill_rect.bin +0 -0
  58. package/fixtures/zrdl-v1/ink-compat/border_styles.bin +0 -0
  59. package/fixtures/zrdl-v1/ink-compat/box_layout.bin +0 -0
  60. package/fixtures/zrdl-v1/ink-compat/flex_layout.bin +0 -0
  61. package/fixtures/zrdl-v1/ink-compat/simple_text.bin +0 -0
  62. package/fixtures/zrdl-v1/widgets/box_with_title.bin +0 -0
  63. package/fixtures/zrdl-v1/widgets/button_focus_states.bin +0 -0
  64. package/fixtures/zrdl-v1/widgets/divider_horizontal.bin +0 -0
  65. package/fixtures/zrdl-v1/widgets/divider_with_label.bin +0 -0
  66. package/fixtures/zrdl-v1/widgets/input_basic.bin +0 -0
  67. package/fixtures/zrdl-v1/widgets/input_disabled.bin +0 -0
  68. package/fixtures/zrdl-v1/widgets/input_focused_inverse.bin +0 -0
  69. package/fixtures/zrdl-v1/widgets/text_in_stack.bin +0 -0
  70. package/fixtures/zrev-v1/.gitkeep +1 -0
  71. package/fixtures/zrev-v1/README.md +102 -0
  72. package/fixtures/zrev-v1/invalid/bad_magic.bin +0 -0
  73. package/fixtures/zrev-v1/invalid/bad_version.bin +0 -0
  74. package/fixtures/zrev-v1/invalid/misaligned_record_size.bin +0 -0
  75. package/fixtures/zrev-v1/invalid/total_size_mismatch.bin +0 -0
  76. package/fixtures/zrev-v1/invalid/truncated_header.bin +0 -0
  77. package/fixtures/zrev-v1/invalid/truncated_payload.bin +0 -0
  78. package/fixtures/zrev-v1/invalid/truncated_record_header.bin +0 -0
  79. package/fixtures/zrev-v1/valid/key.bin +0 -0
  80. package/fixtures/zrev-v1/valid/mouse.bin +0 -0
  81. package/fixtures/zrev-v1/valid/paste.bin +0 -0
  82. package/fixtures/zrev-v1/valid/resize.bin +0 -0
  83. package/fixtures/zrev-v1/valid/text.bin +0 -0
  84. package/fixtures/zrev-v1/valid/tick.bin +0 -0
  85. package/fixtures/zrev-v1/valid/user.bin +0 -0
  86. package/package.json +31 -0
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # @rezi-ui/testkit
2
+
3
+ Test utilities and golden fixtures for Rezi.
4
+
5
+ Most applications do not need this package directly.
6
+
7
+ Docs: `https://rtlzeromemory.github.io/Rezi/`
8
+
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fixtures.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/fixtures.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { readFixture } from "../fixtures.js";
2
+ import { assert, test } from "../nodeTest.js";
3
+ test("readFixture loads bytes from packages/testkit/fixtures", async () => {
4
+ const bytes = await readFixture("__selftest__/hello.bin");
5
+ assert.deepEqual(Array.from(bytes), Array.from(new TextEncoder().encode("SELFTEST\n")));
6
+ });
7
+ //# sourceMappingURL=fixtures.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.test.js","sourceRoot":"","sources":["../../src/__tests__/fixtures.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE9C,IAAI,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;IACxE,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,wBAAwB,CAAC,CAAC;IAC1D,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAC1F,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=golden.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"golden.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/golden.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { assertBytesEqual, hexdump } from "../golden.js";
2
+ import { assert, test } from "../nodeTest.js";
3
+ test("hexdump uses stable formatting", () => {
4
+ const bytes = new Uint8Array([
5
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x41, 0x7e, 0x7f, 0xff,
6
+ ]);
7
+ const out = hexdump(bytes);
8
+ assert.equal(out, "00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 41 7e 7f ff |............A~..|");
9
+ });
10
+ test("assertBytesEqual reports first mismatch with window", () => {
11
+ const actual = new Uint8Array([1, 2, 3, 4, 5, 6]);
12
+ const expected = new Uint8Array([1, 2, 9, 4, 5, 6]);
13
+ assert.throws(() => assertBytesEqual(actual, expected, "demo"), (err) => {
14
+ assert.ok(err instanceof Error);
15
+ assert.ok(err.message.includes("assertBytesEqual (demo): mismatch at offset 2 (0x00000002)"));
16
+ assert.ok(err.message.includes("expected 0x09 but got 0x03"));
17
+ assert.ok(err.message.includes("expected (window):"));
18
+ assert.ok(err.message.includes("actual (window):"));
19
+ return true;
20
+ });
21
+ });
22
+ //# sourceMappingURL=golden.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"golden.test.js","sourceRoot":"","sources":["../../src/__tests__/golden.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE9C,IAAI,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC1C,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC;QAC3B,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;KAC/F,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,CAAC,KAAK,CACV,GAAG,EACH,gFAAgF,CACjF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,qDAAqD,EAAE,GAAG,EAAE;IAC/D,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEpD,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,EAChD,CAAC,GAAG,EAAE,EAAE;QACN,MAAM,CAAC,EAAE,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC;QAChC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,4DAA4D,CAAC,CAAC,CAAC;QAC9F,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC,CAAC;QAC9D,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC;QACtD,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=rng.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rng.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/rng.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import { assert, test } from "../nodeTest.js";
2
+ import { createRng } from "../rng.js";
3
+ test("createRng: same seed => same u32 sequence", () => {
4
+ const a = createRng(123);
5
+ const b = createRng(123);
6
+ const aa = [a.u32(), a.u32(), a.u32(), a.u32(), a.u32()];
7
+ const bb = [b.u32(), b.u32(), b.u32(), b.u32(), b.u32()];
8
+ assert.deepEqual(aa, bb);
9
+ });
10
+ test("createRng: bytes() is deterministic and little-endian from u32()", () => {
11
+ const r1 = createRng(1);
12
+ const r2 = createRng(1);
13
+ const b1 = r1.bytes(9);
14
+ const b2 = r2.bytes(9);
15
+ assert.deepEqual(Array.from(b1), Array.from(b2));
16
+ const r3 = createRng(1);
17
+ const x = r3.u32();
18
+ const y = r3.u32();
19
+ const expected = [
20
+ x & 0xff,
21
+ (x >>> 8) & 0xff,
22
+ (x >>> 16) & 0xff,
23
+ (x >>> 24) & 0xff,
24
+ y & 0xff,
25
+ (y >>> 8) & 0xff,
26
+ (y >>> 16) & 0xff,
27
+ (y >>> 24) & 0xff,
28
+ // next u32 least-significant byte
29
+ r3.u32() & 0xff,
30
+ ];
31
+ assert.deepEqual(Array.from(b1), expected);
32
+ });
33
+ //# sourceMappingURL=rng.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rng.test.js","sourceRoot":"","sources":["../../src/__tests__/rng.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,IAAI,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACrD,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IACzB,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAEzB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACzD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACzD,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,kEAAkE,EAAE,GAAG,EAAE;IAC5E,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAEjD,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;IACnB,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;IACnB,MAAM,QAAQ,GAAG;QACf,CAAC,GAAG,IAAI;QACR,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI;QAChB,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;QACjB,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;QACjB,CAAC,GAAG,IAAI;QACR,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI;QAChB,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;QACjB,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;QACjB,kCAAkC;QAClC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;KAChB,CAAC;IACF,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=test-runner-smoke.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-runner-smoke.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/test-runner-smoke.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { assert, test } from "../nodeTest.js";
2
+ test("test runner smoke", () => {
3
+ assert.equal(1 + 1, 2);
4
+ });
5
+ //# sourceMappingURL=test-runner-smoke.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-runner-smoke.test.js","sourceRoot":"","sources":["../../src/__tests__/test-runner-smoke.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE9C,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC7B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function readFixture(relPath: string): Promise<Uint8Array>;
2
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"mappings":"AAOA,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAYtE"}
@@ -0,0 +1,19 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { resolve, sep } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ const FIXTURES_ROOT = fileURLToPath(new URL("../fixtures/", import.meta.url));
5
+ const FIXTURES_ROOT_PREFIX = FIXTURES_ROOT.endsWith(sep) ? FIXTURES_ROOT : `${FIXTURES_ROOT}${sep}`;
6
+ export async function readFixture(relPath) {
7
+ const abs = resolve(FIXTURES_ROOT, relPath);
8
+ if (!abs.startsWith(FIXTURES_ROOT_PREFIX)) {
9
+ throw new Error(`readFixture: path escapes fixtures root: ${relPath}`);
10
+ }
11
+ try {
12
+ const buf = await readFile(abs);
13
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
14
+ }
15
+ catch {
16
+ throw new Error(`readFixture: not found: ${relPath}`);
17
+ }
18
+ }
19
+ //# sourceMappingURL=fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,aAAa,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9E,MAAM,oBAAoB,GAAG,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,GAAG,EAAE,CAAC;AAEpG,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAe;IAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChC,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type HexdumpOptions = Readonly<{
2
+ startOffset?: number;
3
+ bytesPerLine?: number;
4
+ }>;
5
+ export declare function hexdump(bytes: Uint8Array, opts?: HexdumpOptions): string;
6
+ export declare function assertBytesEqual(actual: Uint8Array, expected: Uint8Array, label?: string): void;
7
+ //# sourceMappingURL=golden.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"golden.d.ts","sourceRoot":"","sources":["../src/golden.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC,CAAC;AAcH,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,GAAE,cAAmB,GAAG,MAAM,CAuC5E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CA0C/F"}
package/dist/golden.js ADDED
@@ -0,0 +1,75 @@
1
+ import { AssertionError } from "node:assert";
2
+ function toHex2(b) {
3
+ return b.toString(16).padStart(2, "0");
4
+ }
5
+ function toHex8(n) {
6
+ return (n >>> 0).toString(16).padStart(8, "0");
7
+ }
8
+ function toAscii(b) {
9
+ return b >= 0x20 && b <= 0x7e ? String.fromCharCode(b) : ".";
10
+ }
11
+ export function hexdump(bytes, opts = {}) {
12
+ const startOffset = opts.startOffset ?? 0;
13
+ const bytesPerLine = opts.bytesPerLine ?? 16;
14
+ if (!Number.isInteger(bytesPerLine) || bytesPerLine <= 0) {
15
+ throw new Error(`hexdump: bytesPerLine must be a positive integer (got ${String(bytesPerLine)})`);
16
+ }
17
+ if (!Number.isInteger(startOffset) || startOffset < 0) {
18
+ throw new Error(`hexdump: startOffset must be a non-negative integer (got ${String(startOffset)})`);
19
+ }
20
+ /** @type {string[]} */
21
+ const lines = [];
22
+ for (let i = 0; i < bytes.length; i += bytesPerLine) {
23
+ const lineBytes = bytes.subarray(i, Math.min(bytes.length, i + bytesPerLine));
24
+ const off = startOffset + i;
25
+ let hexCol = "";
26
+ let asciiCol = "";
27
+ for (let j = 0; j < bytesPerLine; j++) {
28
+ const hasByte = j < lineBytes.length;
29
+ const b = hasByte ? (lineBytes[j] ?? 0) : 0;
30
+ if (j > 0)
31
+ hexCol += j === 8 ? " " : " ";
32
+ hexCol += hasByte ? toHex2(b) : " ";
33
+ asciiCol += hasByte ? toAscii(b) : " ";
34
+ }
35
+ lines.push(`${toHex8(off)} ${hexCol} |${asciiCol}|`);
36
+ }
37
+ return lines.join("\n");
38
+ }
39
+ export function assertBytesEqual(actual, expected, label) {
40
+ const minLen = Math.min(actual.length, expected.length);
41
+ let firstDiff = -1;
42
+ for (let i = 0; i < minLen; i++) {
43
+ if (actual[i] !== expected[i]) {
44
+ firstDiff = i;
45
+ break;
46
+ }
47
+ }
48
+ if (firstDiff === -1 && actual.length !== expected.length) {
49
+ firstDiff = minLen;
50
+ }
51
+ if (firstDiff === -1)
52
+ return;
53
+ const ctx = 16;
54
+ const start = Math.max(0, firstDiff - ctx);
55
+ const end = Math.min(Math.max(actual.length, expected.length), firstDiff + ctx + 1);
56
+ const actualSlice = actual.subarray(start, Math.min(actual.length, end));
57
+ const expectedSlice = expected.subarray(start, Math.min(expected.length, end));
58
+ const a = actual[firstDiff];
59
+ const e = expected[firstDiff];
60
+ const aHex = a === undefined ? "EOF" : `0x${toHex2(a)}`;
61
+ const eHex = e === undefined ? "EOF" : `0x${toHex2(e)}`;
62
+ const name = label ? ` (${label})` : "";
63
+ const msg = [
64
+ `assertBytesEqual${name}: mismatch at offset ${firstDiff} (0x${toHex8(firstDiff)})`,
65
+ `expected ${eHex} but got ${aHex}`,
66
+ "",
67
+ "expected (window):",
68
+ hexdump(expectedSlice, { startOffset: start }),
69
+ "",
70
+ "actual (window):",
71
+ hexdump(actualSlice, { startOffset: start }),
72
+ ].join("\n");
73
+ throw new AssertionError({ message: msg });
74
+ }
75
+ //# sourceMappingURL=golden.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"golden.js","sourceRoot":"","sources":["../src/golden.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAO7C,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC,CAAC,QAAQ,CAAC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AAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAExD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,MAAM,GAAG,GAAG;QACV,mBAAmB,IAAI,wBAAwB,SAAS,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG;QACnF,YAAY,IAAI,YAAY,IAAI,EAAE;QAClC,EAAE;QACF,oBAAoB;QACpB,OAAO,CAAC,aAAa,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;QAC9C,EAAE;QACF,kBAAkB;QAClB,OAAO,CAAC,WAAW,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;KAC7C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,MAAM,IAAI,cAAc,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { createRng, type Rng } from "./rng.js";
2
+ export { readFixture } from "./fixtures.js";
3
+ export { assertBytesEqual, hexdump } from "./golden.js";
4
+ export { assert, describe, test } from "./nodeTest.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { createRng } from "./rng.js";
2
+ export { readFixture } from "./fixtures.js";
3
+ export { assertBytesEqual, hexdump } from "./golden.js";
4
+ export { assert, describe, test } from "./nodeTest.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { strict as assert } from "node:assert";
2
+ import { describe, test } from "node:test";
3
+ export { assert, describe, test };
4
+ //# sourceMappingURL=nodeTest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeTest.d.ts","sourceRoot":"","sources":["../src/nodeTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { strict as assert } from "node:assert";
2
+ import { describe, test } from "node:test";
3
+ export { assert, describe, test };
4
+ //# sourceMappingURL=nodeTest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeTest.js","sourceRoot":"","sources":["../src/nodeTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC"}
package/dist/rng.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export type Rng = Readonly<{
2
+ u32(): number;
3
+ bytes(len: number): Uint8Array;
4
+ }>;
5
+ export declare function createRng(seed: number): Rng;
6
+ //# sourceMappingURL=rng.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rng.d.ts","sourceRoot":"","sources":["../src/rng.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GAAG,QAAQ,CAAC;IACzB,GAAG,IAAI,MAAM,CAAC;IACd,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;CAChC,CAAC,CAAC;AAEH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAyC3C"}
package/dist/rng.js ADDED
@@ -0,0 +1,43 @@
1
+ export function createRng(seed) {
2
+ let state = seed >>> 0;
3
+ function nextU32() {
4
+ // xorshift32 (George Marsaglia)
5
+ // Deterministic across platforms/runtimes via 32-bit bitwise ops.
6
+ state ^= (state << 13) >>> 0;
7
+ state ^= state >>> 17;
8
+ state ^= (state << 5) >>> 0;
9
+ state >>>= 0;
10
+ return state;
11
+ }
12
+ return {
13
+ u32() {
14
+ return nextU32();
15
+ },
16
+ bytes(len) {
17
+ if (!Number.isInteger(len) || len < 0) {
18
+ throw new Error(`createRng.bytes: len must be a non-negative integer (got ${String(len)})`);
19
+ }
20
+ const out = new Uint8Array(len);
21
+ let i = 0;
22
+ while (i < out.length) {
23
+ const x = nextU32();
24
+ out[i] = x & 0xff;
25
+ i++;
26
+ if (i >= out.length)
27
+ break;
28
+ out[i] = (x >>> 8) & 0xff;
29
+ i++;
30
+ if (i >= out.length)
31
+ break;
32
+ out[i] = (x >>> 16) & 0xff;
33
+ i++;
34
+ if (i >= out.length)
35
+ break;
36
+ out[i] = (x >>> 24) & 0xff;
37
+ i++;
38
+ }
39
+ return out;
40
+ },
41
+ };
42
+ }
43
+ //# sourceMappingURL=rng.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rng.js","sourceRoot":"","sources":["../src/rng.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,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AC,IAAI,GAAG,CAAC,MAAM;oBAAE,MAAM;gBAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;gBAC3B,CAAC,EAAE,CAAC;YACN,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;KACO,CAAC;AACb,CAAC"}
@@ -0,0 +1,99 @@
1
+ # @rezi-ui/testkit fixtures
2
+
3
+ This directory is the canonical home for **golden** test data used by protocol and runtime tests.
4
+
5
+ Fixtures live in `@rezi-ui/testkit` so that:
6
+ - `@rezi-ui/core` stays runtime-agnostic and free of filesystem assumptions.
7
+ - Tests can share stable, cross-platform byte fixtures.
8
+
9
+ ## Directory layout
10
+
11
+ - `zrev-v1/` — ZREV v1 event batch fixtures (`*.bin`, `*.json`)
12
+ - `zrdl-v1/` — ZRDL v1 drawlist fixtures (`*.bin`, `*.json`)
13
+ - `text-measure/` — pinned Unicode width fixtures (`*.json`)
14
+ - `layout/` — layout determinism fixtures (`*.json`)
15
+ - `focus/` — focus traversal golden fixtures (`*.json`)
16
+ - `routing/` — routing order fixtures (`*.json`)
17
+
18
+ ## Naming conventions
19
+
20
+ - Binary fixtures: `*.bin` (raw bytes; little-endian, 4-byte aligned where required)
21
+ - JSON fixtures: `*.json` (UTF-8 text; stable key ordering in committed files)
22
+
23
+ Keep filenames descriptive and stable (prefer `kebab-case`).
24
+
25
+ ## Golden update rules
26
+
27
+ See the testing guide for workflow details:
28
+ - [Testing](../../../docs/dev/testing.md)
29
+ - Tests **must not** auto-regenerate golden files.
30
+ - Updating a golden fixture is a **manual, intentional** change that must be reviewed.
31
+
32
+ When a golden fixture needs to change:
33
+ 1) Update the fixture file in this directory by hand (or by running a one-off local script you do not commit).
34
+ 2) Re-run `npm run test` and verify byte-for-byte output matches the new golden.
35
+ 3) Include the fixture diff in the PR review context.
36
+
37
+ ## JSON schemas (selected)
38
+
39
+ ### Text measurement: `text-measure/*.json`
40
+
41
+ Files:
42
+ - `text-measure/graphemes.json`
43
+ - `text-measure/strings.json`
44
+ - `text-measure/invalid-surrogates.json`
45
+
46
+ Schema:
47
+ ```ts
48
+ type TextMeasureFixture = {
49
+ schemaVersion: 1;
50
+ cases: Array<{ name: string; text: string; width: number }>;
51
+ };
52
+ ```
53
+
54
+ ### Layout: `layout/layout_cases.json`
55
+
56
+ Schema:
57
+ ```ts
58
+ type Rect = { x: number; y: number; w: number; h: number };
59
+ type Axis = "row" | "column";
60
+
61
+ type FixtureVNode =
62
+ | { ref: string; kind: "text"; text: string; props?: unknown }
63
+ | { ref: string; kind: "spacer"; props?: unknown }
64
+ | { ref: string; kind: "button"; props: unknown }
65
+ | { ref: string; kind: "row" | "column" | "box"; props?: unknown; children?: FixtureVNode[] };
66
+
67
+ type LayoutCase =
68
+ | { name: string; axis: Axis; viewport: Rect; tree: FixtureVNode; expect: { rects: Record<string, Rect> } }
69
+ | {
70
+ name: string;
71
+ axis: Axis;
72
+ viewport: Rect;
73
+ tree: FixtureVNode;
74
+ expectFatal: { code: "ZRUI_INVALID_PROPS"; detail: string };
75
+ };
76
+
77
+ type LayoutFixture = { schemaVersion: 1; cases: LayoutCase[] };
78
+ ```
79
+
80
+ Notes:
81
+ - `tree.ref` is a fixture-only identifier used as the key in `expect.rects`.
82
+ - `tree.kind`/`props`/`children` are “VNode-like”; tests convert to real `@rezi-ui/core` `VNode`s.
83
+
84
+ ### Hit testing: `layout/hit_test_cases.json`
85
+
86
+ Schema:
87
+ ```ts
88
+ type Rect = { x: number; y: number; w: number; h: number };
89
+ type HitPoint = { x: number; y: number; expectedId: string | null };
90
+
91
+ type HitTestCase = {
92
+ name: string;
93
+ tree: FixtureVNode;
94
+ layoutRects: Record<string, Rect>;
95
+ points: HitPoint[];
96
+ };
97
+
98
+ type HitTestFixture = { schemaVersion: 1; cases: HitTestCase[] };
99
+ ```
@@ -0,0 +1 @@
1
+ SELFTEST
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,68 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "cases": [
4
+ {
5
+ "name": "Example A — basic order (docs/10)",
6
+ "tree": {
7
+ "kind": "column",
8
+ "props": {},
9
+ "children": [
10
+ { "kind": "button", "props": { "id": "a", "label": "A" } },
11
+ {
12
+ "kind": "box",
13
+ "props": {},
14
+ "children": [
15
+ { "kind": "button", "props": { "id": "b", "label": "B" } },
16
+ { "kind": "button", "props": { "id": "c", "label": "C" } }
17
+ ]
18
+ },
19
+ { "kind": "text", "text": "hello", "props": {} },
20
+ { "kind": "button", "props": { "id": "d", "label": "D" } }
21
+ ]
22
+ },
23
+ "expectedFocusList": ["a", "b", "c", "d"]
24
+ },
25
+ {
26
+ "name": "Example D — disabled buttons skipped (docs/10)",
27
+ "tree": {
28
+ "kind": "row",
29
+ "props": {},
30
+ "children": [
31
+ { "kind": "button", "props": { "id": "a", "label": "A" } },
32
+ { "kind": "button", "props": { "id": "b", "label": "B", "disabled": true } },
33
+ { "kind": "button", "props": { "id": "c", "label": "C" } }
34
+ ]
35
+ },
36
+ "expectedFocusList": ["a", "c"]
37
+ }
38
+ ],
39
+ "reconcileCases": [
40
+ {
41
+ "name": "Example B — focused widget disappears (docs/10)",
42
+ "initialFocusedId": "b",
43
+ "nextTree": {
44
+ "kind": "column",
45
+ "props": {},
46
+ "children": [
47
+ { "kind": "button", "props": { "id": "a", "label": "A" } },
48
+ { "kind": "button", "props": { "id": "c", "label": "C" } }
49
+ ]
50
+ },
51
+ "expectedFocusedIdAfterCommit": "a"
52
+ },
53
+ {
54
+ "name": "Example C — insertion before focused keeps focus (docs/10)",
55
+ "initialFocusedId": "c",
56
+ "nextTree": {
57
+ "kind": "column",
58
+ "props": {},
59
+ "children": [
60
+ { "kind": "button", "props": { "id": "a", "label": "A" } },
61
+ { "kind": "button", "props": { "id": "b", "label": "B" } },
62
+ { "kind": "button", "props": { "id": "c", "label": "C" } }
63
+ ]
64
+ },
65
+ "expectedFocusedIdAfterCommit": "c"
66
+ }
67
+ ]
68
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "cases": [
4
+ {
5
+ "name": "simple_hit_test_enabled_buttons",
6
+ "tree": {
7
+ "ref": "root",
8
+ "kind": "column",
9
+ "props": {},
10
+ "children": [
11
+ { "ref": "b1", "kind": "button", "props": { "id": "a", "label": "A" } },
12
+ { "ref": "b2", "kind": "button", "props": { "id": "b", "label": "B" } }
13
+ ]
14
+ },
15
+ "layoutRects": {
16
+ "root": { "x": 0, "y": 0, "w": 3, "h": 2 },
17
+ "b1": { "x": 0, "y": 0, "w": 3, "h": 1 },
18
+ "b2": { "x": 0, "y": 1, "w": 3, "h": 1 }
19
+ },
20
+ "points": [
21
+ { "x": 0, "y": 0, "expectedId": "a" },
22
+ { "x": 2, "y": 1, "expectedId": "b" },
23
+ { "x": 3, "y": 0, "expectedId": null }
24
+ ]
25
+ },
26
+ {
27
+ "name": "overlap_last_wins_sibling_order",
28
+ "tree": {
29
+ "ref": "root",
30
+ "kind": "column",
31
+ "props": {},
32
+ "children": [
33
+ { "ref": "b1", "kind": "button", "props": { "id": "first", "label": "X" } },
34
+ { "ref": "b2", "kind": "button", "props": { "id": "last", "label": "Y" } }
35
+ ]
36
+ },
37
+ "layoutRects": {
38
+ "root": { "x": 0, "y": 0, "w": 4, "h": 1 },
39
+ "b1": { "x": 0, "y": 0, "w": 4, "h": 1 },
40
+ "b2": { "x": 0, "y": 0, "w": 4, "h": 1 }
41
+ },
42
+ "points": [{ "x": 1, "y": 0, "expectedId": "last" }]
43
+ },
44
+ {
45
+ "name": "overlap_disabled_last_is_skipped",
46
+ "tree": {
47
+ "ref": "root",
48
+ "kind": "column",
49
+ "props": {},
50
+ "children": [
51
+ { "ref": "b1", "kind": "button", "props": { "id": "enabled", "label": "E" } },
52
+ {
53
+ "ref": "b2",
54
+ "kind": "button",
55
+ "props": { "id": "disabled", "label": "D", "disabled": true }
56
+ }
57
+ ]
58
+ },
59
+ "layoutRects": {
60
+ "root": { "x": 0, "y": 0, "w": 4, "h": 1 },
61
+ "b1": { "x": 0, "y": 0, "w": 4, "h": 1 },
62
+ "b2": { "x": 0, "y": 0, "w": 4, "h": 1 }
63
+ },
64
+ "points": [{ "x": 2, "y": 0, "expectedId": "enabled" }]
65
+ },
66
+ {
67
+ "name": "overlap_nested_preorder_last_wins",
68
+ "tree": {
69
+ "ref": "root",
70
+ "kind": "column",
71
+ "props": {},
72
+ "children": [
73
+ {
74
+ "ref": "box1",
75
+ "kind": "box",
76
+ "props": { "border": "none" },
77
+ "children": [
78
+ { "ref": "b1", "kind": "button", "props": { "id": "inner", "label": "I" } }
79
+ ]
80
+ },
81
+ { "ref": "b2", "kind": "button", "props": { "id": "outer", "label": "O" } }
82
+ ]
83
+ },
84
+ "layoutRects": {
85
+ "root": { "x": 0, "y": 0, "w": 4, "h": 1 },
86
+ "box1": { "x": 0, "y": 0, "w": 4, "h": 1 },
87
+ "b1": { "x": 0, "y": 0, "w": 4, "h": 1 },
88
+ "b2": { "x": 0, "y": 0, "w": 4, "h": 1 }
89
+ },
90
+ "points": [{ "x": 0, "y": 0, "expectedId": "outer" }]
91
+ }
92
+ ]
93
+ }