style: tests: factor file extension computations

* tests/local.at (AT_LANG_HDR): New.
* tests/calc.at, tests/headers.at, tests/synclines.at: Use it, and
AT_LANG_EXT.
This commit is contained in:
Akim Demaille
2018-10-06 16:18:58 +02:00
parent fd3c17995e
commit 53bde230c6
4 changed files with 14 additions and 8 deletions

View File

@@ -495,9 +495,7 @@ AT_BISON_OPTION_PUSHDEFS([$1])
AT_DATA_CALC_Y([$1])
AT_FULL_COMPILE([calc], AT_DEFINES_IF([[lex], [main]]), [], [$2])
AT_CHECK_SPACES(m4_join([ ],
[calc.AT_SKEL_CC_IF([cc], [c])],
[AT_DEFINES_IF([calc.AT_SKEL_CC_IF([hh], [h])])]))
AT_CHECK_SPACES([calc.AT_LANG_EXT AT_DEFINES_IF([calc.AT_LANG_HDR])])
# Test the priorities.
_AT_CHECK_CALC([$1],

View File

@@ -143,7 +143,7 @@ exp:
]AT_YYLEX_DEFINE(["x"])[
]])
AT_BISON_CHECK([-d -o input.AT_SKEL_CC_IF([cc], [c]) input.y])
AT_BISON_CHECK([-d -o input.AT_LANG_EXT input.y])
AT_LANG_COMPILE([input.o])
@@ -154,10 +154,10 @@ AT_MAIN_DEFINE
# Check that the headers are self-contained, and protected against
# multiple inclusions. While at it, check they are sane for C++.
for h in *.AT_SKEL_CC_IF([hh], [h])
for h in *.AT_LANG_HDR
do
# No shell expansion with AT_DATA.
cat >$h.AT_SKEL_CC_IF([cc], [c]) <<EOF
cat >$h.AT_LANG_EXT <<EOF
AT_DATA_SOURCE_PROLOGUE
#include "$h"
#include "$h"
@@ -235,7 +235,7 @@ exp:
]AT_YYLEX_DEFINE(["$1"])[
]])
AT_BISON_CHECK([-d -o $1.AT_SKEL_CC_IF([cc], [c]) $1.y])
AT_BISON_CHECK([-d -o $1.AT_LANG_EXT $1.y])
AT_LANG_COMPILE([$1.o])
AT_CHECK([[echo "$1" >>expout]])

View File

@@ -833,6 +833,14 @@ m4_define([AT_LANG_EXT(c++)], [cc])
m4_define([AT_LANG_EXT(java)], [java])
# AT_LANG_HDR
# -----------
# The header file extension corresponding to the language: c, cc.
m4_define([AT_LANG_HDR], [AT_LANG_DISPATCH([$0], $@)])
m4_define([AT_LANG_HDR(c)], [h])
m4_define([AT_LANG_HDR(c++)], [hh])
# AT_FULL_COMPILE(OUTPUT, [OTHER1], [OTHER2], [EXTRA-COMPILER-FLAGS)
# ------------------------------------------------------------------
# Compile OUTPUT.y to OUTPUT.c, OUTPUT.cc, or OUTPUT.java, and then

View File

@@ -452,7 +452,7 @@ AT_DATA_GRAMMAR([input.y],
%%
exp: '0'
]])
AT_BISON_CHECK([--no-lines -o input.AT_SKEL_CC_IF([cc], [c]) -d input.y])
AT_BISON_CHECK([--no-lines -o input.AT_LANG_EXT -d input.y])
AT_CHECK([[grep '#line' ]AT_SKEL_CC_IF([*.cc *.hh], [*.c *.h])], 1)
AT_BISON_OPTION_POPDEFS