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

Function TestLambdaCodeGen_NoParams

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

Source from the content-addressed store, hash-verified

237}
238
239func TestLambdaCodeGen_NoParams(t *testing.T) {
240 // || getValue()
241 lambda := &ast.LambdaExpr{
242 LambdaPos: token.Pos(1),
243 Style: ast.RustStyle,
244 Params: []ast.LambdaParam{},
245 ReturnType: "",
246 Body: "getValue()",
247 IsBlock: false,
248 }
249
250 gen := NewLambdaCodeGen(lambda)
251 result := gen.Generate()
252
253 // Expression lambdas without explicit return type get 'any' return type
254 // Type inferrer will replace 'any' with actual type from call context
255 expected := "func() any { return getValue() }"
256 actual := string(result.Output)
257
258 if actual != expected {
259 t.Errorf("Expected:\n%s\nGot:\n%s", expected, actual)
260 }
261}
262
263func TestLambdaCodeGen_NilExpr(t *testing.T) {
264 gen := NewLambdaCodeGen(nil)

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