CodeSampleX

Exemple

luxon 3.6.1: IANAZone

Échantillon vérifié pour npm luxon 3.6.1: IANAZone. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.

sha256:c127b9fe62c451581d6a6c2cc5b5cca89ce7a1d8cd6c148ddedc95c249c82a94

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré linux 24 · ubuntu · glibc 2.39 x64 npm

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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

Cas

HOW
Objectif
verify luxon.IANAZone in pkg:npm/luxon@3.6.1
Paquets
Symboles
  • luxon.IANAZone
Créé
2026-08-23T06:17:54Z

Contrat

  1. IANAZone.create creates valid IANAZone instances for valid IANA time zone identifiers
  2. IANAZone.isValidZone returns true for valid IANA zone identifiers and false for invalid zone identifiers
  3. IANAZone.create returns an invalid IANAZone instance with isValid false for invalid zone names without throwing
  4. IANAZone instances correctly compute UTC offsets and format offsets
  5. IANAZone instances with matching zone names are considered equal via equals method

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code source

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 luxon.IANAZone in pkg:npm/luxon@3.6.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/luxon@3.6.1
Demonstrate these symbols/APIs:
  - luxon.IANAZone

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:7e21cb5ae6d488e04181c13c6b02dc3eb4a7c511b94ead94a3dcb830de0ec20e","contract":["IANAZone.create creates valid IANAZone instances for valid IANA time zone identifiers","IANAZone.isValidZone returns true for valid IANA zone identifiers and false for invalid zone identifiers","IANAZone.create returns an invalid IANAZone instance with isValid false for invalid zone names without throwing","IANAZone instances correctly compute UTC offsets and format offsets","IANAZone instances with matching zone names are considered equal via equals method"],"goal":"verify luxon.IANAZone in pkg:npm/luxon@3.6.1","kind":"HOW","packages":["pkg:npm/luxon@3.6.1"],"schemaVersion":1,"symbols":["luxon.IANAZone"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/luxon@3.6.1"],"schemaVersion":1,"subject":"pkg:npm/luxon@3.6.1","symbols":["luxon.IANAZone"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-luxon-ianazone",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-luxon-ianazone",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "luxon": "3.6.1"
      }
    },
    "node_modules/luxon": {
      "version": "3.6.1",
      "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.6.1.tgz",
      "integrity": "sha512-tJLxrKJhO2ukZ5z0gyjY1zPh3Rh88Ej9P7jNrZiHMUXHae1yvI2imgOZtL1TO8TW6biMMKfTtAOoEJANgtWBMQ==",
      "license": "MIT",
      "engines": {
        "node": ">=12"
      }
    }
  }
}
package.json
{
  "name": "sample-luxon-ianazone",
  "version": "1.0.0",
  "private": true,
  "description": "verify luxon.IANAZone in pkg:npm/luxon@3.6.1",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "luxon": "3.6.1"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify luxon.IANAZone in pkg:npm/luxon@3.6.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/luxon@3.6.1"
  ],
  "symbols": [
    "luxon.IANAZone"
  ]
}
src/index.js
'use strict';

const { IANAZone } = require('luxon');

function createZone(zoneName) {
  return IANAZone.create(zoneName);
}

function isZoneValid(zoneName) {
  return IANAZone.isValidZone(zoneName);
}

function getZoneOffset(zoneName, timestampMs) {
  const zone = IANAZone.create(zoneName);
  if (!zone.isValid) {
    return null;
  }
  return zone.offset(timestampMs);
}

module.exports = {
  IANAZone,
  createZone,
  isZoneValid,
  getZoneOffset
};
test/contract.js
'use strict';

const assert = require('node:assert');
const { IANAZone } = require('luxon');
const { createZone, isZoneValid, getZoneOffset } = require('../src/index.js');

