CodeSampleX

Ejemplo

js-sys 0.3.107: js_sys

Muestra verificada para cargo js-sys 0.3.107: js_sys. El contrato se ejecutó en rust 1 · linux alpine/x64 · docker y pasó: js_sys::Number exposes IEEE 754…

sha256:6b5aad08b2543924cd7370bb81ee5fe95789de07e80bcccac727ef9bffa6659c

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 rust 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-23

Caso

HOW
Objetivo
verify js_sys in pkg:cargo/js-sys@0.3.107
Paquetes
Símbolos
  • js_sys
Creado
2026-11-23T14:25:27Z

Contrato

  1. js_sys::Number exposes IEEE 754 safe integer boundaries (MAX_SAFE_INTEGER == 2^53 - 1, MIN_SAFE_INTEGER == -(2^53 - 1)) and float constants (EPSILON, MAX_VALUE, subnormal MIN_VALUE == 5e-324, NAN, POSITIVE_INFINITY, NEGATIVE_INFINITY)
  2. Number::try_from rejects integers outside the safe 53-bit range for i64, u64, i128, and u128 (including +/-2^53 boundaries and type MIN/MAX) with js_sys::TryFromIntError
  3. js_sys::TryFromIntError implements Copy, Clone, PartialEq, Eq, Debug, Display ('out of range integral type conversion attempted'), and std::error::Error
  4. js_sys::Base64Alphabet (Base64, Base64Url) and js_sys::Base64LastChunkHandling (Loose, Strict, StopBeforePartial) expose distinct variants with Copy, Clone, PartialEq, 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 = "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 = "sample-js-sys"
version = "1.0.0"
dependencies = [
 "js-sys",
]

