CodeSampleX

샘플

@jest/expect-utils 29.7.0: equals

검증된 샘플 — npm @jest/expect-utils 29.7.0: equals. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: equals performs structural deep equality check on…

sha256:47710044294bb121c7f79bb22c3e052f8fbb6a44f676422e88d7371c9b3d4472

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-23

케이스

HOW
목표
verify pkg:npm/%40jest/expect-utils@29.7.0
패키지
심벌
  • equals
환경
node 22.23.2
생성일
2026-08-23T16:19:38Z

컨트랙트

  1. equals performs structural deep equality check on primitives, nested objects, arrays, Dates, RegExps, Sets, and Maps
  2. equals resolves circular references without infinite recursion
  3. equals supports custom tester functions for specialized type comparisons
  4. equals with strictCheck false allows matching missing properties with undefined properties
  5. equals with strictCheck true rejects object property mismatches where one property is undefined and missing on the other
  6. equals with strictCheck true rejects sparse array vs dense undefined array differences

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.cjs

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:npm/%40jest/expect-utils@29.7.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40jest/expect-utils@29.7.0
Demonstrate these symbols/APIs:
  - equals
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:601495bf77d38aaa47b43efede97e80148d930a857be5b02e45db77ffa4d0b95","constraints":{"executionContext":"node"},"contract":["equals performs structural deep equality check on primitives, nested objects, arrays, Dates, RegExps, Sets, and Maps","equals resolves circular references without infinite recursion","equals supports custom tester functions for specialized type comparisons","equals with strictCheck false allows matching missing properties with undefined properties","equals with strictCheck true rejects object property mismatches where one property is undefined and missing on the other","equals with strictCheck true rejects sparse array vs dense undefined array differences"],"goal":"verify pkg:npm/%40jest/expect-utils@29.7.0","kind":"HOW","packages":["pkg:npm/%40jest/expect-utils@29.7.0"],"schemaVersion":1,"symbols":["equals"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40jest/expect-utils@29.7.0"],"schemaVersion":1,"subject":"pkg:npm/%40jest/expect-utils@29.7.0","symbols":["equals"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-jest-expect-utils-equals",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-jest-expect-utils-equals",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@jest/expect-utils": "29.7.0"
      }
    },
    "node_modules/@jest/expect-utils": {
      "version": "29.7.0",
      "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz",
      "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==",
      "license": "MIT",
      "dependencies": {
        "jest-get-type": "^29.6.3"
      },
      "engines": {
        "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
      }
    },
    "node_modules/jest-get-type": {
      "version": "29.6.3",
      "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz",
      "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==",
      "license": "MIT",
      "engines": {
        "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
      }
    }
  }
}
package.json
{
  "name": "sample-jest-expect-utils-equals",
  "version": "1.0.0",
  "private": true,
  "description": "verify pkg:npm/%40jest/expect-utils@29.7.0",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.cjs"
  },
  "dependencies": {
    "@jest/expect-utils": "29.7.0"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40jest/expect-utils@29.7.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40jest/expect-utils@29.7.0"
  ],
  "symbols": [
    "equals"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const { equals } = require('@jest/expect-utils');

/**
 * Performs deep structural equality comparison between two values.
 *
 * @param {unknown} a - First value to compare.
 * @param {unknown} b - Second value to compare.
 * @param {Array<Function>} [customTesters] - Optional custom tester functions.
 * @param {boolean} [strictCheck=false] - Whether to perform strict checks.
 * @returns {boolean} True if values are deeply equal, false otherwise.
 */
function areDeeplyEqual(a, b, customTesters, strictCheck = false) {
  return equals(a, b, customTesters, strictCheck);
}

module.exports = {
  equals,
  areDeeplyEqual
};
test/contract.cjs
const assert = require('node:assert');
const { equals, areDeeplyEqual } = require('../src/index.js');

async function main() {
  // 1. equals performs structural deep equality check on primitives, nested objects, arrays, Dates, RegExps, Sets, and Maps
  assert.strictEqual(areDeeplyEqual(42, 42), true, 'primitives must match');
  assert.strictEqual(areDeeplyEqual('foo', 'foo'), true, 'strings must match');
  assert.strictEqual(areDeeplyEqual({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] }), true, 'nested objects and arrays must match');
  assert.strictEqual(areDeeplyEqual({ a: 1 }, { a: 2 }), false, 'different property values must not match');

  assert.strictEqual(areDeeplyEqual(new Date('2026-01-01'), new Date('2026-01-01')), true, 'identical dates must match');
  assert.strictEqual(areDeeplyEqual(new Date('2026-01-01'), new Date('2026-01-02')), false, 'different dates must not match');
  assert.strictEqual(areDeeplyEqual(/abc/g, /abc/g), true, 'identical regexes must match');
  assert.strictEqual(areDeeplyEqual(/abc/g, /abc/i), false, 'different regex flags must not match');

  const setA = new Set([1, 2, { x: 3 }]);
  const setB = new Set([1, 2, { x: 3 }]);
  assert.strictEqual(areDeeplyEqual(setA, setB), true, 'sets with deeply equal elements must match');

  const mapA = new Map([['k1', { v: 1 }]]);
  const mapB = new Map([['k1', { v: 1 }]]);
  assert.strictEqual(areDeeplyEqual(mapA, mapB), true, 'maps with deeply equal entries must match');

  // 2. equals resolves circular references without infinite recursion
  const circA = { name: 'circular' };
  circA.self = circA;
  const circB = { name: 'circular' };
  circB.self = circB;
  assert.strictEqual(areDeeplyEqual(circA, circB), true, 'circular structures must be handled without overflow');

  // 3. equals supports custom tester functions for specialized type comparisons
  const customTester = function(a, b) {
    if (typeof a === 'string' && typeof b === 'number') {
      return a === String(b);
    }
    return undefined;
  };
  assert.strictEqual(areDeeplyEqual('123', 123, [customTester]), true, 'custom tester should match string with number');
  assert.strictEqual(areDeeplyEqual('123', 456, [customTester]), false, 'custom tester should reject unequal numbers');

  // 4. equals with strictCheck false allows matching missing properties with undefined properties
  const objUndefined = { a: undefined };
  const objMissing = {};
  assert.strictEqual(areDeeplyEqual(objUndefined, objMissing, undefined, false), true, 'loose check matches undefined with missing prop');

  // 5. equals with strictCheck true rejects object property mismatches where one property is undefined and missing on the other
  assert.strictEqual(areDeeplyEqual(objUndefined, objMissing, undefined, true), false, 'strict check rejects undefined vs missing prop');

  // 6. equals with strictCheck true rejects sparse array vs dense undefined array differences
  assert.strictEqual(areDeeplyEqual([,], [undefined], undefined, false), true, 'loose check matches sparse hole with undefined');
  assert.strictEqual(areDeeplyEqual([,], [undefined], undefined, true), false, 'strict check distinguishes sparse hole from undefined');

  console.log('Contract assertions passed.');
  process.exit(0);
}

main().catch((err) => {
  console.error('Contract failed:', err);
  process.exit(1);
});

오리진 시더

익명