#!/bin/rcecho T.int-expr: test interval expressions >[1=2] rm -f foo cat << 'EOF' > progNF == 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.inpat ab{0}cac 1abc 0 pat a(b{0})cac 1abc 0 pat ab{0}*cac 1abc 0 pat a(b{0})*cac 1abc 0 pat ab{0,}cac 1abc 1 pat a(b{0,})cac 1abc 1 pat ab{0,}*cac 1abc 1 pat a(b{0,})*cac 1abc 1 pat ab{1}cac 0abc 1abbc 0 pat ab{1,}cac 0abc 1abbc 1abbbc 1abbbbc 1 pat ab{0,1}cac 1abc 1abbc 0 pat ab{0,3}cac 1abc 1abbc 1abbbc 1abbbbc 0 pat ab{1,3}cac 0abc 1abbc 1abbbc 1abbbbc 0EOF cat << 'EOF' > foo1ac ~ /ab{0}c/ -> should be 1, is 1abc ~ /ab{0}c/ -> should be 0, is 0ac ~ /a(b{0})c/ -> should be 1, is 1abc ~ /a(b{0})c/ -> should be 0, is 0ac ~ /ab{0}*c/ -> should be 1, is 1abc ~ /ab{0}*c/ -> should be 0, is 0ac ~ /a(b{0})*c/ -> should be 1, is 1abc ~ /a(b{0})*c/ -> should be 0, is 0ac ~ /ab{0,}c/ -> should be 1, is 1abc ~ /ab{0,}c/ -> should be 1, is 1ac ~ /a(b{0,})c/ -> should be 1, is 1abc ~ /a(b{0,})c/ -> should be 1, is 1ac ~ /ab{0,}*c/ -> should be 1, is 1abc ~ /ab{0,}*c/ -> should be 1, is 1ac ~ /a(b{0,})*c/ -> should be 1, is 1abc ~ /a(b{0,})*c/ -> should be 1, is 1ac ~ /ab{1}c/ -> should be 0, is 0abc ~ /ab{1}c/ -> should be 1, is 1abbc ~ /ab{1}c/ -> should be 0, is 0ac ~ /ab{1,}c/ -> should be 0, is 0abc ~ /ab{1,}c/ -> should be 1, is 1abbc ~ /ab{1,}c/ -> should be 1, is 1abbbc ~ /ab{1,}c/ -> should be 1, is 1abbbbc ~ /ab{1,}c/ -> should be 1, is 1ac ~ /ab{0,1}c/ -> should be 1, is 1abc ~ /ab{0,1}c/ -> should be 1, is 1abbc ~ /ab{0,1}c/ -> should be 0, is 0ac ~ /ab{0,3}c/ -> should be 1, is 1abc ~ /ab{0,3}c/ -> should be 1, is 1abbc ~ /ab{0,3}c/ -> should be 1, is 1abbbc ~ /ab{0,3}c/ -> should be 1, is 1abbbbc ~ /ab{0,3}c/ -> should be 0, is 0ac ~ /ab{1,3}c/ -> should be 0, is 0abc ~ /ab{1,3}c/ -> should be 1, is 1abbc ~ /ab{1,3}c/ -> should be 1, is 1abbbc ~ /ab{1,3}c/ -> should be 1, is 1abbbbc ~ /ab{1,3}c/ -> should be 0, is 0EOF $awk -f prog foo.in > foo2diff foo1 foo2 | sed -n 's/^> //p' || echo 'BAD: T.int-expr: 1' >[1=2]rm -f prog
#!/bin/rc
echo T.int-expr: test interval expressions >[1=2]
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 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
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 ~ /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
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 | sed -n 's/^> //p' || echo 'BAD: T.int-expr: 1' >[1=2]
rm -f prog