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,55 @@
|
||||
package languages
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/zzet/gortex/internal/graph"
|
||||
)
|
||||
|
||||
func TestScalaExtractor_Enum(t *testing.T) {
|
||||
const scala = `package com.app
|
||||
|
||||
enum Color {
|
||||
case Red, Green, Blue
|
||||
}
|
||||
`
|
||||
res, err := NewScalaExtractor().Extract("Color.scala", []byte(scala))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var enumNode *graph.Node
|
||||
members := map[string]*graph.Node{}
|
||||
for _, n := range res.Nodes {
|
||||
if n.Kind == graph.KindType && n.Name == "Color" {
|
||||
enumNode = n
|
||||
}
|
||||
if n.Kind == graph.KindEnumMember {
|
||||
members[n.Name] = n
|
||||
}
|
||||
}
|
||||
|
||||
if enumNode == nil {
|
||||
t.Fatalf("enum 'Color' was not extracted as a type")
|
||||
}
|
||||
if enumNode.Meta["kind"] != "enum" {
|
||||
t.Errorf("Color should be kind=enum, got meta=%v", enumNode.Meta)
|
||||
}
|
||||
|
||||
for _, want := range []string{"Red", "Green", "Blue"} {
|
||||
m := members[want]
|
||||
if m == nil {
|
||||
t.Errorf("enum case %q was not extracted", want)
|
||||
continue
|
||||
}
|
||||
var memberEdge bool
|
||||
for _, e := range res.Edges {
|
||||
if e.Kind == graph.EdgeMemberOf && e.From == m.ID && e.To == "Color.scala::Color" {
|
||||
memberEdge = true
|
||||
}
|
||||
}
|
||||
if !memberEdge {
|
||||
t.Errorf("enum case %q should be member_of Color", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user