(t *testing.T)
| 161 | } |
| 162 | |
| 163 | func 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 | |
| 190 | func TestLambdaCodeGen_MultipleParamsTyped(t *testing.T) { |
| 191 | // |x: int, y: int| -> int { x + y } |
nothing calls this directly
no test coverage detected