X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/21bc2db0ec83b235caec38d42f4d0812f473d766..d325d75dac5339f0c25b741122cde5698c62f04e:/tests/general.at diff --git a/tests/general.at b/tests/general.at index bc22e44..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 @@ -115,7 +135,7 @@ 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 >stdout; sed -f check.sed stdout], [0], ]) 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