Expand Gotlin language and tooling

This commit is contained in:
pavel 2026-08-27 01:46:57 +02:00
commit de1262b4cf
41 changed files with 6059 additions and 379 deletions

View file

@ -0,0 +1,31 @@
package lang
import (
"strings"
"testing"
)
func TestGenerateGoJSONDecodeReturnsTypedValue(t *testing.T) {
prog, err := Parse(`
package demo
import json encoding.json
fun decode(body: ByteSlice): List<Account> {
val accounts = json.decode<List<Account>>(body)
return accounts
}
`)
if err != nil {
t.Fatalf("parse failed: %v", err)
}
out, err := GenerateGo(prog)
if err != nil {
t.Fatalf("generation failed: %v", err)
}
for _, want := range []string{"accounts := gotlinAutoThrow(gotlinJSONDecode[[]Account](body))", "json.Unmarshal(body, &value)"} {
if !strings.Contains(string(out), want) {
t.Fatalf("generated Go missing %q:\n%s", want, out)
}
}
}