Debian Codegraph @

tests/function-line-vs-leading-space

raw
1 #!/bin/sh
2 # Demonstrate how -F RE behavior changed after diff-2.9.
3
4 . "${srcdir=.}/init.sh"; path_prepend_ ../src
5
6 cat <<EOF > in || fail_ "failed to create temporary file"
7 procedure AdaCode is
8 procedure Local_Level_1 is
9 procedure Local_Level_2 is
10 procedure Local_Level_3 is
11 procedure Local_Level_4 is
12 procedure Local_Level_5 is
13 begin
14 null;
15 null;
16 null;
17 foo;
18 end;
19 begin
20 Local_Level_5;
21 end;
22 begin
23 Local_Level_4;
24 end;
25 begin
26 Local_Level_3;
27 end;
28 begin
29 Local_Level_2;
30 end;
31 begin
32 Local_Level_1;
33 end;
34 EOF
35
36 sed s/foo/null/ < in > in2 || fail_ "failed to create temporary file"
37
38 # Before diff-2.10, the function line would be truncated like this:
39 # @@ -8,7 +8,7 @@ procedure Local_Leve
40
41 cat <<EOF > exp || fail_ "failed to create temporary file"
42 @@ -8,7 +8,7 @@ procedure Local_Level_5 is
43 null;
44 null;
45 null;
46 - foo;
47 + null;
48 end;
49 begin
50 Local_Level_5;
51 EOF
52
53 fail=0
54
55 returns_ 1 diff -u -F '^[[:space:]]*\(function\|procedure\)' in in2 \
56 > out 2> err || fail=1
57
58 sed -n '3,$p' out > k && mv k out || fail=1
59
60 compare exp out || fail=1
61
62 # expect empty stderr
63 compare /dev/null err || fail=1
64
65 Exit $fail