샘플
@babel/types 7.29.7: numericLiteral
검증된 샘플 — npm @babel/types 7.29.7: numericLiteral. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: types.numericLiteral creates a NumericLiteral…
sha256:8c58390f9cd42c4020a199e387ba5bf9cf94003fd2b7904554e574dcf071f549
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-05 |
케이스
HOW- 목표
- verify @babel/types.numericLiteral in pkg:npm/%40babel/types@7.29.7
- 심벌
-
- @babel/types.numericLiteral
- 환경
- node 22.23.2
- 생성일
- 2026-09-05T21:24:19Z
컨트랙트
- types.numericLiteral creates a NumericLiteral AST node with the specified number value and type 'NumericLiteral'
- types.numericLiteral throws a TypeError when called with a non-number argument
- types.isNumericLiteral returns true for NumericLiteral nodes with optional value matching and false for other nodes
- types.assertNumericLiteral succeeds for valid NumericLiteral nodes and throws an Error for non-NumericLiteral nodes
- NumericLiteral nodes created with types.numericLiteral integrate into compound AST structures like BinaryExpression and ArrayExpression
- types.cloneNode produces an independent equivalent copy of a NumericLiteral node
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
소스
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 @babel/types.numericLiteral in pkg:npm/%40babel/types@7.29.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40babel/types@7.29.7
Demonstrate these symbols/APIs:
- @babel/types.numericLiteral
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.
{"case":{"caseId":"case:sha256:f56447539b5042b499ddb505118ec78e9b6808e33b48d49a92a0dcf8b6af29ae","constraints":{"executionContext":"node"},"contract":["types.numericLiteral creates a NumericLiteral AST node with the specified number value and type 'NumericLiteral'","types.numericLiteral throws a TypeError when called with a non-number argument","types.isNumericLiteral returns true for NumericLiteral nodes with optional value matching and false for other nodes","types.assertNumericLiteral succeeds for valid NumericLiteral nodes and throws an Error for non-NumericLiteral nodes","NumericLiteral nodes created with types.numericLiteral integrate into compound AST structures like BinaryExpression and ArrayExpression","types.cloneNode produces an independent equivalent copy of a NumericLiteral node"],"goal":"verify @babel/types.numericLiteral in pkg:npm/%40babel/types@7.29.7","kind":"HOW","packages":["pkg:npm/%40babel/types@7.29.7"],"schemaVersion":1,"symbols":["@babel/types.numericLiteral"]},"contractCommand":["node","test/contract.mjs"],"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/%40babel/types@7.29.7"],"schemaVersion":1,"subject":"pkg:npm/%40babel/types@7.29.7","symbols":["@babel/types.numericLiteral"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-babel-types-numericliteral",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-babel-types-numericliteral",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@babel/types": "7.29.7"
}
},
"node_modules/@babel/helper-string-parser": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
"integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
"integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/types": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.7.tgz",
"integrity": "sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA==",
"license": "MIT",
"dependencies": {
"@babel/helper-string-parser": "^7.29.7",
"@babel/helper-validator-identifier": "^7.29.7"
},
"engines": {
"node": ">=6.9.0"
}
}
}
}
{
"name": "sample-babel-types-numericliteral",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of @babel/types.numericLiteral",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"@babel/types": "7.29.7"
}
}
{
"schemaVersion": 1,
"goal": "verify @babel/types.numericLiteral in pkg:npm/%40babel/types@7.29.7",
"kind": "HOW",
"packages": [
"pkg:npm/%40babel/types@7.29.7"
],
"symbols": [
"@babel/types.numericLiteral"
]
}
const t = require('@babel/types');
/**
* Creates a NumericLiteral AST node with the given number value.
* @param {number} value
* @returns {object}
*/
function createNumericLiteral(value) {
return t.numericLiteral(value);
}
/**
* Checks if a node is a NumericLiteral, optionally matching properties.
* @param {object} node
* @param {object} [opts]
* @returns {boolean}
*/
function isNumericLiteralNode(node, opts) {
return t.isNumericLiteral(node, opts);
}
/**
* Asserts that a node is a NumericLiteral, throwing if not.
* @param {object} node
* @param {object} [opts]
*/
function assertNumericLiteralNode(node, opts) {
t.assertNumericLiteral(node, opts);
}
/**
* Creates a BinaryExpression AST node with two NumericLiteral operands.
* @param {string} operator
* @param {number} leftValue
* @param {number} rightValue
* @returns {object}
*/
function createBinaryNumericExpression(operator, leftValue, rightValue) {
const left = t.numericLiteral(leftValue);
const right = t.numericLiteral(rightValue);
return t.binaryExpression(operator, left, right);
}
/**
* Creates an ArrayExpression AST node containing NumericLiteral elements.
* @param {number[]} values
* @returns {object}
*/
function createNumericArrayExpression(values) {
const elements = values.map((val) => t.numericLiteral(val));
return t.arrayExpression(elements);
}
/**
* Clones a NumericLiteral AST node.
* @param {object} node
* @returns {object}
*/
function cloneNumericLiteral(node) {
return t.cloneNode(node);
}
module.exports = {
t,
createNumericLiteral,
isNumericLiteralNode,
assertNumericLiteralNode,
createBinaryNumericExpression,
createNumericArrayExpression,
cloneNumericLiteral,
};
import assert from 'node:assert';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
t,
createNumericLiteral,
isNumericLiteralNode,
assertNumericLiteralNode,
createBinaryNumericExpression,
createNumericArrayExpression,
cloneNumericLiteral,
} = require('../src/index.js');
async function runContract() {
// 1. types.numericLiteral creates a NumericLiteral AST node with the specified number value and type 'NumericLiteral'
const intNode = createNumericLiteral(42);
assert.strictEqual(intNode.type, 'NumericLiteral');
assert.strictEqual(intNode.value, 42);
const floatNode = createNumericLiteral(3.14159);
assert.strictEqual(floatNode.type, 'NumericLiteral');
assert.strictEqual(floatNode.value, 3.14159);
const zeroNode = t.numericLiteral(0);
assert.strictEqual(zeroNode.type, 'NumericLiteral');
assert.strictEqual(zeroNode.value, 0);
const negNode = t.numericLiteral(-250);
assert.strictEqual(negNode.type, 'NumericLiteral');
assert.strictEqual(negNode.value, -250);
// 2. types.numericLiteral throws a TypeError when called with a non-number argument
assert.throws(
() => createNumericLiteral('42'),
(err) => err instanceof TypeError || err.message.includes('expected type of number'),
'types.numericLiteral must throw when value is a string'
);
assert.throws(
() => createNumericLiteral(null),
(err) => err instanceof TypeError || err.message.includes('expected type of number'),
'types.numericLiteral must throw when value is null'
);
assert.throws(
() => createNumericLiteral(undefined),
(err) => err instanceof TypeError || err.message.includes('expected type of number'),
'types.numericLiteral must throw when value is undefined'
);
assert.throws(
() => createNumericLiteral(true),
(err) => err instanceof TypeError || err.message.includes('expected type of number'),
'types.numericLiteral must throw when value is boolean'
);
// 3. types.isNumericLiteral returns true for NumericLiteral nodes with optional value matching and false for other nodes
assert.strictEqual(isNumericLiteralNode(intNode), true);
assert.strictEqual(isNumericLiteralNode(intNode, { value: 42 }), true);
assert.strictEqual(isNumericLiteralNode(intNode, { value: 100 }), false);
const identNode = t.identifier('count');
assert.strictEqual(isNumericLiteralNode(identNode), false);
assert.strictEqual(isNumericLiteralNode(null), false);
assert.strictEqual(isNumericLiteralNode(undefined), false);
// 4. types.assertNumericLiteral succeeds for valid NumericLiteral nodes and throws an Error for non-NumericLiteral nodes
assertNumericLiteralNode(intNode);
assertNumericLiteralNode(intNode, { value: 42 });
assert.throws(
() => assertNumericLiteralNode(identNode),
(err) => err instanceof Error,
'assertNumericLiteral on non-NumericLiteral node must throw'
);
assert.throws(
() => assertNumericLiteralNode(intNode, { value: 999 }),
(err) => err instanceof Error,
'assertNumericLiteral with mismatching value option must throw'
);
// 5. NumericLiteral nodes created with types.numericLiteral integrate into compound AST structures like BinaryExpression and ArrayExpression
const binExpr = createBinaryNumericExpression('+', 10, 20);
assert.strictEqual(binExpr.type, 'BinaryExpression');
assert.strictEqual(binExpr.operator, '+');
assert.strictEqual(binExpr.left.type, 'NumericLiteral');
assert.strictEqual(binExpr.left.value, 10);
assert.strictEqual(binExpr.right.type, 'NumericLiteral');
assert.strictEqual(binExpr.right.value, 20);
const arrExpr = createNumericArrayExpression([1, 2, 3]);
assert.strictEqual(arrExpr.type, 'ArrayExpression');
assert.strictEqual(arrExpr.elements.length, 3);
assert.strictEqual(arrExpr.elements[0].type, 'NumericLiteral');
assert.strictEqual(arrExpr.elements[0].value, 1);
assert.strictEqual(arrExpr.elements[1].type, 'NumericLiteral');
assert.strictEqual(arrExpr.elements[1].value, 2);
assert.strictEqual(arrExpr.elements[2].type, 'NumericLiteral');
assert.strictEqual(arrExpr.elements[2].value, 3);
// 6. types.cloneNode produces an independent equivalent copy of a NumericLiteral node
const cloned = cloneNumericLiteral(intNode);
assert.notStrictEqual(cloned, intNode, 'cloned node should have separate object identity');
assert.strictEqual(cloned.type, 'NumericLiteral');
assert.strictEqual(cloned.value, 42);
assert.strictEqual(t.isNodesEquivalent(cloned, intNode), true);
console.log('All contract assertions passed successfully.');
}
runContract().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
오리진 시더
익명