From 53bde230c6af83c0648ba49669ce6711d9a8f6e7 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 6 Oct 2018 16:18:58 +0200 Subject: [PATCH] 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. --- tests/calc.at | 4 +--- tests/headers.at | 8 ++++---- tests/local.at | 8 ++++++++ tests/synclines.at | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/calc.at b/tests/calc.at index 5d270dd8..17cecdc3 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -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], diff --git a/tests/headers.at b/tests/headers.at index e6e747b0..490cf1d4 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -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]) <$h.AT_LANG_EXT <>expout]]) diff --git a/tests/local.at b/tests/local.at index 9a0bec15..cc4abc6d 100644 --- a/tests/local.at +++ b/tests/local.at @@ -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 diff --git a/tests/synclines.at b/tests/synclines.at index fb1b6725..95636c68 100644 --- a/tests/synclines.at +++ b/tests/synclines.at @@ -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