test: cover web-runtime seeded PRNG, weighted pick, and seed define wiring

This commit is contained in:
pj committed 2026-06-01 15:10:04 +05:30
1 parent 6fc1c971c7
commit d4ffdce8f9
3 files changed
+123

No files matched your search

+22
View File
@@ -3,9 +3,31 @@ package testrun
import (
"os"
"path/filepath"
"strconv"
"testing"
)
func TestResolveSeed_UsesConfiguredWhenNonZero(t *testing.T) {
if got := resolveSeed(42); got != 42 {
t.Fatalf("got %d, want 42", got)
}
}
func TestResolveSeed_DerivesWhenZero(t *testing.T) {
if got := resolveSeed(0); got == 0 {
t.Fatal("expected a non-zero time-derived seed")
}
}
// TestSeedDefineFormatsAsDecimal guards the contract that Execute uses to put
// the seed into the web bundle: strconv.FormatInt base 10, which web-runtime
// folds to a 32-bit PRNG seed.
func TestSeedDefineFormatsAsDecimal(t *testing.T) {
if got := strconv.FormatInt(resolveSeed(8675309), 10); got != "8675309" {
t.Fatalf("got %q, want 8675309", got)
}
}
func TestResolveSpecAPIPath_FindsUpwardSibling(t *testing.T) {
root := t.TempDir()
apiPath := filepath.Join(root, "pkg", "spec", "src", "index.ts")