diff options
author | Rob Landley <rob@landley.net> | 2006-03-01 16:32:01 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-03-01 16:32:01 +0000 |
commit | e8e7811fb471ae11868db8f715c06960bba8637b (patch) | |
tree | 8443f180fcbaab438b53a306e79a2de3fc6f2a19 | |
parent | 325da7b509e25cbb26bfc77418b27d397cbc0e4d (diff) | |
download | busybox-w32-e8e7811fb471ae11868db8f715c06960bba8637b.tar.gz busybox-w32-e8e7811fb471ae11868db8f715c06960bba8637b.tar.bz2 busybox-w32-e8e7811fb471ae11868db8f715c06960bba8637b.zip |
Yet more sed tests. Passing these is a to-do item for 1.1.2 or 1.2, not a
1.1.1 issue.
-rwxr-xr-x | testsuite/sed.tests | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/testsuite/sed.tests b/testsuite/sed.tests index 1f2208200..6fcaa19df 100755 --- a/testsuite/sed.tests +++ b/testsuite/sed.tests | |||
@@ -10,17 +10,14 @@ | |||
10 | # testing "description" "arguments" "result" "infile" "stdin" | 10 | # testing "description" "arguments" "result" "infile" "stdin" |
11 | 11 | ||
12 | # Corner cases | 12 | # Corner cases |
13 | testing "sed as cat" '"" -' "hello\n" "" "hello\n" | 13 | testing "sed no files (stdin)" '""' "hello\n" "" "hello\n" |
14 | testing "sed explicit stdin" '"" -' "hello\n" "" "hello\n" | ||
14 | testing "sed handles empty lines" "-e 's/\$/@/'" "@\n" "" "\n" | 15 | testing "sed handles empty lines" "-e 's/\$/@/'" "@\n" "" "\n" |
16 | testing "sed stdin twice" '"" - -' "hello" "" "hello" | ||
15 | 17 | ||
16 | # no files (stdin) | ||
17 | # explicit stdin | ||
18 | # mix files and stdin (various orders) | ||
19 | # list stdin twice | ||
20 | # Trailing EOF. | 18 | # Trailing EOF. |
21 | # Multiple files: first no EOF, second length 0. | ||
22 | # Match $, at end of each file or all files? | 19 | # Match $, at end of each file or all files? |
23 | # First no EOF, second no matches at all. | 20 | |
24 | # -e corner cases | 21 | # -e corner cases |
25 | # without -e | 22 | # without -e |
26 | # multiple -e | 23 | # multiple -e |
@@ -37,6 +34,9 @@ testing "sed handles empty lines" "-e 's/\$/@/'" "@\n" "" "\n" | |||
37 | # permissions | 34 | # permissions |
38 | # -i on a symlink | 35 | # -i on a symlink |
39 | # on a directory | 36 | # on a directory |
37 | # With $ last-line test | ||
38 | # Continue with \ | ||
39 | # End of script with trailing \ | ||
40 | 40 | ||
41 | # command list | 41 | # command list |
42 | testing "sed accepts blanks before command" "-e '1 d'" "" "" "" | 42 | testing "sed accepts blanks before command" "-e '1 d'" "" "" "" |
@@ -100,6 +100,10 @@ testing "sed d ends script iteration (2)" \ | |||
100 | 100 | ||
101 | # Multiple files, with varying newlines and NUL bytes | 101 | # Multiple files, with varying newlines and NUL bytes |
102 | testing "sed embedded NUL" "-e 's/woo/bang/'" "\0bang\0woo\0" "" "\0woo\0woo\0" | 102 | testing "sed embedded NUL" "-e 's/woo/bang/'" "\0bang\0woo\0" "" "\0woo\0woo\0" |
103 | testing "sed embedded NUL g" "-e 's/woo/bang/g'" "bang\0bang\0" "" "woo\0woo\0" | ||
104 | echo -e "/woo/a he\0llo" > sed.commands | ||
105 | testing "sed NUL in command" "-f sed.commands" "woo\nhe\0llo\n" "" "woo" | ||
106 | rm sed.commands | ||
103 | 107 | ||
104 | # sed has funky behavior with newlines at the end of file. Test lots of | 108 | # sed has funky behavior with newlines at the end of file. Test lots of |
105 | # corner cases with the optional newline appending behavior. | 109 | # corner cases with the optional newline appending behavior. |
@@ -121,10 +125,9 @@ testing "sed insert doesn't autoinsert newline" "-e '/woot/i woo' -" \ | |||
121 | testing "sed print autoinsert newlines" "-e 'p' -" "one\none" "" "one" | 125 | testing "sed print autoinsert newlines" "-e 'p' -" "one\none" "" "one" |
122 | testing "sed print autoinsert newlines two files" "-e 'p' input -" \ | 126 | testing "sed print autoinsert newlines two files" "-e 'p' input -" \ |
123 | "one\none\ntwo\ntwo" "one" "two" | 127 | "one\none\ntwo\ntwo" "one" "two" |
124 | |||
125 | testing "sed noprint, no match, no newline" "-ne 's/woo/bang/' input" \ | 128 | testing "sed noprint, no match, no newline" "-ne 's/woo/bang/' input" \ |
126 | "" "no\n" "" | 129 | "" "no\n" "" |
127 | testing "sed selective matches with nl" "-ne 's/woo/bang/p' input -" \ | 130 | testing "sed selective matches with one nl" "-ne 's/woo/bang/p' input -" \ |
128 | "a bang\nc bang\n" "a woo\nb no" "c woo\nd no" | 131 | "a bang\nc bang\n" "a woo\nb no" "c woo\nd no" |
129 | testing "sed selective matches insert newline" "-ne 's/woo/bang/p' input -" \ | 132 | testing "sed selective matches insert newline" "-ne 's/woo/bang/p' input -" \ |
130 | "a bang\nb bang\nd bang" "a woo\nb woo" "c no\nd woo" | 133 | "a bang\nb bang\nd bang" "a woo\nb woo" "c no\nd woo" |
@@ -133,6 +136,39 @@ testing "sed selective matches noinsert newline" "-ne 's/woo/bang/p' input -" \ | |||
133 | testing "sed clusternewline" "-e '/one/a 111' -e '/two/i 222' -e p input -" \ | 136 | testing "sed clusternewline" "-e '/one/a 111' -e '/two/i 222' -e p input -" \ |
134 | "one\none\n111\n222\ntwo\ntwo" "one" "two" | 137 | "one\none\n111\n222\ntwo\ntwo" "one" "two" |
135 | 138 | ||
139 | # Test end-of-file matching behavior | ||
140 | |||
141 | testing "sed match EOF" " -e '"'$p'"'" "hello\nthere\nthere" "" "hello\nthere" | ||
142 | testing "sed match EOF two files" " -e '"'$p'"' input -" \ | ||
143 | "one\ntwo\nthree\nfour\nfour" "one\ntwo" "three\nfour" | ||
144 | echo -ne "three\nfour" > input2 | ||
145 | testing "sed match EOF inline" \ | ||
146 | " -e '"'$i ook'"' -i input input2 && cat input input2" \ | ||
147 | "one\nook\ntwothree\nook\nfour" "one\ntwo" "" | ||
148 | rm input2 | ||
149 | |||
150 | # Test lie-to-autoconf | ||
151 | |||
152 | testing "sed lie-to-autoconf" "--version | grep -o 'GNU sed version '" \ | ||
153 | "GNU sed version \n" "" "" | ||
154 | |||
155 | # Jump to nonexistent label | ||
156 | testing "sed nonexistent label" "-e 'b walrus' 2> /dev/null || echo yes" \ | ||
157 | "yes\n" "" "" | ||
158 | |||
159 | testing "sed backref from empty s uses range regex" \ | ||
160 | "-e '/woot/s//eep \0 eep/'" "eep woot eep" "" "woot" | ||
161 | |||
162 | testing "sed backref from empty s uses range regex with newline" \ | ||
163 | "-e '/woot/s//eep \0 eep/'" "eep woot eep\n" "" "woot\n" | ||
164 | |||
165 | # -i with no filename | ||
166 | |||
167 | touch ./- # Detect gnu failure mode here. | ||
168 | testing "sed -i with no arg [GNUFAIL]" "-e '' -i 2> /dev/null || echo yes" \ | ||
169 | "yes\n" "" "" | ||
170 | rm ./- # Clean up | ||
171 | |||
136 | # Ponder this a bit more, why "woo not found" from gnu version? | 172 | # Ponder this a bit more, why "woo not found" from gnu version? |
137 | #testing "sed doesn't substitute in deleted line" \ | 173 | #testing "sed doesn't substitute in deleted line" \ |
138 | # "-e '/ook/d;s/ook//;t woo;a bang;'" "bang" "" "ook\n" | 174 | # "-e '/ook/d;s/ook//;t woo;a bang;'" "bang" "" "ook\n" |