Expand Gotlin language and tooling
This commit is contained in:
parent
8f4f858d86
commit
de1262b4cf
41 changed files with 6059 additions and 379 deletions
32
internal/lang/go_interop_test.go
Normal file
32
internal/lang/go_interop_test.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package lang
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGenerateGoLowercaseImportedSelectors(t *testing.T) {
|
||||
prog, err := Parse(`
|
||||
package demo
|
||||
|
||||
import http net.http
|
||||
import json encoding.json
|
||||
|
||||
fun main() {
|
||||
http.handleFunc("/health", handler)
|
||||
json.unmarshal(body, &target)
|
||||
}
|
||||
`)
|
||||
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{"http.HandleFunc(\"/health\", handler)", "json.Unmarshal(body, &target)"} {
|
||||
if !strings.Contains(string(out), want) {
|
||||
t.Fatalf("generated Go missing %q:\n%s", want, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue