(t *testing.T)
| 85 | } |
| 86 | |
| 87 | func TestLambdaCodeGen_RustStyleBlockBody(t *testing.T) { |
| 88 | // |x: int| -> int { doSomething(); return x * 2 } |
| 89 | lambda := &ast.LambdaExpr{ |
| 90 | LambdaPos: token.Pos(1), |
| 91 | Style: ast.RustStyle, |
| 92 | Params: []ast.LambdaParam{ |
| 93 | {Name: "x", Type: "int"}, |
| 94 | }, |
| 95 | ReturnType: "int", |
| 96 | Body: "{ doSomething(); return x * 2 }", |
| 97 | IsBlock: true, |
| 98 | } |
| 99 | |
| 100 | gen := NewLambdaCodeGen(lambda) |
| 101 | result := gen.Generate() |
| 102 | |
| 103 | expected := "func(x int) int { doSomething(); return x * 2 }" |
| 104 | actual := string(result.Output) |
| 105 | |
| 106 | if actual != expected { |
| 107 | t.Errorf("Expected:\n%s\nGot:\n%s", expected, actual) |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | func TestLambdaCodeGen_TypeScriptStyleSimple(t *testing.T) { |
| 112 | // x => x + 1 |
nothing calls this directly
no test coverage detected