From c5cda3ac190f114227db80f48364012144e9f13a Mon Sep 17 00:00:00 2001 From: Iskander Sharipov Date: Mon, 1 Feb 2021 18:03:12 +0300 Subject: [PATCH] gogrep: add more capture tests TODO refs #192 --- internal/mvdan.cc/gogrep/gogrep_test.go | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/internal/mvdan.cc/gogrep/gogrep_test.go b/internal/mvdan.cc/gogrep/gogrep_test.go index cb361e67..1a7ac2cc 100644 --- a/internal/mvdan.cc/gogrep/gogrep_test.go +++ b/internal/mvdan.cc/gogrep/gogrep_test.go @@ -77,6 +77,44 @@ func TestCapture(t *testing.T) { vars{"tail": "2, 3", "x": "1"}, }, + { + `f($left, $*mid, $right)`, + `f(1, 2)`, + vars{"left": "1", "mid": "", "right": "2"}, + }, + // TODO: #192 + // { + // `f($left, $*mid, $right)`, + // `f(1, 2, 3)`, + // vars{"left": "1", "mid": "2", "right": "3"}, + // }, + // { + // `f($left, $*mid, $right)`, + // `f(1, 2, 3, 4)`, + // vars{"left": "1", "mid": "2, 3", "right": "4"}, + // }, + + { + `f($*butlast, "last")`, + `f("last")`, + vars{"butlast": ""}, + }, + { + `f($*butlast, "last")`, + `f(1, "last")`, + vars{"butlast": "1"}, + }, + { + `f($*butlast, "last")`, + `f(1, 2, "last")`, + vars{"butlast": "1, 2"}, + }, + { + `f($*v, "x", "y")`, + `f(1, 2, "x", "y")`, + vars{"v": "1, 2"}, + }, + { `f($*butlast, $x)`, `f(1)`,