diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2019-12-27 12:02:52 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2019-12-27 12:03:35 +0200 |
commit | 7db55ba13f856c868b23a83dc3e10fa9fbc5fa3b (patch) | |
tree | 966a8eb8f1481e26f03b9cf2a19a9f124699e5ec /testdir | |
parent | 1951e01288b48817b8cb5e9b789f4f9fb01527b7 (diff) | |
download | one-true-awk-7db55ba13f856c868b23a83dc3e10fa9fbc5fa3b.tar.gz |
Bug fix in interval expressions.
Diffstat (limited to 'testdir')
-rwxr-xr-x | testdir/T.int-expr | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/testdir/T.int-expr b/testdir/T.int-expr new file mode 100755 index 0000000..e71a075 --- /dev/null +++ b/testdir/T.int-expr @@ -0,0 +1,82 @@ +echo T.int-expr: test interval expressions + +awk=${awk-../a.out} + +rm -f foo + +cat << \EOF > prog +NF == 0 { next } +$1 == "pat" { pattern = $2; next } +{ + check = ($1 ~ pattern) + printf("%s ~ /%s/ -> should be %d, is %d\n", $1, pattern, $2, check) +} +EOF + +cat << \EOF > foo.in +pat ab{0}c +ac 1 +abc 0 + +pat ab{1}c +ac 0 +abc 1 +abbc 0 + +pat ab{1,}c +ac 0 +abc 1 +abbc 1 +abbbc 1 +abbbbc 1 + +pat ab{0,1}c +ac 1 +abc 1 +abbc 0 + +pat ab{0,3}c +ac 1 +abc 1 +abbc 1 +abbbc 1 +abbbbc 0 + +pat ab{1,3}c +ac 0 +abc 1 +abbc 1 +abbbc 1 +abbbbc 0 +EOF + +cat << \EOF > foo1 +ac ~ /ab{0}c/ -> should be 1, is 1 +abc ~ /ab{0}c/ -> should be 0, is 0 +ac ~ /ab{1}c/ -> should be 0, is 0 +abc ~ /ab{1}c/ -> should be 1, is 1 +abbc ~ /ab{1}c/ -> should be 0, is 0 +ac ~ /ab{1,}c/ -> should be 0, is 0 +abc ~ /ab{1,}c/ -> should be 1, is 1 +abbc ~ /ab{1,}c/ -> should be 1, is 1 +abbbc ~ /ab{1,}c/ -> should be 1, is 1 +abbbbc ~ /ab{1,}c/ -> should be 1, is 1 +ac ~ /ab{0,1}c/ -> should be 1, is 1 +abc ~ /ab{0,1}c/ -> should be 1, is 1 +abbc ~ /ab{0,1}c/ -> should be 0, is 0 +ac ~ /ab{0,3}c/ -> should be 1, is 1 +abc ~ /ab{0,3}c/ -> should be 1, is 1 +abbc ~ /ab{0,3}c/ -> should be 1, is 1 +abbbc ~ /ab{0,3}c/ -> should be 1, is 1 +abbbbc ~ /ab{0,3}c/ -> should be 0, is 0 +ac ~ /ab{1,3}c/ -> should be 0, is 0 +abc ~ /ab{1,3}c/ -> should be 1, is 1 +abbc ~ /ab{1,3}c/ -> should be 1, is 1 +abbbc ~ /ab{1,3}c/ -> should be 1, is 1 +abbbbc ~ /ab{1,3}c/ -> should be 0, is 0 +EOF + + +$awk -f prog foo.in > foo2 +diff foo1 foo2 || echo 'BAD: T.int-expr (1)' +rm -f prog |