annotate tests/sed.test @ 1776:7bf68329eb3b draft default tip

Repository switched to git at https://github.com/landley/toybox
author Rob Landley <rob@landley.net>
date Thu, 09 Apr 2015 02:28:32 -0500
parents 4c92484c2646
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1539
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/echo Run scripts/test.sh
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 #testing "name" "command" "result" "infile" "stdin"
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
1546
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
5 testing 'sed as cat' 'sed ""' "one\ntwo\nthree" "" "one\ntwo\nthree"
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
6 # This segfaults ubuntu 12.04's sed. No really.
1768
4c92484c2646 Fix sed bug David Halls hit trying to compile libiconv.
Rob Landley <rob@landley.net>
parents: 1620
diff changeset
7 SKIP_HOST=1 testing 'sed - - twice' 'sed "" - -' "hello\n" "" "hello\n"
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
8 testing 'sed -n' 'sed -n ""' "" "" "one\ntwo\nthree"
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
9 testing 'sed -n p' 'sed -n p' "one\ntwo\nthree" "" "one\ntwo\nthree"
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
10 testing 'sed explicit pattern' 'sed -e p -n' "one\ntwo\nthree" "" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
11 "one\ntwo\nthree"
1546
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
12
1539
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 # Exploring the wonders of sed addressing modes
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 testing '' 'sed -n 1p' "one\n" "" "one\ntwo\nthree"
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 testing '' 'sed 2p' "one\ntwo\ntwo\nthree" "" "one\ntwo\nthree"
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 testing '' 'sed -n 2p' "two\n" "" "one\ntwo\nthree"
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 testing 'sed -n $p' 'sed -n \$p' "three" "" "one\ntwo\nthree"
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 testing 'sed as cat #2' "sed -n '1,\$p'" "one\ntwo\nthree" "" "one\ntwo\nthree"
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
19 testing 'sed no input means no last line' "sed '\$a boing'" "" "" ""
1546
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
20 testing 'sed -n $,$p' 'sed -n \$,\$p' 'three' '' 'one\ntwo\nthree'
1539
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 testing '' 'sed -n 1,2p' "one\ntwo\n" "" "one\ntwo\nthree"
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 testing '' 'sed -n 2,3p' "two\nthree" "" "one\ntwo\nthree"
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 testing '' 'sed -n 2,1p' "two\n" "" "one\ntwo\nthree"
1546
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
24 testing 'sed $ with 2 inputs' 'sed -n \$p - input' "four\n" "four\n" \
1539
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 "one\ntwo\nthree"
1546
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
26 testing '' 'sed -n /two/p' "two\n" "" "one\ntwo\nthree"
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
27 testing '' 'sed -n 1,/two/p' 'one\ntwo\n' '' 'one\ntwo\nthree'
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
28 testing '' 'sed -n /one/,2p' 'one\ntwo\n' '' 'one\ntwo\nthree'
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
29 testing '' 'sed -n 1,/one/p' 'one\ntwo\nthree' '' 'one\ntwo\nthree'
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
30 testing '' 'sed -n /one/,1p' 'one\n' '' 'one\ntwo\nthree'
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
31 testing 'sed -n /two/,$p' 'sed -n /two/,\$p' 'two\nthree' '' 'one\ntwo\nthree'
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
32
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
33
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
34 # Fun with newlines!
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
35 testing '' 'sed -n 3p' "three" "" "one\ntwo\nthree"
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
36 testing 'sed prodigal newline' "sed -n '1,\$p' - input" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
37 "one\ntwo\nthree\nfour\n" "four\n" "one\ntwo\nthree"
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
38 testing 'sed Newline only added if further output' "sed -n 3p - input" "three" \
1546
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
39 "four\n" "one\ntwo\nthree"
1539
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
40
1546
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
41 # Fun with match delimiters and escapes
1539
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 testing 'sed match \t tab' "sed -n '/\t/p'" "\tx\n" "" "\tx\n"
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 testing 'sed match t delim disables \t tab' "sed -n '\t\txtp'" "" "" "\tx\n"
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
44 testing 'sed match t delim makes \t literal t' \
3e85af1f7e22 First batch of sed tests.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 "sed -n '\t\txtp'" "tx\n" "" "tx\n"
1544
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
46 testing 'sed match n delim' "sed -n '\n\txnp'" "\tx\n" "" "\tx\n"
1546
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
47 testing 'sed match n delim disables \n newline' "sed -n '\n\nxnp'" "" "" "\nx\n"
1555
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
48 SKIP_HOST=1 testing 'sed match \n literal n' "sed -n '\n\nxnp'" "nx\n" "" "nx\n"
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
49 testing 'sed end match does not check starting match line' \
1544
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
50 "sed -n '/two/,/two/p'" "two\nthree" "" "one\ntwo\nthree"
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
51 testing 'sed end match/start match mixing number/letter' \
1544
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
52 "sed -n '2,/two/p'" "two\nthree" "" "one\ntwo\nthree"
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
53 testing 'sed num then regex' 'sed -n 2,/d/p' 'b\nc\nd\n' '' 'a\nb\nc\nd\ne\nf\n'
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
54 testing 'sed regex then num' 'sed -n /b/,4p' 'b\nc\nd\n' '' 'a\nb\nc\nd\ne\nf\n'
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
55 testing 'sed multiple regex address match' 'sed -n /on/,/off/p' \
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
56 'bone\nturtle\scoff\ntron\nlurid\noffer\n' "" \
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
57 'zap\nbone\nturtle\scoff\nfred\ntron\nlurid\noffer\nbecause\n'
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
58 testing 'sed regex address overlap' 'sed -n /on/,/off/p' "on\nzap\noffon\n" "" \
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
59 'on\nzap\noffon\nping\noff\n'
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
60
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
61 # gGhHlnNpPqrstwxy:=
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
62 # s///#comment
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
63 # abcdDi
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
64
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
65 testing 'sed prodigaler newline' 'sed -e a\\ -e woo' 'one\nwoo\n' '' 'one'
1544
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
66 testing "sed aci" \
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
67 "sed -e '3a boom' -e '/hre/i bang' -e '3a whack' -e '3c bong'" \
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
68 "one\ntwo\nbang\nbong\nboom\nwhack\nfour\n" "" \
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
69 "one\ntwo\nthree\nfour\n"
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
70 testing "sed b loop" "sed ':woo;=;b woo' | head -n 5" '1\n1\n1\n1\n1\n' "" "X"
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
71 testing "sed b skip" "sed -n '2b zap;d;:zap;p'" "two\n" "" "one\ntwo\nthree"
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
72 testing "sed b end" "sed -n '2b;p'" "one\nthree" "" "one\ntwo\nthree"
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
73 testing "sed c range" "sed '2,4c blah'" "one\nblah\nfive\nsix" "" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
74 "one\ntwo\nthree\nfour\nfive\nsix"
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
75 testing "sed c {range}" "sed -e '2,4{c blah' -e '}'" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
76 "one\nblah\nblah\nblah\nfive\nsix" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
77 "" "one\ntwo\nthree\nfour\nfive\nsix"
1620
6f7ed6316d90 Another sed bug. (The e2fsprogs build uses multiple line continuations on the same command.)
Rob Landley <rob@landley.net>
parents: 1612
diff changeset
78 testing "sed c multiple continuation" \
6f7ed6316d90 Another sed bug. (The e2fsprogs build uses multiple line continuations on the same command.)
Rob Landley <rob@landley.net>
parents: 1612
diff changeset
79 "sed -e 'c\\' -e 'two\\' -e ''" "two\n\n" "" "hello"
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
80 testing "sed D further processing depends on whether line is blank" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
81 "sed -e '/one/,/three/{' -e 'i meep' -e'N;2D;}'" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
82 "meep\nmeep\ntwo\nthree\n" "" "one\ntwo\nthree\n"
1544
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
83 testing 'sed newline staying away' 'sed s/o/x/' 'xne\ntwx' '' 'one\ntwo'
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
84
1544
e3aeb7435efe More sed tests.
Rob Landley <rob@landley.net>
parents: 1539
diff changeset
85 # Why on _earth_ is this not an error? There's a \ with no continuation!
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
86 #testing 'sed what, _really_?' 'sed -e a\\ && echo yes really' \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
87 # 'one\nyes really\n' '' 'one\n'
1546
aa74fb336bf4 Yet more sed tests.
Rob Landley <rob@landley.net>
parents: 1544
diff changeset
88
1555
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
89 # all the s/// test
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
90
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
91 testing "sed match empty line" "sed -e 's/^\$/@/'" "@\n" "" "\n"
1555
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
92
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
93 testing 'sed \1' "sed 's/t\\(w\\)o/za\\1py/'" "one\nzawpy\nthree" "" \
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
94 "one\ntwo\nthree"
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
95 testing 'sed \1 p' "sed 's/t\\(w\\)o/za\\1py/p'" "one\nzawpy\nzawpy\nthree" \
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
96 "" "one\ntwo\nthree"
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
97 testing 'sed \1 no newline' "sed 's/t\\(w\\)o/za\\1py/'" "one\nzawpy" "" \
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
98 "one\ntwo"
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
99 testing 'sed \1 p no newline' "sed 's/t\\(w\\)o/za\\1py/p'" \
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
100 "one\nzawpy\nzawpy" "" "one\ntwo"
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
101 testing 'sed -n s//\1/p' "sed -n 's/t\\(w\\)o/za\\1py/p'" "zawpy" "" "one\ntwo"
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
102 testing 'sed -n s//\1/p no newline' "sed -n 's/t\\(w\\)o/za\\1py/p'" "zawpy" \
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
103 "" "one\ntwo"
1556
e7944f8fdcbb Debugging pass on sed: make the existing test suite pass.
Rob Landley <rob@landley.net>
parents: 1555
diff changeset
104 testing 'sed backref error' \
e7944f8fdcbb Debugging pass on sed: make the existing test suite pass.
Rob Landley <rob@landley.net>
parents: 1555
diff changeset
105 "sed 's/w/ale \2 ha/' >/dev/null 2>/dev/null || echo no" \
1555
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
106 "no\n" "" "one\ntwo\nthree"
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
107 testing 'sed empty match after nonempty match' "sed -e 's/a*/c/g'" 'cbcncgc' \
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
108 '' 'baaang'
1aef47e34485 Add a few more sed tests.
Rob Landley <rob@landley.net>
parents: 1546
diff changeset
109 testing 'sed empty match' "sed -e 's/[^ac]*/A/g'" 'AaAcA' '' 'abcde'
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
110 testing 'sed s///#comment' "sed -e 's/TWO/four/i#comment'" "one\nfour\nthree" \
1556
e7944f8fdcbb Debugging pass on sed: make the existing test suite pass.
Rob Landley <rob@landley.net>
parents: 1555
diff changeset
111 "" "one\ntwo\nthree"
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
112
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
113 testing 'sed N flushes pending a and advances match counter' \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
114 "sed -e 'a woo' -e 'N;\$p'" 'woo\none\ntwo\none\ntwo' "" 'one\ntwo'
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
115 testing "sed delimiter in regex [char range] doesn't count" "sed -e 's/[/]//'" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
116 "onetwo\n" "" 'one/two\n'
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
117 testing "sed delete regex range start line after trigger" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
118 "sed -e '/one/,/three/{' -e 'i meep' -e '1D;}'" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
119 "meep\nmeep\ntwo\nmeep\nthree" "" "one\ntwo\nthree"
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
120 testing "sed D further processing depends on whether line is blank" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
121 "sed -e '/one/,/three/{' -e 'i meep' -e'N;2D;}'" \
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
122 "meep\nmeep\ntwo\nthree\n" "" "one\ntwo\nthree\n"
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
123
1612
eec3b88f2d58 Make sed a\ line continuations work properly for different pattern input modes.
Rob Landley <rob@landley.net>
parents: 1577
diff changeset
124 # Different ways of parsing line continuations
eec3b88f2d58 Make sed a\ line continuations work properly for different pattern input modes.
Rob Landley <rob@landley.net>
parents: 1577
diff changeset
125
eec3b88f2d58 Make sed a\ line continuations work properly for different pattern input modes.
Rob Landley <rob@landley.net>
parents: 1577
diff changeset
126 testing "" "sed -e '1a\' -e 'huh'" "meep\nhuh\n" "" "meep"
eec3b88f2d58 Make sed a\ line continuations work properly for different pattern input modes.
Rob Landley <rob@landley.net>
parents: 1577
diff changeset
127 testing "" "sed -f input" "blah\nboom\n" '1a\\\nboom' 'blah'
eec3b88f2d58 Make sed a\ line continuations work properly for different pattern input modes.
Rob Landley <rob@landley.net>
parents: 1577
diff changeset
128 testing "" "sed '1a\
eec3b88f2d58 Make sed a\ line continuations work properly for different pattern input modes.
Rob Landley <rob@landley.net>
parents: 1577
diff changeset
129 hello'" "merp\nhello\n" "" "merp"
eec3b88f2d58 Make sed a\ line continuations work properly for different pattern input modes.
Rob Landley <rob@landley.net>
parents: 1577
diff changeset
130 #echo meep | sed/sed -e '1a\' -e 'huh'
eec3b88f2d58 Make sed a\ line continuations work properly for different pattern input modes.
Rob Landley <rob@landley.net>
parents: 1577
diff changeset
131 #echo blah | sed/sed -f <(echo -e "1a\\\\\nboom")
eec3b88f2d58 Make sed a\ line continuations work properly for different pattern input modes.
Rob Landley <rob@landley.net>
parents: 1577
diff changeset
132 #echo merp | sed/sed "1a\\
eec3b88f2d58 Make sed a\ line continuations work properly for different pattern input modes.
Rob Landley <rob@landley.net>
parents: 1577
diff changeset
133 #hello"
eec3b88f2d58 Make sed a\ line continuations work properly for different pattern input modes.
Rob Landley <rob@landley.net>
parents: 1577
diff changeset
134
1768
4c92484c2646 Fix sed bug David Halls hit trying to compile libiconv.
Rob Landley <rob@landley.net>
parents: 1620
diff changeset
135 testing "sed bonus backslashes" \
4c92484c2646 Fix sed bug David Halls hit trying to compile libiconv.
Rob Landley <rob@landley.net>
parents: 1620
diff changeset
136 "sed -e 'a \l \x\' -e \"\$(echo -e 'ab\\\nc')\"" \
4c92484c2646 Fix sed bug David Halls hit trying to compile libiconv.
Rob Landley <rob@landley.net>
parents: 1620
diff changeset
137 "hello\nl x\nab\nc\n" "" "hello\n"
1577
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
138 # -i with $ last line test
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
139
ac84a209cb05 sed: c needs to trigger range logic like d, D works like d when there isn't anything left in the line, and more tests.
Rob Landley <rob@landley.net>
parents: 1556
diff changeset
140 exit $FAILCOUNT