a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
53 lines
1.6 KiB
Go
53 lines
1.6 KiB
Go
package resolver
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/zzet/gortex/internal/graph"
|
|
)
|
|
|
|
func pascalFileNode(g graph.Store, path, workspace string) {
|
|
g.AddNode(&graph.Node{
|
|
ID: path, Kind: graph.KindFile, Name: path, FilePath: path,
|
|
Language: "pascal", WorkspaceID: workspace,
|
|
})
|
|
}
|
|
|
|
func pascalFormEdge(g graph.Store, from, to string) *graph.Edge {
|
|
for _, e := range g.GetOutEdges(from) {
|
|
if e.To == to && e.Meta != nil {
|
|
if v, _ := e.Meta["via"].(string); v == pascalFormVia {
|
|
return e
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// TestPascalFormSynth is the C1 named test: a unit and its same-dir
|
|
// same-basename form pair, the pairing rides a provenance tier, and a basename
|
|
// shared across workspaces (repos) does not cross-pair.
|
|
func TestPascalFormSynth(t *testing.T) {
|
|
g := graph.New()
|
|
pascalFileNode(g, "ui/Main.pas", "app")
|
|
pascalFileNode(g, "ui/Main.dfm", "app")
|
|
pascalFileNode(g, "ui/Other.pas", "app") // no form → no pair
|
|
// Same basename, different workspace — must NOT pair.
|
|
pascalFileNode(g, "lib/Main.pas", "vendor")
|
|
pascalFileNode(g, "other/Main.dfm", "vendor")
|
|
|
|
n := ResolvePascalForms(g)
|
|
assert.Equal(t, 1, n, "exactly one same-dir same-workspace pair")
|
|
|
|
e := pascalFormEdge(g, "ui/Main.pas", "ui/Main.dfm")
|
|
require.NotNil(t, e, "unit should reference its form")
|
|
assert.Equal(t, graph.EdgeReferences, e.Kind)
|
|
assert.Equal(t, graph.OriginASTInferred, e.Origin, "pairing must ride a tier")
|
|
assert.Equal(t, SynthPascalForm, e.Meta[MetaSynthesizedBy])
|
|
|
|
assert.Nil(t, pascalFormEdge(g, "ui/Other.pas", "ui/Other.dfm"))
|
|
}
|