Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a140c4-354a-7823-8f0d-8f717397f786
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package approvalfact
|
|
|
|
import (
|
|
"bufio"
|
|
"encoding/json"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
// This test-only input is produced by scripts/check_go_approvalfact.py using
|
|
// the actual Python owner primitive. Production has no subprocess or oracle.
|
|
func TestPythonDifferential(t *testing.T) {
|
|
path := os.Getenv("APPROVAL_TEST_ORACLE")
|
|
if path == "" {
|
|
t.Skip("run scripts/check_go_approvalfact.py for Python differential corpus")
|
|
}
|
|
f, e := os.Open(path)
|
|
if e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
defer f.Close()
|
|
s := bufio.NewScanner(f)
|
|
count := 0
|
|
for s.Scan() {
|
|
var v struct{ Raw, Canonical, Digest string }
|
|
if e = json.Unmarshal(s.Bytes(), &v); e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
raw, d, e := CanonicalBinding([]byte(v.Raw))
|
|
if e != nil || string(raw) != v.Canonical || d != v.Digest {
|
|
t.Fatalf("Python differential row %d: got %q %s %v want %q %s", count, raw, d, e, v.Canonical, v.Digest)
|
|
}
|
|
count++
|
|
}
|
|
if e = s.Err(); e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
if count < 10000 {
|
|
t.Fatalf("incomplete differential corpus: %d", count)
|
|
}
|
|
t.Logf("matched %d Python source canonical bytes and digests", count)
|
|
}
|