grep -P: add tests for matching ^ and $
Earlier, fba4f1 (grep -P: Fix matching ^ and $) fixed an ancient bug. Add some tests to protect the change from future breakages; a slightly broken version of this was a part of the originally submitted patch. Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com> Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michał Kiedrowicz committed
Feb 27, 2012 at 17:45 UTC
d29d787cd6c0e70891596c61533c1f811425d2d6
1 file changed
+23
t/t7810-grep.sh
+23
@@ -47,6 +47,13 @@ test_expect_success setup '
47
echo vvv >t/v &&
48
mkdir t/a &&
49
echo vvv >t/a/v &&
50
+ {
51
+ echo "line without leading space1"
52
+ echo " line with leading space1"
53
+ echo " line with leading space2"
54
+ echo " line with leading space3"
55
+ echo "line without leading space2"
56
+ } >space &&
57
git add . &&
58
test_tick &&
59
git commit -m initial
@@ -893,4 +900,20 @@ test_expect_success 'mimic ack-grep --group' '
900
test_cmp expected actual
901
'
902
903
+cat >expected <<EOF
904
+space: line with leading space1
905
+space: line with leading space2
906
+space: line with leading space3
907
+EOF
908
+
909
+test_expect_success LIBPCRE 'grep -E "^ "' '
910
+ git grep -E "^ " space >actual &&
911
+ test_cmp expected actual
912
+'
913
+
914
+test_expect_success LIBPCRE 'grep -P "^ "' '
915
+ git grep -P "^ " space >actual &&
916
+ test_cmp expected actual
917
+'
918
+
919
test_done