awk/testdir/T.int-expr

125 lines
2.1 KiB
Plaintext
Raw Normal View History

2019-12-27 05:02:52 -05:00
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
2020-01-31 01:40:11 -05:00
pat a(b{0})c
ac 1
abc 0
pat ab{0}*c
ac 1
abc 0
pat a(b{0})*c
ac 1
abc 0
pat ab{0,}c
ac 1
abc 1
pat a(b{0,})c
ac 1
abc 1
pat ab{0,}*c
ac 1
abc 1
pat a(b{0,})*c
ac 1
abc 1
2019-12-27 05:02:52 -05:00
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
2020-01-31 01:40:11 -05:00
ac ~ /a(b{0})c/ -> should be 1, is 1
abc ~ /a(b{0})c/ -> should be 0, is 0
ac ~ /ab{0}*c/ -> should be 1, is 1
abc ~ /ab{0}*c/ -> should be 0, is 0
ac ~ /a(b{0})*c/ -> should be 1, is 1
abc ~ /a(b{0})*c/ -> should be 0, is 0
ac ~ /ab{0,}c/ -> should be 1, is 1
abc ~ /ab{0,}c/ -> should be 1, is 1
ac ~ /a(b{0,})c/ -> should be 1, is 1
abc ~ /a(b{0,})c/ -> should be 1, is 1
ac ~ /ab{0,}*c/ -> should be 1, is 1
abc ~ /ab{0,}*c/ -> should be 1, is 1
ac ~ /a(b{0,})*c/ -> should be 1, is 1
abc ~ /a(b{0,})*c/ -> should be 1, is 1
2019-12-27 05:02:52 -05:00
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