(t *testing.T)
| 213 | } |
| 214 | |
| 215 | func TestLambdaCodeGen_ComplexExpression(t *testing.T) { |
| 216 | // |arr| len(arr) > 0 && arr[0] == "test" |
| 217 | lambda := &ast.LambdaExpr{ |
| 218 | LambdaPos: token.Pos(1), |
| 219 | Style: ast.RustStyle, |
| 220 | Params: []ast.LambdaParam{ |
| 221 | {Name: "arr", Type: "[]string"}, |
| 222 | }, |
| 223 | ReturnType: "bool", |
| 224 | Body: `len(arr) > 0 && arr[0] == "test"`, |
| 225 | IsBlock: false, |
| 226 | } |
| 227 | |
| 228 | gen := NewLambdaCodeGen(lambda) |
| 229 | result := gen.Generate() |
| 230 | |
| 231 | expected := `func(arr []string) bool { return len(arr) > 0 && arr[0] == "test" }` |
| 232 | actual := string(result.Output) |
| 233 | |
| 234 | if actual != expected { |
| 235 | t.Errorf("Expected:\n%s\nGot:\n%s", expected, actual) |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | func TestLambdaCodeGen_NoParams(t *testing.T) { |
| 240 | // || getValue() |
nothing calls this directly
no test coverage detected