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

Function TestLambdaCodeGen_MultipleParams

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

Source from the content-addressed store, hash-verified

161}
162
163func TestLambdaCodeGen_MultipleParams(t *testing.T) {
164 // |x, y| x + y
165 lambda := &ast.LambdaExpr{
166 LambdaPos: token.Pos(1),
167 Style: ast.RustStyle,
168 Params: []ast.LambdaParam{
169 {Name: "x", Type: ""},
170 {Name: "y", Type: ""},
171 },
172 ReturnType: "",
173 Body: "x + y",
174 IsBlock: false,
175 }
176
177 gen := NewLambdaCodeGen(lambda)
178 result := gen.Generate()
179
180 // Expression lambdas without explicit return type get 'any' return type
181 // Type inferrer will replace 'any' with actual type from call context
182 expected := "func(x any, y any) any { return x + y }"
183 actual := string(result.Output)
184
185 if actual != expected {
186 t.Errorf("Expected:\n%s\nGot:\n%s", expected, actual)
187 }
188}
189
190func TestLambdaCodeGen_MultipleParamsTyped(t *testing.T) {
191 // |x: int, y: int| -> int { x + y }

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