autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: m4_combine


From: Eric Blake
Subject: Re: m4_combine
Date: Wed, 17 Oct 2007 20:46:03 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de> writes:

> [1] One could even go as far as saying that untested interfaces are
> broken by definition.  Experience confirms that.

Broken no longer :)

From: Eric Blake <address@hidden>
Date: Wed, 17 Oct 2007 13:51:26 -0600
Subject: [PATCH] Test recent additions.

* tests/m4sugar.at (m4@&address@hidden, m4@&address@hidden)
(m4@&t_max and m4@&t_min): New tests.
* doc/autoconf.texi (Evaluation Macros) <m4_apply>: Enhance
description.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog         |    8 +++
 doc/autoconf.texi |    5 ++-
 tests/m4sugar.at  |  135 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 210f3c8..81b0f78 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-10-17  Eric Blake  <address@hidden>
+
+       Test recent additions.
+       * tests/m4sugar.at (m4@&address@hidden, m4@&address@hidden)
+       (m4@&t_max and m4@&t_min): New tests.
+       * doc/autoconf.texi (Evaluation Macros) <m4_apply>: Enhance
+       description.
+
 2007-10-17  Ralf Wildenhues  <address@hidden>
 
        * TODO: multiline args in config files and headers work now.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 2710a6a..446f89f 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -10707,7 +10707,10 @@ by adding or removing levels of quotes.
 @msindex apply
 Apply the elements of the quoted, comma-separated @var{list} as the
 arguments to @var{macro}.  If @var{list} is empty, invoke @var{macro}
-without arguments.
+without arguments.  Note the difference between @code{m4_indir}, which
+expects its first argument to be a macro name but can use names that are
+otherwise invalid, and @code{m4_apply}, where @var{macro} can contain
+other text, but must end in a valid macro name.
 @example
 m4_apply([m4_count], [])
 @result{}0
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index f42c6c8..dc91fbb 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -518,3 +518,138 @@ script.4s:3: the top level
 autom4te: m4 failed with exit status: 1
 ]])
 AT_CLEANUP
+
+
+## --------------- ##
+## m4_map{,_sep}.  ##
+## --------------- ##
+
+AT_SETUP([m4@&address@hidden)
+AT_KEYWORDS([m4@&address@hidden)
+AT_KEYWORDS([m4@&address@hidden)
+
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_map([m4_count], [])
+m4_map([ m4_count], [[],
+                     [[1]],
+                     [[1], [2]]])
+m4_map_sep([m4_eval], [,], [[[1+2]],
+                            [[10], [16]]])
+m4_define([a], [m4_if([$#], [0], [oops], [$1], [a], [pass], [oops])])dnl
+m4_define([a1], [oops])dnl
+m4_define([pass1], [oops])dnl
+m4_map([a], [[[a]]])1
+m4_map([m4_unquote([a])], [m4_dquote([a])])
+]],
+[[
+ 0 1 2
+3,a
+pass1
+pass
+]], [])
+
+AT_CLEANUP
+
+
+## ------------ ##
+## m4_combine.  ##
+## ------------ ##
+
+AT_SETUP([m4@&address@hidden)
+
+AT_CHECK_M4SUGAR_TEXT([[m4_define([a], [oops])dnl
+m4_combine([, ], [[a], [b], [c]], [-], [1], [2], [3])
+m4_combine([, ], [[a], [b]], [-])
+m4_combine([, ], [[a], [b]], [-], [])
+m4_combine([, ], [], [-], [a], [b])
+m4_combine([, ], [[]], [-], [a], [b])
+m4_combine([ a ], [[-], [+]], [a], [-], [+])
+]],
+[[a-1, a-2, a-3, b-1, b-2, b-3, c-1, c-2, c-3
+
+a-, b-
+
+-a, -b
+-a- a -a+ a +a- a +a+
+]], [])
+
+AT_CLEANUP
+
+
+## -------------- ##
+## m4_{max,min}.  ##
+## -------------- ##
+
+AT_SETUP([m4@&address@hidden and m4@&address@hidden)
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_max
+]])
+
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:1: error: too few arguments to m4@&address@hidden
+script.4s:1: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_min
+]])
+
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:1: error: too few arguments to m4@&address@hidden
+script.4s:1: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_min(0)
+m4_min(0xa)
+m4_min(0, 0)
+m4_min(0, 1)
+m4_min(1, 0)
+m4_min(0+1, 1+1)
+m4_min(0+1, 1+0)
+m4_min(0, 1, 2)
+m4_min(2, 1, 0)
+m4_min(1m4_for([i], 2, 100, , [,i]))
+m4_min(m4_for([i], 100, 2, , [i,])1)
+----
+m4_max(0)
+m4_max(0xa)
+m4_max(0, 0)
+m4_max(0, 1)
+m4_max(1, 0)
+m4_max(1+0, 1+1)
+m4_max(1+0, 1+0)
+m4_max(0, 1, 2)
+m4_max(2, 1, 0)
+m4_max(1m4_for([i], 2, 100, , [,i]))
+m4_max(m4_for([i], 100, 2, , [i,])1)
+]],
+[[0
+10
+0
+0
+0
+1
+1
+0
+0
+1
+1
+----
+0
+10
+0
+1
+1
+2
+1
+2
+2
+100
+100
+]], [])
+
+AT_CLEANUP
-- 
1.5.3.2








reply via email to

[Prev in Thread] Current Thread [Next in Thread]