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,93 @@
|
||||
package languages
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/zzet/gortex/internal/graph"
|
||||
)
|
||||
|
||||
func runKotlinExtract(t *testing.T, path, src string) ([]*graph.Node, []*graph.Edge) {
|
||||
t.Helper()
|
||||
ext := NewKotlinExtractor()
|
||||
result, err := ext.Extract(path, []byte(src))
|
||||
if err != nil {
|
||||
t.Fatalf("extract: %v", err)
|
||||
}
|
||||
return result.Nodes, result.Edges
|
||||
}
|
||||
|
||||
func TestKotlinAsyncSpawns_LaunchAsync(t *testing.T) {
|
||||
src := `package x
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
fun runAll() {
|
||||
GlobalScope.launch {
|
||||
val deferred = async { compute() }
|
||||
deferred.await()
|
||||
}
|
||||
}
|
||||
`
|
||||
_, edges := runKotlinExtract(t, "x/runner.kt", src)
|
||||
|
||||
spawns := edgesByKind(edges, graph.EdgeSpawns)
|
||||
wantBuilders := map[string]bool{"unresolved::launch": false, "unresolved::async": false}
|
||||
hasAwait := false
|
||||
for _, e := range spawns {
|
||||
mode, _ := e.Meta["mode"].(string)
|
||||
if mode == "coroutine" {
|
||||
if _, ok := wantBuilders[e.To]; ok {
|
||||
wantBuilders[e.To] = true
|
||||
}
|
||||
}
|
||||
if mode == "async" && e.To == "unresolved::await" {
|
||||
hasAwait = true
|
||||
}
|
||||
}
|
||||
for tgt, found := range wantBuilders {
|
||||
if !found {
|
||||
t.Errorf("expected EdgeSpawns mode=coroutine → %s; got %v", tgt, edgeTargets(spawns))
|
||||
}
|
||||
}
|
||||
if !hasAwait {
|
||||
t.Errorf("expected EdgeSpawns mode=async → await; got %v", edgeTargets(spawns))
|
||||
}
|
||||
}
|
||||
|
||||
func TestKotlinFunctionShape_ClassLevelGeneric(t *testing.T) {
|
||||
src := `package x
|
||||
|
||||
class Repo<T : Any>
|
||||
`
|
||||
nodes, _ := runKotlinExtract(t, "x/Repo.kt", src)
|
||||
gp := nodesOfKind(nodes, graph.KindGenericParam)
|
||||
hasT := false
|
||||
for _, n := range gp {
|
||||
if n.Name == "T" {
|
||||
hasT = true
|
||||
}
|
||||
}
|
||||
if !hasT {
|
||||
t.Fatalf("expected KindGenericParam T at class level; got %v", nodeNames(gp))
|
||||
}
|
||||
}
|
||||
|
||||
func TestKotlinAsyncSpawns_RunBlocking(t *testing.T) {
|
||||
src := `package x
|
||||
|
||||
fun blockingMain() = runBlocking {
|
||||
println("hi")
|
||||
}
|
||||
`
|
||||
_, edges := runKotlinExtract(t, "x/main.kt", src)
|
||||
spawns := edgesByKind(edges, graph.EdgeSpawns)
|
||||
hasRunBlocking := false
|
||||
for _, e := range spawns {
|
||||
if e.To == "unresolved::runBlocking" {
|
||||
hasRunBlocking = true
|
||||
}
|
||||
}
|
||||
if !hasRunBlocking {
|
||||
t.Errorf("expected EdgeSpawns → runBlocking; got %v", edgeTargets(spawns))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user