CodeSampleX

Ejemplo

js-sys 0.3.107

Muestra verificada para cargo js-sys 0.3.107. El contrato se ejecutó en rust 1 · linux alpine/x64 · docker y pasó: Boolean::TRUE and Boolean::FALSE construct…

sha256:cbc217da1a25b18bc79bfb23f1affdf2e11fad1c563ee3e8bbd3d3fc439819a6

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux · alpine · musl x64 cargo

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b…
2026-11-22

Caso

HOW
Objetivo
verify pkg:cargo/js-sys@0.3.107
Paquetes
Creado
2026-11-22T21:25:03Z

Contrato

  1. Boolean::TRUE and Boolean::FALSE construct and drop cleanly as const handles
  2. Number::MAX_SAFE_INTEGER and Number::MIN_SAFE_INTEGER match IEEE-754 53-bit integer limits
  3. Number::EPSILON, MAX_VALUE, MIN_VALUE, NAN, POSITIVE_INFINITY, and NEGATIVE_INFINITY match IEEE-754 f64 constants
  4. Number::try_from rejects i64, u64, i128, and u128 values outside [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER] with TryFromIntError
  5. TryFromIntError implements Copy, Eq, Debug, Display, and std::error::Error
  6. Intl::SupportedValuesKey and Intl::LocaleMatcher expose typed enum variants implementing Copy, Eq, and Debug

Archivos

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.rs

Descargar el artefacto de código fuente (tar.gz)

Código fuente

Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4

[[package]]
name = "bumpalo"
version = "3.20.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"

[[package]]
name = "cfg-if"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"

[[package]]
name = "futures-core"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"

[[package]]
name = "futures-task"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"

[[package]]
name = "futures-util"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
dependencies = [
 "futures-core",
 "futures-task",
 "pin-project-lite",
 "slab",
]

[[package]]
name = "js-sys"
version = "0.3.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a"
dependencies = [
 "cfg-if",
 "futures-util",
 "wasm-bindgen",
]

[[package]]
name = "js-sys-sample"
version = "0.1.0"
dependencies = [
 "js-sys",
]

[[package]]
name = "pin-project-lite"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c938015719552d665fd0553b90d96cd7ff58e83e4c061ca99e6bb78865a72752"

[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
 "unicode-ident",
]

[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
 "proc-macro2",
]

[[package]]
name = "rustversion"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"

[[package]]
name = "slab"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"

[[package]]
name = "syn"
version = "3.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
dependencies = [
 "proc-macro2",
 "quote",
 "unicode-ident",
]

[[package]]
name = "unicode-ident"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"

[[package]]
name = "wasm-bindgen"
version = "0.2.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c"
dependencies = [
 "cfg-if",
 "rustversion",
 "wasm-bindgen-macro",
 "wasm-bindgen-shared",
]

[[package]]
name = "wasm-bindgen-macro"
version = "0.2.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9"
dependencies = [
 "quote",
 "wasm-bindgen-macro-support",
]

[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a"
dependencies = [
 "bumpalo",
 "proc-macro2",
 "quote",
 "syn",
 "wasm-bindgen-shared",
]

[[package]]
name = "wasm-bindgen-shared"
version = "0.2.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e"
dependencies = [
 "unicode-ident",
]
Cargo.toml
[package]
name = "js-sys-sample"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
js-sys = "=0.3.107"

[[bin]]
name = "contract"
path = "test/contract.rs"
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:cargo/js-sys@0.3.107
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/js-sys@0.3.107
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:9b974c5789abe17aea93db6f5e879b4c71f9b0ee2d3f28b67250edbd1a34da4f","contract":["Boolean::TRUE and Boolean::FALSE construct and drop cleanly as const handles","Number::MAX_SAFE_INTEGER and Number::MIN_SAFE_INTEGER match IEEE-754 53-bit integer limits","Number::EPSILON, MAX_VALUE, MIN_VALUE, NAN, POSITIVE_INFINITY, and NEGATIVE_INFINITY match IEEE-754 f64 constants","Number::try_from rejects i64, u64, i128, and u128 values outside [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER] with TryFromIntError","TryFromIntError implements Copy, Eq, Debug, Display, and std::error::Error","Intl::SupportedValuesKey and Intl::LocaleMatcher expose typed enum variants implementing Copy, Eq, and Debug"],"goal":"verify pkg:cargo/js-sys@0.3.107","kind":"HOW","packages":["pkg:cargo/js-sys@0.3.107"],"schemaVersion":1},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/js-sys@0.3.107"],"schemaVersion":1,"subject":"pkg:cargo/js-sys@0.3.107","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/js-sys@0.3.107",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/js-sys@0.3.107"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/lib.rs
pub use js_sys;
test/contract.rs
use core::convert::TryFrom;
use js_sys::Intl::{LocaleMatcher, SupportedValuesKey};
use js_sys::{Boolean, Number, TryFromIntError};

