Commit 8aacb975 authored by Kim Nguyễn's avatar Kim Nguyễn

Add some non-regression test script for the parser/pretty-printer.

parent 16ea487d
(** Format of this file
Sequences of :
let xNNN : t = raise []
t must fit on a single line.
This file is to be compiled with cduce --compile --verbose to produce lines of the form:
val xNNN : t
the t part is then read back from the testing script and compared with the original type as
written in the file.
*)
include "prologue.cd"
let x000 : Any = raise []
let x001 : Int = raise []
let x002 : Bool = raise []
let x003 : Char = raise []
let x004 : Atom = raise []
let x005 : Arrow = raise []
let x006 : { .. } = raise []
let x007 : 'a = raise []
let x008 : 'abcd = raise []
let x009 : [ Int | Bool * ] = raise []
let x010 : [ (Int & Int) * ] = raise []
let x011 : (`A | `B | `C) & ('a) = raise []
#!/bin/sh
DIR=$(dirname "$0")
TMP="$DIR"/tmp.cd
INPUT="$DIR"/print.cd
CDUCE="$DIR"/../../cduce
if test ! -x "$CDUCE";
then
echo 'Compile the cduce compiler first'
fi
REGEXP='^ *let *x[0-9]\{3\} *:\(.*\)= *raise *\[ *\] *$'
I=1
cat "$INPUT" | grep "$REGEXP" | while read line;
do
echo -n "Test $I ... "
orig=`echo $line | sed -e "s/$REGEXP/\1/"`
echo 'include "prologue.cd"' > "$TMP"
echo "$line" >> "$TMP"
new=`"$CDUCE" -I "$DIR" --compile --verbose "$TMP" | sed -e 's/val x[0-9]\{3\} ://'`
rm -f "$TMP"o "$TMP"
set -f
for test in "($orig) ($new)" "($new) ($orig)"
do
echo 'include "prologue.cd";;' > "$TMP"
echo "debug subtype $test;;" >> "$TMP"
res=`"$CDUCE" -I "$DIR" < "$TMP" 2>&1 | grep '<=' | sed -e 's/^.*: \(true\|false\)$/\1/'`
rm -f "$TMP" "$TMP"o
if test "$res" != "true";
then
echo "(semantic failed)"
echo "INPUT: $orig"
echo "OUPTUT: $new"
exit 1
fi
done
echo -n "(semantic ok) "
lo=`echo "$orig" | wc -c`
ln=`echo "$new" | wc -c`
rat=`echo 5 k $ln $lo / 100 \* 0 k 1 / p | dc`
if test "$rat" -lt 110;
then
echo "(length ok)"
else
echo "(length failed)"
echo "INPUT: $orig"
echo "OUPTUT: $new"
rm -f "$TMP" "$TMP"o
exit 2
fi
I=$(($I + 1))
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment