(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func 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 | |
| 37 | func TestLambdaCodeGen_RustStyleTyped(t *testing.T) { |
| 38 | // |x: int| x * 2 |
nothing calls this directly
no test coverage detected