Files
ziran/tests/api_discovery.sh
T
waozi 4838ce9b2f Improve runtimes, add an experimental direct backend, and prune Ziran tests
Prepare short portable helpers and scalar record reads, improve JSON SIMD scanning, expose one-line execution, and publish qualified Alpha benchmark artifacts. Add the experimental verified lowered execution, serialization and Linux x86-64 backend with source maps.

Physically remove 263 redundant test entry points and unused helpers, migrate retained helpers to Ziran, and execute the full retained suite without sharding. Allow ignored backup state for the managed physical Alpha workflow.

Local validation: all 268 retained tests passed across the full run and corrected targeted reruns; bootstrap matches. Current assembly verifier, x86-64, executor and serializer tests passed. Website examples and all 4661 local links passed. Six Alpha JSON/text workloads retain verified artifacts, raw samples and explicit unsupported Wasm diagnostics. The mobile sub-500 ns target remains pending.
2026-11-11 18:46:34 -03:00

60 lines
1.6 KiB
Bash

#!/bin/sh
set -eu
ziran=${1:?pass the ziran command}
repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
mkdir -p "$repo/build/tests"
work=$(mktemp -d "$repo/build/tests/api-discovery-XXXXXX")
trap 'rm -rf "$work"' EXIT HUP INT TERM
cat > "$work/library.zi" <<'ZI'
Choice :: struct {
value: s32;
}
Visible :: (value: s32 = 42) -> Choice {
result: Choice
result.value = value
return result
}
#scope_module
Hidden :: () -> s32 { return 9 }
HIDDEN_CONSTANT :: 3;
hidden_global: s32 = 4;
#scope_export
Again :: () -> s32 { return Hidden() }
PUBLIC_CONSTANT :: 5;
public_global: s32 = 6;
host_api :: #system_library "host_api";
CallHost :: (value: s32) -> s32 #foreign host_api;
Handler :: #type (value: s32) -> bool;
FEATURE :: #defined(HAS_EXTRA)
#if FEATURE {
Extra :: () -> s32 { return 1 }
}
ZI
cat > "$work/main.zi" <<'ZI'
#import "library"
Answer :: () -> s32 {
value: Choice = Visible(42)
return value.value + Again() - 9
}
ZI
"$ziran" api --json --root "$work" "$work/main.zi" > "$work/source.json"
"$ziran" api --json --define HAS_EXTRA --root "$work" \
"$work/main.zi" > "$work/defined.json"
"$ziran" api --root "$work" "$work/main.zi" > "$work/source.txt"
"$ziran" ir --root "$work" -o "$work/ir" "$work/main.zi"
"$ziran" api --json --root "$work/ir" "$work/ir/main.zir" > "$work/saved.json"
"$ziran" run --target=c --root "$repo/tests" "$repo/tests/api_assertions.zi" -- "$ziran" "$work" discovery
if "$ziran" api --root "$work" "$work/missing.zi" > "$work/out" 2> "$work/err"; then
echo 'api accepted a missing source file' >&2
exit 1
fi