changeset 1555:1aef47e34485 draft

Add a few more sed tests.
author Rob Landley <rob@landley.net>
date Fri, 14 Nov 2014 16:44:21 -0600
parents e6a4ed6fc873
children e7944f8fdcbb
files tests/sed.test
diffstat 1 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tests/sed.test	Fri Nov 14 16:44:00 2014 -0600
+++ b/tests/sed.test	Fri Nov 14 16:44:21 2014 -0600
@@ -39,8 +39,7 @@
 	"sed -n '\t\txtp'" "tx\n" "" "tx\n"
 testing 'sed match n delim' "sed -n '\n\txnp'" "\tx\n" "" "\tx\n"
 testing 'sed match n delim disables \n newline' "sed -n '\n\nxnp'" "" "" "\nx\n"
-testing 'sed match n delim makes \n literal n' \
-	"sed -n '\n\nxnp'" "nx\n" "" "nx\n"
+SKIP_HOST=1 testing 'sed match \n literal n' "sed -n '\n\nxnp'" "nx\n" "" "nx\n"
 testing 'end match does not check starting match line' \
 	"sed -n '/two/,/two/p'" "two\nthree" "" "one\ntwo\nthree"
 testing 'end match/start match mixing number/letter' \
@@ -63,3 +62,23 @@
 testing 'sed what, _really_?' 'sed -e a\\ && echo yes really' \
 	'one\nyes really\n' '' 'one\n'
 
+# all the s/// test
+
+
+testing 'sed \1' "sed 's/t\\(w\\)o/za\\1py/'" "one\nzawpy\nthree" "" \
+	"one\ntwo\nthree"
+testing 'sed \1 p' "sed 's/t\\(w\\)o/za\\1py/p'" "one\nzawpy\nzawpy\nthree" \
+	"" "one\ntwo\nthree"
+testing 'sed \1 no newline' "sed 's/t\\(w\\)o/za\\1py/'" "one\nzawpy" "" \
+	"one\ntwo"
+testing 'sed \1 p no newline' "sed 's/t\\(w\\)o/za\\1py/p'" \
+	"one\nzawpy\nzawpy" "" "one\ntwo"
+testing 'sed -n s//\1/p' "sed -n 's/t\\(w\\)o/za\\1py/p'" "zawpy" "" "one\ntwo"
+testing 'sed -n s//\1/p no newline' "sed -n 's/t\\(w\\)o/za\\1py/p'" "zawpy" \
+	"" "one\ntwo"
+testing 'sed backref error' "sed 's/w/ale \2 ha/' 2>/dev/null || echo no" \
+	"no\n" "" "one\ntwo\nthree"
+testing 'sed empty match after nonempty match' "sed -e 's/a*/c/g'" 'cbcncgc' \
+	'' 'baaang'
+testing 'sed empty match' "sed -e 's/[^ac]*/A/g'" 'AaAcA' '' 'abcde'
+