chore: import upstream snapshot with attribution
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
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
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package languages
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/zzet/gortex/internal/graph"
|
||||
)
|
||||
|
||||
// A selector call `x.foo()` must emit exactly one call edge carrying the
|
||||
// receiver_type — not also a receiver-less plain-call edge. The two would
|
||||
// collide on the edge key (which excludes Meta) and the receiver-less one would
|
||||
// clobber the receiver_type, so the resolver would lose the type hint.
|
||||
func TestJavaExtractor_SelectorCallNoDuplicateEdge(t *testing.T) {
|
||||
src := []byte(`public class T {
|
||||
private final Dep dep;
|
||||
void run() {
|
||||
dep.doWork();
|
||||
bare();
|
||||
}
|
||||
}
|
||||
`)
|
||||
e := NewJavaExtractor()
|
||||
result, err := e.Extract("T.java", src)
|
||||
require.NoError(t, err)
|
||||
|
||||
var doWork []*graph.Edge
|
||||
var sawBare bool
|
||||
for _, ed := range edgesOfKind(result.Edges, graph.EdgeCalls) {
|
||||
switch ed.To {
|
||||
case "unresolved::*.doWork":
|
||||
doWork = append(doWork, ed)
|
||||
case "unresolved::*.bare":
|
||||
sawBare = true
|
||||
}
|
||||
}
|
||||
require.Len(t, doWork, 1, "a selector call must emit exactly one call edge, not a receiver-less duplicate")
|
||||
rt, _ := doWork[0].Meta["receiver_type"].(string)
|
||||
assert.Equal(t, "Dep", rt, "the surviving selector edge must keep its receiver_type")
|
||||
assert.True(t, sawBare, "a true bare call still emits its plain-call edge")
|
||||
}
|
||||
Reference in New Issue
Block a user