X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/663aa8d7a7aa6910f188ac6aa5ccb2c078ad90c8..d325d75dac5339f0c25b741122cde5698c62f04e:/tests/general.at
diff --git a/tests/general.at b/tests/general.at
index 35c9dbb..c40d6b5 100644
--- a/tests/general.at
+++ b/tests/general.at
@@ -1,4 +1,4 @@
-# Copyright © 2012, 2020-2021, 2023 Nick Bowler
+# Copyright © 2012, 2020-2021, 2023-2024 Nick Bowler
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -63,13 +63,33 @@ AT_CLEANUP
AT_SETUP([cdecl99 help command])
-AT_DATA([input], [[help
+AT_DATA([input],
+[[help
explain int
]])
-AT_CHECK([cdecl99 -f input], [0], [stdout])
-AT_CHECK([sed -n '$p' stdout], [0], [type int
-])
+# Program to generate expected output based on src/execute.gperf
+AT_DATA([expout.sed],
+[[#n
+/^%%$/,/^%%$/ {
+ s/^exit.*//
+ s/,.*//p
+}
+$a\
+type int
+]])
+sed -f expout.sed "$srcdir/src/execute.gperf" >expout
+
+# Program to filter the help output to extract the command list from "help"
+# without any descriptions.
+AT_DATA([filter.sed],
+[[/^ /,$ !d
+/^ /d
+s/^ *\([^ ]*\).*/\1/
+]])
+
+AT_CHECK([LC_ALL=C cdecl99 -f input >stdout && sed -f filter.sed stdout],
+ [0], [expout])
AT_CLEANUP
@@ -104,6 +124,7 @@ AT_DATA([input],
[[explain int a b c
simplify int a b c
declare a as b c
+bad command
]])
AT_DATA([check.awk],
@@ -114,21 +135,27 @@ END { exit(status); }
]])
AT_CHECK([LC_ALL=C cdecl99 --file=input || exit 42], [42], [], [stderr])
-AT_CHECK([$AWK -v progname="$progname" -f check.awk stderr])
+AT_CHECK([$AWK -f check.awk progname="$progname" stderr])
+
+exec 3test.dat <<'EOF'
-BEGIN {
+$AWK 'BEGIN {
print "explain \1";
print "explain \377";
print "explain \a";
print "explain \b";
print "explain ?";
-}
-EOF
+}' >test.dat /d' stdout], [0], [declare x as int
+AT_CHECK([cdecl99 --quiet --interactive [eq]/d
+:loop
+s/^> //
+t loop
+/^$/d
+]])
+
+AT_CHECK([echo >>stdout; sed -f check.sed stdout], [0],
+[declare x as int
])
AT_CLEANUP
+
+AT_SETUP([cdecl99 EOF in batch mode])
+
+AT_CHECK([AS_ECHO_N(["explain int"]) | cdecl99 --batch | head], [0],
+[[type int
+]])
+AT_CHECK([cdecl99 --batch