mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-20 05:40:17 +08:00
- The ratified rename rider (world-unification §7 lane 5): "DOM" collided with the browser DOM and, post-lane-1, the structure is no longer a document tree. Comments and doc prose now say "the checked-dynamic tree" for the noun and "dyn" adjectivally; runtime symbol names (scr_dyn_*), the error.domClone libCall, and the real web DOMException family are unchanged. - The few user-facing strings carrying the nickname move with it (the structuredClone cyclic message, the dc subscriber/publish fences, two emitter ICE texts); diagnostics snapshots regenerated (96 pass). One private compiler constant (DOM_PROTO_METHOD_NAMES -> DYN_PROTO_METHOD_NAMES) rides along. - Mechanical sweep, 142 files, comments/prose only — no behavior change.
52 lines
2.5 KiB
TypeScript
52 lines
2.5 KiB
TypeScript
// The assert surface's honest fences: the loose == quartet (assert's own
|
|
// equal/deepEqual — assert/strict's same-named members ARE the strict
|
|
// comparisons and lower), reference-equality strictEqual on objects,
|
|
// union operands (narrow first), mismatched or uncomparable deep types
|
|
// (typed arrays, class instances), namespace-object calls, unsupported
|
|
// throws/rejects expectations (properties outside the static error
|
|
// surface, empty shapes, non-literal objects, doesNotReject shapes —
|
|
// Node's own TypeError), ifError over uncomparable types, and assert
|
|
// functions as values. Every reached site terminates in a named
|
|
// diagnostic — never a miscompare, never silence.
|
|
import assert from "node:assert";
|
|
import * as assertNs from "node:assert";
|
|
|
|
assert.equal(1, 1); // loose == — points at the strict forms
|
|
assert.notEqual(1, 2);
|
|
assert.deepEqual([1], [1]);
|
|
assert.notDeepEqual([1], [2]);
|
|
|
|
const box = { n: 1 };
|
|
assert.strictEqual(box, box); // reference equality — deepStrictEqual hint
|
|
|
|
let maybe: string | undefined = "x";
|
|
if ("x".length === 0) maybe = undefined;
|
|
assert.strictEqual(maybe, "x"); // union operand — narrow first
|
|
|
|
const unk: unknown = JSON.parse("{}");
|
|
assert.strictEqual(unk, { n: 1 }); // strict + composite static side: reference identity does not survive the unknown boundary
|
|
assert.deepStrictEqual(unk, new Uint8Array([1])); // bytes static side: the dyn copy cannot carry the brand
|
|
assert.deepStrictEqual(unk, new Map<string, number>()); // not dyn-convertible
|
|
|
|
assert.deepStrictEqual([1, 2], ["a", "b"]); // different static types
|
|
assert.deepStrictEqual([new Uint8Array([1])], [new Uint8Array([1])]); // NESTED typed arrays fence (no brand in the element type)
|
|
class Point {
|
|
x: number;
|
|
constructor(x: number) {
|
|
this.x = x;
|
|
}
|
|
}
|
|
assert.deepStrictEqual(new Point(1), new Point(1)); // class instances fence
|
|
|
|
assertNs(true); // namespace objects are not callable in Node
|
|
|
|
assert.throws(() => { throw new Error("x"); }, { errno: -2 }); // properties outside the static error surface
|
|
assert.throws(() => { throw new Error("x"); }, {}); // Node rejects the empty shape
|
|
// (a convertible record VARIABLE as the expected shape lowers now — the
|
|
// errValue key walk; corpus 2556 pins it)
|
|
void assert.doesNotReject(async () => {}, { name: "TypeError" }); // Node's own TypeError (function or RegExp only)
|
|
assert.ifError(new Map<string, number>()); // no honest ifError rendering for this type
|
|
|
|
const eq = assert.strictEqual; // assert functions as values
|
|
eq(1, 1);
|