diff options
Diffstat (limited to 'testsuite/sed.tests')
-rwxr-xr-x | testsuite/sed.tests | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/testsuite/sed.tests b/testsuite/sed.tests index 677303be1..a9d9ada31 100755 --- a/testsuite/sed.tests +++ b/testsuite/sed.tests | |||
@@ -51,8 +51,10 @@ testing "sed -n" "sed -n -e s/foo/bar/ -e s/bar/baz/" "" "" "foo\n" | |||
51 | testing "sed s//p" "sed -e s/foo/bar/p -e s/bar/baz/p" "bar\nbaz\nbaz\n" \ | 51 | testing "sed s//p" "sed -e s/foo/bar/p -e s/bar/baz/p" "bar\nbaz\nbaz\n" \ |
52 | "" "foo\n" | 52 | "" "foo\n" |
53 | testing "sed -n s//p" "sed -ne s/abc/def/p" "def\n" "" "abc\n" | 53 | testing "sed -n s//p" "sed -ne s/abc/def/p" "def\n" "" "abc\n" |
54 | test x"$SKIP_KNOWN_BUGS" = x"" && { | ||
54 | testing "sed s//g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5,\n" \ | 55 | testing "sed s//g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5,\n" \ |
55 | "" "12345\n" | 56 | "" "12345\n" |
57 | } | ||
56 | testing "sed s arbitrary delimiter" "sed -e 's woo boing '" "boing\n" "" "woo\n" | 58 | testing "sed s arbitrary delimiter" "sed -e 's woo boing '" "boing\n" "" "woo\n" |
57 | testing "sed s chains" "sed -e s/foo/bar/ -e s/bar/baz/" "baz\n" "" "foo\n" | 59 | testing "sed s chains" "sed -e s/foo/bar/ -e s/bar/baz/" "baz\n" "" "foo\n" |
58 | testing "sed s chains2" "sed -e s/foo/bar/ -e s/baz/nee/" "bar\n" "" "foo\n" | 60 | testing "sed s chains2" "sed -e s/foo/bar/ -e s/baz/nee/" "bar\n" "" "foo\n" |
@@ -72,6 +74,7 @@ testing "sed t (test/branch clears test bit)" "sed -e 's/a/b/;:loop;t loop'" \ | |||
72 | testing "sed T (!test/branch)" "sed -e 's/a/1/;T notone;p;: notone;p'" \ | 74 | testing "sed T (!test/branch)" "sed -e 's/a/1/;T notone;p;: notone;p'" \ |
73 | "1\n1\n1\nb\nb\nc\nc\n" "" "a\nb\nc\n" | 75 | "1\n1\n1\nb\nb\nc\nc\n" "" "a\nb\nc\n" |
74 | 76 | ||
77 | test x"$SKIP_KNOWN_BUGS" = x"" && { | ||
75 | # Normal sed end-of-script doesn't print "c" because n flushed the pattern | 78 | # Normal sed end-of-script doesn't print "c" because n flushed the pattern |
76 | # space. If n hits EOF, pattern space is empty when script ends. | 79 | # space. If n hits EOF, pattern space is empty when script ends. |
77 | # Query: how does this interact with no newline at EOF? | 80 | # Query: how does this interact with no newline at EOF? |
@@ -80,6 +83,7 @@ testing "sed n (flushes pattern space, terminates early)" "sed -e 'n;p'" \ | |||
80 | # N does _not_ flush pattern space, therefore c is still in there @ script end. | 83 | # N does _not_ flush pattern space, therefore c is still in there @ script end. |
81 | testing "sed N (doesn't flush pattern space when terminating)" "sed -e 'N;p'" \ | 84 | testing "sed N (doesn't flush pattern space when terminating)" "sed -e 'N;p'" \ |
82 | "a\nb\na\nb\nc\n" "" "a\nb\nc\n" | 85 | "a\nb\na\nb\nc\n" "" "a\nb\nc\n" |
86 | } | ||
83 | testing "sed address match newline" 'sed "/b/N;/b\\nc/i woo"' \ | 87 | testing "sed address match newline" 'sed "/b/N;/b\\nc/i woo"' \ |
84 | "a\nwoo\nb\nc\nd\n" "" "a\nb\nc\nd\n" | 88 | "a\nwoo\nb\nc\nd\n" "" "a\nb\nc\nd\n" |
85 | 89 | ||
@@ -99,13 +103,17 @@ testing "sed d ends script iteration (2)" \ | |||
99 | "sed -e '/ook/d;a\' -e 'bang'" "woot\nbang\n" "" "ook\nwoot\n" | 103 | "sed -e '/ook/d;a\' -e 'bang'" "woot\nbang\n" "" "ook\nwoot\n" |
100 | 104 | ||
101 | # Multiple files, with varying newlines and NUL bytes | 105 | # Multiple files, with varying newlines and NUL bytes |
106 | test x"$SKIP_KNOWN_BUGS" = x"" && { | ||
102 | testing "sed embedded NUL" "sed -e 's/woo/bang/'" "\0bang\0woo\0" "" \ | 107 | testing "sed embedded NUL" "sed -e 's/woo/bang/'" "\0bang\0woo\0" "" \ |
103 | "\0woo\0woo\0" | 108 | "\0woo\0woo\0" |
109 | } | ||
104 | testing "sed embedded NUL g" "sed -e 's/woo/bang/g'" "bang\0bang\0" "" \ | 110 | testing "sed embedded NUL g" "sed -e 's/woo/bang/g'" "bang\0bang\0" "" \ |
105 | "woo\0woo\0" | 111 | "woo\0woo\0" |
112 | test x"$SKIP_KNOWN_BUGS" = x"" && { | ||
106 | echo -e "/woo/a he\0llo" > sed.commands | 113 | echo -e "/woo/a he\0llo" > sed.commands |
107 | testing "sed NUL in command" "sed -f sed.commands" "woo\nhe\0llo\n" "" "woo" | 114 | testing "sed NUL in command" "sed -f sed.commands" "woo\nhe\0llo\n" "" "woo" |
108 | rm sed.commands | 115 | rm sed.commands |
116 | } | ||
109 | 117 | ||
110 | # sed has funky behavior with newlines at the end of file. Test lots of | 118 | # sed has funky behavior with newlines at the end of file. Test lots of |
111 | # corner cases with the optional newline appending behavior. | 119 | # corner cases with the optional newline appending behavior. |
@@ -120,8 +128,10 @@ testing "sed empty file plus cat" "sed -e 's/nohit//' input -" "one\ntwo" \ | |||
120 | "" "one\ntwo" | 128 | "" "one\ntwo" |
121 | testing "sed cat plus empty file" "sed -e 's/nohit//' input -" "one\ntwo" \ | 129 | testing "sed cat plus empty file" "sed -e 's/nohit//' input -" "one\ntwo" \ |
122 | "one\ntwo" "" | 130 | "one\ntwo" "" |
131 | test x"$SKIP_KNOWN_BUGS" = x"" && { | ||
123 | testing "sed append autoinserts newline" "sed -e '/woot/a woo' -" \ | 132 | testing "sed append autoinserts newline" "sed -e '/woot/a woo' -" \ |
124 | "woot\nwoo\n" "" "woot" | 133 | "woot\nwoo\n" "" "woot" |
134 | } | ||
125 | testing "sed insert doesn't autoinsert newline" "sed -e '/woot/i woo' -" \ | 135 | testing "sed insert doesn't autoinsert newline" "sed -e '/woot/i woo' -" \ |
126 | "woo\nwoot" "" "woot" | 136 | "woo\nwoot" "" "woot" |
127 | testing "sed print autoinsert newlines" "sed -e 'p' -" "one\none" "" "one" | 137 | testing "sed print autoinsert newlines" "sed -e 'p' -" "one\none" "" "one" |
@@ -137,9 +147,11 @@ testing "sed selective matches insert newline" \ | |||
137 | testing "sed selective matches noinsert newline" \ | 147 | testing "sed selective matches noinsert newline" \ |
138 | "sed -ne 's/woo/bang/p' input -" "a bang\nb bang" "a woo\nb woo" \ | 148 | "sed -ne 's/woo/bang/p' input -" "a bang\nb bang" "a woo\nb woo" \ |
139 | "c no\nd no" | 149 | "c no\nd no" |
150 | test x"$SKIP_KNOWN_BUGS" = x"" && { | ||
140 | testing "sed clusternewline" \ | 151 | testing "sed clusternewline" \ |
141 | "sed -e '/one/a 111' -e '/two/i 222' -e p input -" \ | 152 | "sed -e '/one/a 111' -e '/two/i 222' -e p input -" \ |
142 | "one\none\n111\n222\ntwo\ntwo" "one" "two" | 153 | "one\none\n111\n222\ntwo\ntwo" "one" "two" |
154 | } | ||
143 | testing "sed subst+write" \ | 155 | testing "sed subst+write" \ |
144 | "sed -e 's/i/z/' -e 'woutputw' input -; echo -n X; cat outputw" \ | 156 | "sed -e 's/i/z/' -e 'woutputw' input -; echo -n X; cat outputw" \ |
145 | "thzngy\nagaznXthzngy\nagazn" "thingy" "again" | 157 | "thzngy\nagaznXthzngy\nagazn" "thingy" "again" |
@@ -175,8 +187,12 @@ testing "sed lie-to-autoconf" "sed --version | grep -o 'GNU sed version '" \ | |||
175 | "GNU sed version \n" "" "" | 187 | "GNU sed version \n" "" "" |
176 | 188 | ||
177 | # Jump to nonexistent label | 189 | # Jump to nonexistent label |
178 | testing "sed nonexistent label" "sed -e 'b walrus' 2> /dev/null || echo yes" \ | 190 | test x"$SKIP_KNOWN_BUGS" = x"" && { |
191 | # Incompatibility: illegal jump is not detected if input is "" | ||
192 | # (that is, no lines at all). GNU sed 4.1.5 complains even in this case | ||
193 | testing "sed nonexistent label" "sed -e 'b walrus' 2>/dev/null || echo yes" \ | ||
179 | "yes\n" "" "" | 194 | "yes\n" "" "" |
195 | } | ||
180 | 196 | ||
181 | testing "sed backref from empty s uses range regex" \ | 197 | testing "sed backref from empty s uses range regex" \ |
182 | "sed -e '/woot/s//eep \0 eep/'" "eep woot eep" "" "woot" | 198 | "sed -e '/woot/s//eep \0 eep/'" "eep woot eep" "" "woot" |