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,45 @@
|
||||
package languages
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/zzet/gortex/internal/graph"
|
||||
)
|
||||
|
||||
// Calls inside lambda bodies — expression form, block form, and lambdas in
|
||||
// argument position — must emit call edges attributed to the enclosing named
|
||||
// method, exactly like top-level statements. A test that only exercises the
|
||||
// caller through a lambda (assertThatThrownBy(() -> x.y())) is a real usage of
|
||||
// x.y() and must not vanish.
|
||||
func TestJavaExtractor_LambdaBodyCalls(t *testing.T) {
|
||||
src := []byte(`public class Fixture {
|
||||
void run() {
|
||||
Runnable r = () -> foo.bar();
|
||||
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> testee.triggerException());
|
||||
assertThat(values).allMatch(value -> value.getId() != null);
|
||||
list.forEach(item -> { process(item); item.finish(); });
|
||||
}
|
||||
}
|
||||
`)
|
||||
e := NewJavaExtractor()
|
||||
result, err := e.Extract("Fixture.java", src)
|
||||
require.NoError(t, err)
|
||||
|
||||
targets := map[string]bool{}
|
||||
for _, edge := range edgesOfKind(result.Edges, graph.EdgeCalls) {
|
||||
if edge.From == "Fixture.java::Fixture.run" {
|
||||
targets[edge.To] = true
|
||||
}
|
||||
}
|
||||
for _, want := range []string{
|
||||
"unresolved::*.bar", // expression lambda in a local init
|
||||
"unresolved::*.triggerException", // lambda in argument position
|
||||
"unresolved::*.getId", // argument-position lambda with a param
|
||||
"unresolved::*.process", // block-bodied lambda, statement 1
|
||||
"unresolved::*.finish", // block-bodied lambda, statement 2
|
||||
} {
|
||||
assert.True(t, targets[want], "expected a call edge to %s attributed to the enclosing method", want)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user