diff options
Diffstat (limited to 'tests/match.awk')
| -rw-r--r-- | tests/match.awk | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/match.awk b/tests/match.awk new file mode 100644 index 0000000..8f35452 --- /dev/null +++ b/tests/match.awk @@ -0,0 +1,25 @@ +# Check that all words, pairs, and triples in output ARGV[2] are in original ARGV[1] +BEGIN { + while (getline <ARGV[1] > 0) { + for (i = 1; i <= NF; i++) { + wd[++nw] = $i # input words + single[$i]++ + } + } + for (i = 1; i < nw; i++) + pair[wd[i],wd[i+1]]++ + for (i = 1; i < nw-1; i++) + triple[wd[i],wd[i+1],wd[i+2]]++ + + while (getline <ARGV[2] > 0) { + outwd[++ow] = $0 # output words + if (!($0 in single)) + print "unexpected word:", $0 + } + for (i = 1; i < ow; i++) + if (!((outwd[i],outwd[i+1]) in pair)) + print "unexpected pair:", outwd[i], outwd[i+1] + for (i = 1; i < ow-1; i++) + if (!((outwd[i],outwd[i+1],outwd[i+2]) in triple)) + print "unexpected triple:", outwd[i], outwd[i+1], outwd[i+2] +}
\ No newline at end of file |