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

Function TestLambdaCodeGen_RustStyleSimple

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

Source from the content-addressed store, hash-verified

9)
10
11func TestLambdaCodeGen_RustStyleSimple(t *testing.T) {
12 // |x| x + 1
13 lambda := &ast.LambdaExpr{
14 LambdaPos: token.Pos(1),
15 Style: ast.RustStyle,
16 Params: []ast.LambdaParam{
17 {Name: "x", Type: ""},
18 },
19 ReturnType: "",
20 Body: "x + 1",
21 IsBlock: false,
22 }
23
24 gen := NewLambdaCodeGen(lambda)
25 result := gen.Generate()
26
27 // Expression lambdas without explicit return type get 'any' return type
28 // Type inferrer will replace 'any' with actual type from call context
29 expected := "func(x any) any { return x + 1 }"
30 actual := string(result.Output)
31
32 if actual != expected {
33 t.Errorf("Expected:\n%s\nGot:\n%s", expected, actual)
34 }
35}
36
37func TestLambdaCodeGen_RustStyleTyped(t *testing.T) {
38 // |x: int| x * 2

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