Versions 89 to 318
new file, 27 lines
1+import assert from "node:assert/strict"; 2+import { test } from "node:test"; 3+import { LOG_PART_CHARACTERS, logParts, streamedLogParts } from "../src/engine-project.ts"; 5+test("streamed canonical rows exactly match legacy serialization and boundaries", () => { 6+ for (const offset of [-2, -1, 0, 1, 2]) { 7+ const value = { text: "x".repeat(LOG_PART_CHARACTERS - 9 + offset) + '😀\ud800\n"', rest: [null, false, 3] }; 8+ assert.deepEqual([...streamedLogParts(value)], logParts(JSON.stringify(value))); 10+ const value = { files: Array.from({ length: 100 }, (_, i) => `${i}:` + "中".repeat(20000)) }; 11+ assert.deepEqual([...streamedLogParts(value)], logParts(JSON.stringify(value))); 14+test("canonical row streaming never stringifies a whole object or a large string", (t) => { 15+ const stringify = JSON.stringify; 16+ t.mock.method(JSON, "stringify", (value: unknown) => { 17+ assert.ok(typeof value !== "object", "whole-object serialization is forbidden"); 18+ if (typeof value === "string") assert.ok(value.length <= 16384); 19+ return stringify(value); 22+ for (const part of streamedLogParts({ text: "x".repeat(6_000_000) })) { 23+ assert.ok(part.length <= LOG_PART_CHARACTERS); 24+ length += part.length; 26+ assert.equal(length, 6_000_011);