(t *testing.T)
| 237 | } |
| 238 | |
| 239 | func 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 | |
| 263 | func TestLambdaCodeGen_NilExpr(t *testing.T) { |
| 264 | gen := NewLambdaCodeGen(nil) |
nothing calls this directly
no test coverage detected