source: trunk/src/sed/testsuite/eval.sh@ 3670

Last change on this file since 3670 was 3613, checked in by bird, 10 months ago

src/sed: Merged in changes between 4.1.5 and 4.9 from the vendor branch. (svn merge /vendor/sed/4.1.5 /vendor/sed/current .)

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#!/bin/sh
2
3# Test runner for old 'eval' test
4
5# Copyright (C) 2017-2022 Free Software Foundation, Inc.
6
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <https://www.gnu.org/licenses/>.
19. "${srcdir=.}/testsuite/init.sh"; path_prepend_ ./sed
20print_ver_ sed
21
22cat << \EOF > eval-in || framework_failure_
2317380: 2 2 5 11 79
24abcd
25cpu
26 abcd
27 cpu
28EOF
29
30# create a copy of the input file.
31# Keep the name 'eval.in2' - it is used in the 'eval' commands in the
32# sed program below.
33cp eval-in eval.in2 || framework_failure_
34
35
36# The sed program - containing multiple 'e' (eval) commands.
37# NOTE: the program executes 'sed' using 'e' commands - and
38# assumes GNU sed is in the $PATH (which is the case here).
39cat << \EOF > eval.sed || framework_failure_
401d
41
42 #Try eval command
43 /cpu/!b2
44 esed 1q eval.in2
45
46:2
47p
48i---
49h
50
51 #Try eval option
52 s,.* *cpu *,sed 1q eval.in2; echo "&",e
53
54:3
55p
56g
57i---
58
59 h
60 #Try eval option with print
61 s,.* *cpu.*,sed 1q eval.in2,ep
62 g
63
64
65:4
66p
67i---
68
69$!d
70
71#Do some more tests
72s/.*/Doing some more tests -----------------------/p
73s,.*,sed 1q eval.in2,ep
74i---
75s,.*,sed 1q eval.in2,pe
76i---
77s,.*,sed 1q eval.in2,
78h
79e
80p
81g
82i---
83s/^/echo /ep
84i---
85s/^fubar$/echo wozthis/e
86EOF
87
88
89# The expected output file
90cat << \EOF > eval-exp || framework_failure_
91abcd
92---
93abcd
94---
95abcd
96---
9717380: 2 2 5 11 79
98cpu
99---
10017380: 2 2 5 11 79
101cpu
102---
10317380: 2 2 5 11 79
104cpu
105---
106 abcd
107---
108 abcd
109---
110 abcd
111---
11217380: 2 2 5 11 79
113 cpu
114---
11517380: 2 2 5 11 79
116 cpu
117---
11817380: 2 2 5 11 79
119 cpu
120---
121Doing some more tests -----------------------
12217380: 2 2 5 11 79
123---
124sed 1q eval.in2
125---
12617380: 2 2 5 11 79
127---
128sed 1q eval.in2
129---
130sed 1q eval.in2
131EOF
132
133
134
135
136sed -f eval.sed eval-in > eval-out || fail=1
137remove_cr_inplace eval-out
138compare eval-exp eval-out || fail=1
139
140
141Exit $fail
Note: See TracBrowser for help on using the repository browser.