MCPcopy
hub / github.com/MadAppGang/dingo / TestLambdaCodeGen_ComplexExpression

Function TestLambdaCodeGen_ComplexExpression

pkg/codegen/lambda_test.go:215–237  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

213}
214
215func 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
239func TestLambdaCodeGen_NoParams(t *testing.T) {
240 // || getValue()

Callers

nothing calls this directly

Calls 4

GenerateMethod · 0.95
NewLambdaCodeGenFunction · 0.85
PosMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected