| 1 |
#!/usr/bin/env runawk |
| 2 |
|
| 3 |
#use "multisub.awk" |
| 4 |
#use "alt_assert.awk" |
| 5 |
|
| 6 |
function test (ideal, input, repls, num, keep, |
| 7 |
res) |
| 8 |
{ |
| 9 |
# print "ideal=" ideal > "/dev/stderr" |
| 10 |
res = multisub(input, repls, keep) |
| 11 |
# print "res=" res > "/dev/stderr" |
| 12 |
if (ideal != res){ |
| 13 |
msg = ("test " num " failed") |
| 14 |
msg = msg "\n ideal=\"" ideal "\"" |
| 15 |
msg = msg "\n res =\"" res "\"" |
| 16 |
abort(msg) |
| 17 |
} |
| 18 |
# print "test " num " succeeded" |
| 19 |
} |
| 20 |
|
| 21 |
BEGIN { |
| 22 |
test("osb", "[", "[:osb", -1) |
| 23 |
test("csb", "]", "]:csb", -2) |
| 24 |
test("", "", "", 1) |
| 25 |
test("aaa", "aaa", "", 2) |
| 26 |
test("aaa", "aaa", "b:c", 3) |
| 27 |
test("dc", "bbb", "b:c bb:d", 4) |
| 28 |
test("e", "bbb", "b:c bbb:e bb:d", 5) |
| 29 |
test("Bd", "BBBA", "ABB:c BBA:d", 6) |
| 30 |
test("ccBBde", "ABBABBBBBBAAB", "ABB:c BBA:d AB:e", 7) |
| 31 |
test("kABBA(acca)BC(saab)", "kabba(acca)bc(saab)", "a:A b:B c:C [(][^()]*[)]:&", 7, "&") |
| 32 |
|
| 33 |
if (!__buggy_mawk) |
| 34 |
test("aaa\nbbb\nccc\tddd\aeee\a", "aaa\\nbbb\\nccc\\tddd\\aeee\\a", "\\t:\t \\a:\a \\n:\n", 7) |
| 35 |
|
| 36 |
test("question_question_osb_osb_csb_csb_ocb_ocb_ccb_ccb_or_or_orb_orb_crb_crb_star_star_plus_plus_dot_power_power_dollar_backslash_", |
| 37 |
"??[[]]{{}}||(())**++.^^$\\", "$:dollar_ ^:power_ .:dot_ +:plus_ *:star_ ):crb_ (:orb_ |:or_ }:ccb_ {:ocb_ [:osb_ ]:csb_ ?:question_ \\:backslash_", 8) |
| 38 |
|
| 39 |
exit 0 |
| 40 |
} |