async function run() {
  // 1. IANAZone.create creates valid IANAZone instances for valid IANA time zone identifiers
  const ny = IANAZone.create('America/New_York');
  assert.strictEqual(ny.isValid, true, 'ny zone must be valid');
  assert.strictEqual(ny.name, 'America/New_York', 'ny zone name must match');
  assert.strictEqual(ny.type, 'iana', 'ny zone type must be iana');
  assert.strictEqual(ny.isUniversal, false, 'ny zone isUniversal must be false');

  const tokyo = IANAZone.create('Asia/Tokyo');
  assert.strictEqual(tokyo.isValid, true, 'tokyo zone must be valid');
  assert.strictEqual(tokyo.name, 'Asia/Tokyo', 'tokyo zone name must match');
  assert.strictEqual(tokyo.type, 'iana', 'tokyo zone type must be iana');
  assert.strictEqual(tokyo.isUniversal, false, 'tokyo zone isUniversal must be false');

  // 2. IANAZone.isValidZone returns true for valid IANA zone identifiers and false for invalid zone identifiers
  assert.strictEqual(IANAZone.isValidZone('America/New_York'), true, 'America/New_York must be valid');
  assert.strictEqual(IANAZone.isValidZone('Asia/Tokyo'), true, 'Asia/Tokyo must be valid');
  assert.strictEqual(IANAZone.isValidZone('UTC'), true, 'UTC must be valid');
  assert.strictEqual(IANAZone.isValidZone('Europe/Paris'), true, 'Europe/Paris must be valid');
  assert.strictEqual(IANAZone.isValidZone('Invalid/NonExistent_Zone'), false, 'Invalid zone name must return false');
  assert.strictEqual(IANAZone.isValidZone(''), false, 'Empty string must return false');

  assert.strictEqual(IANAZone.isValidSpecifier('America/New_York'), true, 'America/New_York must be valid specifier');
  assert.strictEqual(IANAZone.isValidSpecifier(123), false, 'Number must not be valid specifier');

  // 3. IANAZone.create returns an invalid IANAZone instance with isValid false for invalid zone names without throwing
  const invalid = IANAZone.create('Invalid/NonExistent_Zone');
  assert.strictEqual(invalid.isValid, false, 'invalid zone isValid must be false');
  assert.strictEqual(invalid.name, 'Invalid/NonExistent_Zone', 'invalid zone name must match input');
  assert.strictEqual(invalid.type, 'iana', 'invalid zone type must still be iana');
  assert.strictEqual(Number.isNaN(invalid.offset(0)), true, 'invalid zone offset should be NaN');

  // 4. IANAZone instances correctly compute UTC offsets and format offsets
  const utc = IANAZone.create('UTC');
  assert.strictEqual(utc.isValid, true, 'UTC zone must be valid');
  assert.strictEqual(utc.offset(0), 0, 'UTC offset at timestamp 0 must be 0');
  assert.strictEqual(utc.formatOffset(0, 'narrow'), '+0', 'UTC formatOffset narrow must be +0');

  // Asia/Tokyo has fixed UTC+9 offset (540 minutes)
  assert.strictEqual(tokyo.offset(0), 540, 'Tokyo offset at timestamp 0 must be 540 minutes');
  assert.strictEqual(tokyo.formatOffset(0, 'short'), '+09:00', 'Tokyo formatOffset short must be +09:00');
  assert.strictEqual(tokyo.formatOffset(0, 'narrow'), '+9', 'Tokyo formatOffset narrow must be +9');

  // 5. IANAZone instances with matching zone names are considered equal via equals method
  const ny2 = IANAZone.create('America/New_York');
  assert.strictEqual(ny.equals(ny2), true, 'Same IANAZone instances must be equal');
  assert.strictEqual(ny.equals(tokyo), false, 'Different IANAZone instances must not be equal');
  assert.strictEqual(ny.equals(invalid), false, 'Valid and invalid zones must not be equal');

  // 6. Helper functions in src/index.js
  const helperZone = createZone('Asia/Tokyo');
  assert.strictEqual(helperZone.isValid, true, 'helper createZone should return valid zone');
  assert.strictEqual(isZoneValid('Asia/Tokyo'), true, 'helper isZoneValid should return true for valid zone');
  assert.strictEqual(isZoneValid('Invalid/Zone'), false, 'helper isZoneValid should return false for invalid zone');
  assert.strictEqual(getZoneOffset('Asia/Tokyo', 0), 540, 'helper getZoneOffset should return 540 for Tokyo');
  assert.strictEqual(getZoneOffset('Invalid/Zone', 0), null, 'helper getZoneOffset should return null for invalid zone');

  console.log('Contract tests passed successfully.');
}

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

Seeder d'origine

anonyme