Commit 1be14ed0 authored by Kim Nguyễn's avatar Kim Nguyễn

Add other pretty-printer/parser tests.

parent b8e562b5
...@@ -26,3 +26,9 @@ let x008 : 'abcd = raise [] ...@@ -26,3 +26,9 @@ let x008 : 'abcd = raise []
let x009 : [ Int | Bool * ] = raise [] let x009 : [ Int | Bool * ] = raise []
let x010 : [ (Int & Int) * ] = raise [] let x010 : [ (Int & Int) * ] = raise []
let x011 : (`A | `B | `C) & ('a) = raise [] let x011 : (`A | `B | `C) & ('a) = raise []
let x012 : (`A | `B | `C) & ('a | 'b | 'c) = raise []
let x013 : X1 where X1 = [ ( 'a \ [Any*] | X1)* ] = raise []
let x014 : [ ( 'a \ [Any*] )* ] = raise []
let x015 : X1 where X1 = <a > [ X1* ] | <b foo=Int > [ X1* ] = raise []
let x016 : (Atom \ `A \`B) & ('a \ 'b \ 'c) = raise []
let x017 : Atom \ ((`A | `B | `C)) | `test:A = raise []
\ No newline at end of file
namespace test = "test"
\ No newline at end of file
...@@ -5,27 +5,31 @@ DIR=$(dirname "$0") ...@@ -5,27 +5,31 @@ DIR=$(dirname "$0")
TMP="$DIR"/tmp.cd TMP="$DIR"/tmp.cd
INPUT="$DIR"/print.cd INPUT="$DIR"/print.cd
CDUCE="$DIR"/../../cduce CDUCE="$DIR"/../../cduce
rm -f "$TMP" "$TMP"o
if test ! -x "$CDUCE"; if test ! -x "$CDUCE";
then then
echo 'Compile the cduce compiler first' echo 'Compile the cduce compiler first'
fi fi
REGEXP='^ *let *x[0-9]\{3\} *:\(.*\)= *raise *\[ *\] *$' REGEXP='^ *let *x[0-9]\{3\} *:\(.*\)= *raise *\[ *\] *$'
I=1 I=0
cat "$INPUT" | grep "$REGEXP" | while read line; set -f
cat "$INPUT" | grep "$REGEXP" | while read -r line;
do do
echo -n "Test $I ... " echo -n "Test $I ... "
orig=`echo $line | sed -e "s/$REGEXP/\1/"` orig=`echo "$line" | sed -e "s/$REGEXP/\1/"`
echo 'include "prologue.cd"' > "$TMP" echo 'include "prologue.cd"' > "$TMP"
echo "$line" >> "$TMP" echo "$line" >> "$TMP"
new=`"$CDUCE" -I "$DIR" --compile --verbose "$TMP" | sed -e 's/val x[0-9]\{3\} ://'` new=`"$CDUCE" -I "$DIR" --compile --verbose "$TMP" | sed -e 's/val x[0-9]\{3\} ://'`
rm -f "$TMP"o "$TMP" rm -f "$TMP"o "$TMP"
set -f
for test in "($orig) ($new)" "($new) ($orig)" for test in "($orig) ($new)" "($new) ($orig)"
do do
echo 'include "prologue.cd";;' > "$TMP" echo 'include "prologue.cd";;' > "$TMP"
echo "debug subtype $test;;" >> "$TMP" echo "debug subtype $test;;" >> "$TMP"
res=`"$CDUCE" -I "$DIR" < "$TMP" 2>&1 | grep '<=' | sed -e 's/^.*: \(true\|false\)$/\1/'` res=`"$CDUCE" -I "$DIR" < "$TMP" 2>&1 | grep '<=' | sed -e 's/^.*: \(true\|false\)$/\1/'`
rm -f "$TMP" "$TMP"o rm -f "$TMP"o "$TMP"
if test "$res" != "true"; if test "$res" != "true";
then then
echo "(semantic failed)" echo "(semantic failed)"
......
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