#!/bin/sh -e

this=expr
indir=debian/tests
outdir=${ADT_ARTIFACTS:-/tmp}/${this}
mkdir -p ${outdir}

ppx='ppx_deriving_yojson,yojson'
cp ${indir}/${this}.ml ${indir}/expected ${outdir}
cd ${outdir}
ocamlbuild -quiet -use-ocamlfind -pkgs ${ppx} ${this}.byte
./${this}.byte > result
diff result expected

if [ -x /usr/bin/ocamlopt ]
then ocamlbuild -quiet -use-ocamlfind -pkgs ${ppx} ${this}.native;
     ./${this}.native > result
     diff result expected
fi
