206b0357d1
gates / gates (push) Successful in 27s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"go/ast"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// R-659 (v0.268.0) — the pieces are wired: the adapter records the hold through the WHOLE-copy walk
|
|
// (never the precondition copy again), and the held-event sink sends app_hold_no_whole_copy.
|
|
// An AST walk, not a substring (a commented-out call satisfies strings.Contains).
|
|
func TestR659_HoldAndEventAreWired(t *testing.T) {
|
|
_, f, _ := slice4CallLines(t)
|
|
var calls []string
|
|
for _, d := range f.Decls {
|
|
fn, ok := d.(*ast.FuncDecl)
|
|
if !ok || fn.Name.Name != "HoldAfterFailedUpdate" || fn.Recv == nil || fn.Body == nil {
|
|
continue
|
|
}
|
|
if st, ok := fn.Recv.List[0].Type.(*ast.StarExpr); !ok || st.X.(*ast.Ident).Name != "updateGuardsAdapter" {
|
|
continue
|
|
}
|
|
ast.Inspect(fn.Body, func(n ast.Node) bool {
|
|
if sel, ok := n.(*ast.SelectorExpr); ok {
|
|
calls = append(calls, sel.Sel.Name)
|
|
}
|
|
return true
|
|
})
|
|
}
|
|
body := strings.Join(calls, " ")
|
|
if !strings.Contains(body, "HoldAfterFailedUpdateWhole") {
|
|
t.Fatal("the adapter does not record the hold through HoldAfterFailedUpdateWhole — the precondition copy would be named again (R-659)")
|
|
}
|
|
if strings.Contains(body, "HoldAfterFailedUpdateHolding") {
|
|
t.Fatal("the adapter still calls HoldAfterFailedUpdateHolding with the precondition copy")
|
|
}
|
|
sends := false
|
|
ast.Inspect(mainBody(t), func(n ast.Node) bool {
|
|
if sel, ok := n.(*ast.SelectorExpr); ok && sel.Sel.Name == "NotifyAppHoldNoWholeCopy" {
|
|
sends = true
|
|
}
|
|
return true
|
|
})
|
|
if !sends {
|
|
t.Fatal("main never calls NotifyAppHoldNoWholeCopy — support would never be told")
|
|
}
|
|
}
|