mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
- tests/harness/library-int.test.ts: all 16 reference-corpus cases as library fixtures on both emissions — send/sendU64 are profile-mapped exports with i64/u64 params, PROVE cases pin every crossed value against the Node oracle (the test process runs the same case source), the counter loop crosses 0..9 in order, REFUSE cases name obligation, slot path, and evidence - int-returns fixture: i64/u64 returns cross as real int64_t/uint64_t (9007199254740991, -0 as 0, -7 % 3 as -1, ToUint32 max on a u64 slot) - int-trap fixture: inbound integers past 2^53-1 deliver the structured SC4012 host-contract trap with profile teaching/remediation; in-range extremes convert exactly - Sidecar slots: integer_slots attestation in declaration order, declared slots spelled i64 (V10 bijection validated), unproven writes refused by slot path (Msg.count, helpers.clampIdx.return), unresolvable and non-number declarations refused SC4009, teachings ride SC4022 as attributed notes - Layer-1 differential: no Layer-1 representation exists (trivially unobservable); pinned consequence — f64-declared vs i64-declared builds cross byte-identical values - Integer-declared helpers join libRoots so their attestation covers a compiled body, never a dead-stripped vacuity
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
/* Generic driver for the ask-4 conformance corpus (library-int.test.ts):
|
||
* every corpus fixture records what crossed its declared integer slot in
|
||
* a module array; the probe replays the host side — optionally feeding
|
||
* the case's parameter function (compiled with -DHAS_F) the argv values —
|
||
* and prints each crossed value on its own line with %.17g (exact for
|
||
* every integer within ±(2^53 − 1)). The suite compares the lines against
|
||
* the Node oracle's numbers computed from the same case source. */
|
||
#include <setjmp.h>
|
||
#include <stddef.h>
|
||
#include <stdint.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
|
||
extern void kc_init(void);
|
||
extern void kc_set_panic_sink(void (*fn)(void *, const uint8_t *, size_t, uint64_t), void *ctx);
|
||
extern double kc_count(void);
|
||
extern double kc_at(double i);
|
||
#ifdef HAS_F
|
||
extern void kc_f(double a);
|
||
#endif
|
||
|
||
static jmp_buf trap_jmp;
|
||
|
||
static void sink(void *ctx, const uint8_t *msg, size_t len, uint64_t addr) {
|
||
(void)ctx;
|
||
(void)addr;
|
||
printf("sink: %.*s\n", (int)len, (const char *)msg);
|
||
longjmp(trap_jmp, 1);
|
||
}
|
||
|
||
int main(int argc, char **argv) {
|
||
(void)argc;
|
||
(void)argv;
|
||
kc_set_panic_sink(sink, NULL);
|
||
if (setjmp(trap_jmp) != 0) {
|
||
printf("trapped\n");
|
||
return 1;
|
||
}
|
||
kc_init();
|
||
#ifdef HAS_F
|
||
for (int i = 1; i < argc; i++) kc_f(strtod(argv[i], NULL));
|
||
#endif
|
||
double n = kc_count();
|
||
for (double i = 0; i < n; i++) printf("%.17g\n", kc_at(i));
|
||
return 0;
|
||
}
|