[[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 = "sample-js-sys"
version = "1.0.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 js_sys in pkg:cargo/js-sys@0.3.107
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/js-sys@0.3.107
Demonstrate these symbols/APIs:
  - js_sys

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:e8b3ecd8a4ec662d4ed0553c9f809c5c32b04339a68d41d958cacf39e2ac21ce","contract":["js_sys::Number exposes IEEE 754 safe integer boundaries (MAX_SAFE_INTEGER == 2^53 - 1, MIN_SAFE_INTEGER == -(2^53 - 1)) and float constants (EPSILON, MAX_VALUE, subnormal MIN_VALUE == 5e-324, NAN, POSITIVE_INFINITY, NEGATIVE_INFINITY)","Number::try_from rejects integers outside the safe 53-bit range for i64, u64, i128, and u128 (including +/-2^53 boundaries and type MIN/MAX) with js_sys::TryFromIntError","js_sys::TryFromIntError implements Copy, Clone, PartialEq, Eq, Debug, Display ('out of range integral type conversion attempted'), and std::error::Error","js_sys::Base64Alphabet (Base64, Base64Url) and js_sys::Base64LastChunkHandling (Loose, Strict, StopBeforePartial) expose distinct variants with Copy, Clone, PartialEq, Eq, and Debug"],"goal":"verify js_sys in pkg:cargo/js-sys@0.3.107","kind":"HOW","packages":["pkg:cargo/js-sys@0.3.107"],"schemaVersion":1,"symbols":["js_sys"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","language":"rust","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","symbols":["js_sys"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify js_sys in pkg:cargo/js-sys@0.3.107",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/js-sys@0.3.107"
  ],
  "symbols": [
    "js_sys"
  ]
}
src/lib.rs
//! Minimal clean-room sample verifying `js_sys` crate APIs in `js-sys@0.3.107`.

pub use js_sys;
test/contract.rs
use core::convert::TryFrom;
use js_sys::{Base64Alphabet, Base64LastChunkHandling, Number, TryFromIntError};

fn main() {
    // 1. IEEE 754 safe integer boundaries and float constants on js_sys::Number
    let max_safe = ((1u64 << 53) - 1) as f64;
    assert_eq!(Number::MAX_SAFE_INTEGER, 9_007_199_254_740_991.0);
    assert_eq!(Number::MAX_SAFE_INTEGER, max_safe);
    assert_eq!(Number::MIN_SAFE_INTEGER, -9_007_199_254_740_991.0);
    assert_eq!(Number::MIN_SAFE_INTEGER, -max_safe);

    assert_eq!(Number::EPSILON, f64::EPSILON);
    assert_eq!(Number::MAX_VALUE, f64::MAX);
    assert_eq!(Number::MIN_VALUE, 5e-324);
    assert!(Number::MIN_VALUE.is_subnormal());
    assert!(Number::MIN_VALUE > 0.0 && Number::MIN_VALUE < f64::MIN_POSITIVE);

    assert!(Number::NAN.is_nan());
    assert_eq!(Number::POSITIVE_INFINITY, f64::INFINITY);
    assert_eq!(Number::NEGATIVE_INFINITY, f64::NEG_INFINITY);

    // 2. Number::try_from rejects integers outside the safe 53-bit range
    let boundary_pos_i64: i64 = 1i64 << 53;
    let boundary_neg_i64: i64 = -(1i64 << 53);
    let boundary_pos_u64: u64 = 1u64 << 53;
    let boundary_pos_i128: i128 = 1i128 << 53;
    let boundary_neg_i128: i128 = -(1i128 << 53);
    let boundary_pos_u128: u128 = 1u128 << 53;

    let err_i64_boundary: TryFromIntError = Number::try_from(boundary_pos_i64).unwrap_err();
    assert!(Number::try_from(boundary_neg_i64).is_err());
    assert!(Number::try_from(i64::MAX).is_err());
    assert!(Number::try_from(i64::MIN).is_err());

    assert!(Number::try_from(boundary_pos_u64).is_err());
    assert!(Number::try_from(u64::MAX).is_err());

    assert!(Number::try_from(boundary_pos_i128).is_err());
    assert!(Number::try_from(boundary_neg_i128).is_err());
    assert!(Number::try_from(i128::MAX).is_err());
    assert!(Number::try_from(i128::MIN).is_err());

    assert!(Number::try_from(boundary_pos_u128).is_err());
    assert!(Number::try_from(u128::MAX).is_err());

    // 3. TryFromIntError trait implementations
    let err_copied = err_i64_boundary;
    let err_cloned = err_i64_boundary.clone();
    assert_eq!(err_i64_boundary, err_copied);
    assert_eq!(err_i64_boundary, err_cloned);
    assert_eq!(
        err_i64_boundary.to_string(),
        "out of range integral type conversion attempted"
    );
    assert_eq!(format!("{err_i64_boundary:?}"), "TryFromIntError(())");
    let dyn_err: &dyn std::error::Error = &err_i64_boundary;
    assert_eq!(
        dyn_err.to_string(),
        "out of range integral type conversion attempted"
    );
    assert!(dyn_err.source().is_none());

    // 4. Base64Alphabet and Base64LastChunkHandling option enums
    let std_alphabet = Base64Alphabet::Base64;
    let url_alphabet = Base64Alphabet::Base64Url;
    assert_eq!(std_alphabet, std_alphabet.clone());
    assert_ne!(std_alphabet, url_alphabet);
    assert_eq!(format!("{std_alphabet:?}"), "Base64");
    assert_eq!(format!("{url_alphabet:?}"), "Base64Url");

    let modes = [
        Base64LastChunkHandling::Loose,
        Base64LastChunkHandling::Strict,
        Base64LastChunkHandling::StopBeforePartial,
    ];
    assert_ne!(modes[0], modes[1]);
    assert_ne!(modes[1], modes[2]);
    assert_ne!(modes[0], modes[2]);
    assert_eq!(format!("{:?}", modes[0]), "Loose");
    assert_eq!(format!("{:?}", modes[1]), "Strict");
    assert_eq!(format!("{:?}", modes[2]), "StopBeforePartial");

    println!("js-sys 0.3.107 contract passed");
}

Seeder de origen

anónimo