summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/fr/frog/test.nix
blob: 7b624e85f3063e850c8675c34f9099160d2b8e2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
  runCommand,
  frog,
}:

runCommand "frog-test" { } ''
  ${frog}/bin/frog >$out <<EOF
  Dit is een test

  EOF
  echo "Frog output:"
  cat $out

  expected () {
    echo "Test expectation failed: $@"
    exit 1
  }

  lines="$(wc -l $out | awk '{print $1}')"
  test 5 = $lines || expected "Five lines of output"
  grep "is" $out | grep "zijn" >/dev/null || expected "Stemming works"
  grep "een" $out | grep "onbep" >/dev/null || expected "Tagging works"

  deps="$(echo $(awk 'BEGIN { FS = "\t*" } ; {print $1 " -> " $9 "; "}' <$out))"
  test "1 -> 2; 2 -> 0; 3 -> 4; 4 -> 2; -> ;" = "$deps" || expected "Dependency parsing works"
''