Files
lukaszraczylo e7479e9169 test(catalog): expand research to 10 tests per subcategory
Add 9 tests to research/web, research/whitepapers, and
research/codebase, bringing each subcategory from 1 test to 10.

Web tests extract data from inline HTML, headers, and URLs, and
answer protocol scenarios for HTTP status codes, CORS, DNS, and
canonicalization. Every fixture stays inline; no test makes a live
web call.

Whitepaper tests each pair a 120 to 180 word, technically accurate
excerpt with numeric or JSON extraction questions. Topics cover
product quantization, Bloom filters, TF-IDF, recall@k, LSM-tree
write amplification, Raft quorum sizing, B-tree capacity, the CAP
theorem, and attention scaling. Every derived constant carries a
ground-truth comment and a unit test that recomputes the value with
an independent formula.

Codebase tests trace a Python function and a TypeScript function to
exact output, then reason over an inline diff, a data race, dead
code, Big-O complexity, an import cycle, a generic return type, and
a git-bisect scenario. The Python trace test runs the same source
through python3 when available and skips otherwise; the TypeScript
trace test cross-checks its hand-derivation against an equivalent Go
function.

New package-level helpers use a wp or code prefix to avoid name
collisions with sibling category authors sharing this package. Test
IDs keep the paper, web, and code prefixes already established by
the existing catalog entries. New tests omit MaxTokens so the runner
falls back to its default, per the catalog's authoring rules.

catalog_test.go's exact-map assertion now fails as expected, since
it still lists only the original 17-test catalog; that assertion is
owned centrally and is not touched here.
2026-08-17 01:51:11 +01:00

76 lines
2.1 KiB
Go

package tests
import (
"github.com/lukaszraczylo/llm-testbench/internal/eval"
"github.com/lukaszraczylo/llm-testbench/internal/testkit"
)
func registerCodebaseTests(r *testkit.Registry) {
r.Register(codeTraceGoTest())
r.Register(codeTracePythonTest())
r.Register(codeTraceTSTest())
r.Register(codeBugLineDiffTest())
r.Register(codeRaceVariableTest())
r.Register(codeDeadFunctionsTest())
r.Register(codeBigODedupTest())
r.Register(codeImportCycleTest())
r.Register(codeGenericReturnTypeTest())
r.Register(codeCommitBisectTest())
}
// mix is the traced function for codeTraceGoTest: deterministic bit
// manipulation plus recursion. It is called directly (not re-implemented)
// to derive codeTraceGoWant, and codebase_test.go calls it again with the
// same input to ground that value, per PLAN.md's instruction that this
// test's ground truth be established by running the same function.
func mix(n int, depth int) int {
if depth == 0 {
return n
}
if n%2 == 0 {
n = n >> 1
} else {
n = (n << 1) ^ 0x2A
}
return mix(n, depth-1) + depth
}
// codeTraceGoWant is mix(37, 4), computed by running mix itself.
//
// ground truth: mix(37,4): 37 is odd -> n=(37<<1)^0x2A=96, return
// mix(96,3)+4. 96 is even -> n=48, return mix(48,2)+3. 48 is even -> n=24,
// return mix(24,1)+2. 24 is even -> n=12, return mix(12,0)+1. depth=0 ->
// return 12. Unwinding: 12+1=13, 13+2=15, 15+3=18, 18+4=22.
var codeTraceGoWant = mix(37, 4)
func codeTraceGoTest() testkit.Test {
prompt := `Here is a Go function:
` + "```go" + `
func mix(n int, depth int) int {
if depth == 0 {
return n
}
if n%2 == 0 {
n = n >> 1
} else {
n = (n << 1) ^ 0x2A
}
return mix(n, depth-1) + depth
}
` + "```" + `
What is the exact value of mix(37, 4)? Respond with only the number,
nothing else.`
return testkit.Test{
ID: "code-trace-go",
Category: "research",
Subcategory: "codebase",
Description: "Trace a recursive Go function combining bit manipulation and recursion to an exact numeric result.",
Prompt: prompt,
MaxTokens: 200,
Eval: eval.Numeric(eval.ExtractLastNumber[int], codeTraceGoWant, 0),
}
}