shithub: MicroHs

Download patch

ref: 4c42805ee9262181d4fc8a6b3a92472353388236
parent: 8b59f46062a8793125a4f0c321f5f70142984005
author: Lennart Augustsson <lennart@augustsson.net>
date: Fri Oct 13 09:18:15 EDT 2023

Start of error message testing.

--- /dev/null
+++ b/tests/errmsg.test
@@ -1,0 +1,15 @@
+x = y
+-----
+mhs: "../tmp/E.hs": line 3, col 1: undefined no type signature: x
+=====
+x :: Int
+x = y
+-----
+mhs: "../tmp/E.hs": line 4, col 5: undefined variable: y
+=====
+x :: T
+x = 1
+-----
+mhs: "../tmp/E.hs": line 3, col 6: undefined variable: T
+=====
+END
--- /dev/null
+++ b/tests/errtester.sh
@@ -1,0 +1,38 @@
+# Split the input file and test each snippet for the correct error message.
+IFS=""
+tmp=../tmp
+out=$tmp/E.hs
+err=$tmp/err
+cerr=$tmp/cerr
+comp=../bin/mhs
+read -r line
+while [ "$line" != "END" ]; do
+    echo "module E(module E) where" > $out
+    echo "import Prelude" >> $out
+    while true; do
+        if [ "$line" = "-----" ]; then
+            break
+        fi
+        echo "$line" >> $out
+        read -r line
+    done
+    cp /dev/null $err
+    read -r line
+    while true; do
+        if [ "$line" = "=====" ]; then
+            break
+        fi
+        echo "$line" >> $err
+        read -r line
+    done
+    read -r line
+
+    #echo "Trying:"
+    #cat $out
+    #echo "---"
+    #cat $err
+    #echo "==="
+    #echo "next: $line"
+    $comp -i../lib -i../tmp E 2>&1 | sed -e '/CallStack/,$d' > $cerr
+    diff $err $cerr
+done
--