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
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package resolver
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/zzet/gortex/internal/graph"
|
|
)
|
|
|
|
// A method-level EdgeOverrides emitted by the extractor for an
|
|
// `impl Trait for Type` block resolves to the trait declaration's method
|
|
// node — even when the impl-for type is external (io::Error) and thus has
|
|
// no local type node.
|
|
func TestRustScope_TraitOverrideResolves(t *testing.T) {
|
|
g := buildRustGraph(t, map[string]string{
|
|
"sink.rs": `
|
|
pub trait SinkError {
|
|
fn error_message(message: String) -> Self;
|
|
}
|
|
|
|
impl SinkError for io::Error {
|
|
fn error_message(message: String) -> io::Error {
|
|
panic!()
|
|
}
|
|
}
|
|
`,
|
|
})
|
|
n := ResolveRustScopeCalls(g)
|
|
_ = n
|
|
|
|
implID := "sink.rs::io::Error.error_message"
|
|
traitID := "sink.rs::SinkError.error_message"
|
|
|
|
found := false
|
|
for _, e := range g.GetOutEdges(implID) {
|
|
if e.Kind == graph.EdgeOverrides && e.To == traitID {
|
|
found = true
|
|
}
|
|
}
|
|
require.True(t, found, "impl override should resolve to the trait method")
|
|
|
|
inbound := 0
|
|
for _, e := range g.GetInEdges(traitID) {
|
|
if e.Kind == graph.EdgeOverrides {
|
|
inbound++
|
|
}
|
|
}
|
|
require.Equal(t, 1, inbound, "trait method should have one inbound override")
|
|
}
|