fn main() {
    // 1. Boolean::TRUE and Boolean::FALSE are usable const handles without JS runtime calls
    let _true_handle: Boolean = Boolean::TRUE;
    let _false_handle: Boolean = Boolean::FALSE;

    // 2. Number safe integer bounds match IEEE-754 53-bit integer limits
    let max_safe_u64 = (1u64 << 53) - 1;
    assert_eq!(Number::MAX_SAFE_INTEGER, 9007199254740991.0);
    assert_eq!(Number::MAX_SAFE_INTEGER, max_safe_u64 as f64);
    assert_eq!(Number::MIN_SAFE_INTEGER, -9007199254740991.0);
    assert_eq!(Number::MIN_SAFE_INTEGER, -(max_safe_u64 as f64));

    // 3. Number floating-point precision and special value constants match IEEE-754 f64
    assert_eq!(Number::EPSILON, f64::EPSILON);
    assert_eq!(Number::MAX_VALUE, f64::MAX);
    assert_eq!(Number::MIN_VALUE, f64::from_bits(1));
    assert_eq!(Number::MIN_VALUE, 5E-324);
    assert!(Number::NAN.is_nan());
    assert_eq!(Number::POSITIVE_INFINITY, f64::INFINITY);
    assert_eq!(Number::NEGATIVE_INFINITY, f64::NEG_INFINITY);

    // 4. Number::try_from rejects integers outside [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER]
    let over_max_i64: i64 = 1i64 << 53;
    let under_min_i64: i64 = -(1i64 << 53);
    let over_max_u64: u64 = 1u64 << 53;
    let over_max_i128: i128 = 1i128 << 53;
    let under_min_i128: i128 = -(1i128 << 53);
    let over_max_u128: u128 = 1u128 << 53;

    assert!(Number::try_from(over_max_i64).is_err());
    assert!(Number::try_from(under_min_i64).is_err());
    assert!(Number::try_from(i64::MAX).is_err());
    assert!(Number::try_from(i64::MIN).is_err());
    assert!(Number::try_from(over_max_u64).is_err());
    assert!(Number::try_from(u64::MAX).is_err());
    assert!(Number::try_from(over_max_i128).is_err());
    assert!(Number::try_from(under_min_i128).is_err());
    assert!(Number::try_from(i128::MAX).is_err());
    assert!(Number::try_from(i128::MIN).is_err());
    assert!(Number::try_from(over_max_u128).is_err());
    assert!(Number::try_from(u128::MAX).is_err());

    // 5. TryFromIntError implements Copy, Eq, Debug, Display, and std::error::Error
    let err: TryFromIntError = Number::try_from(over_max_i64).unwrap_err();
    let err_copy = err;
    assert_eq!(err, err_copy);
    assert_eq!(format!("{err:?}"), "TryFromIntError(())");
    assert_eq!(format!("{err}"), "out of range integral type conversion attempted");
    let dyn_err: &dyn std::error::Error = &err;
    assert_eq!(dyn_err.to_string(), "out of range integral type conversion attempted");

    // 6. Intl enums implement Copy, Eq, and Debug for typed configuration variants
    let key = SupportedValuesKey::TimeZone;
    let key_copy = key;
    assert_eq!(key, key_copy);
    assert_ne!(SupportedValuesKey::Calendar, SupportedValuesKey::TimeZone);
    assert_eq!(format!("{key:?}"), "TimeZone");
    let matcher = LocaleMatcher::BestFit;
    assert_ne!(matcher, LocaleMatcher::Lookup);
    assert_eq!(format!("{matcher:?}"), "BestFit");
}

Seeder de origen

anónimo