MCPcopy
hub / github.com/MadAppGang/dingo / TestLambdaCodeGen_RustStyleBlockBody

Function TestLambdaCodeGen_RustStyleBlockBody

pkg/codegen/lambda_test.go:87–109  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func TestLambdaCodeGen_RustStyleBlockBody(t *testing.T) {
88 // |x: int| -> int { doSomething(); return x * 2 }
89 lambda := &ast.LambdaExpr{
90 LambdaPos: token.Pos(1),
91 Style: ast.RustStyle,
92 Params: []ast.LambdaParam{
93 {Name: "x", Type: "int"},
94 },
95 ReturnType: "int",
96 Body: "{ doSomething(); return x * 2 }",
97 IsBlock: true,
98 }
99
100 gen := NewLambdaCodeGen(lambda)
101 result := gen.Generate()
102
103 expected := "func(x int) int { doSomething(); return x * 2 }"
104 actual := string(result.Output)
105
106 if actual != expected {
107 t.Errorf("Expected:\n%s\nGot:\n%s", expected, actual)
108 }
109}
110
111func TestLambdaCodeGen_TypeScriptStyleSimple(t *testing.T) {
112 // x => x + 1

Callers

nothing calls this directly

Calls 4

GenerateMethod · 0.95
NewLambdaCodeGenFunction · 0.85
PosMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected