5 # Copyright (C) 2000, 2001, 2002, 2005, 2006, 2007, 2008 Free Software
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 # AT_CHECK_M4SUGAR_TEXT(CODE, STDOUT, STDERR)
25 # -------------------------------------------
26 # Check that m4sugar CODE expands to STDOUT and emits STDERR.
27 m4_define([AT_CHECK_M4SUGAR_TEXT],
29 AT_DATA_M4SUGAR([script.4s],
31 m4_divert_push(0)[]dnl
36 AT_CHECK_M4SUGAR([-o-],, [$2], [$3])
37 ])# AT_CHECK_M4SUGAR_TEXT
44 # uses warn/error code.
59 AT_SETUP([m4@&t@_defn])
61 AT_KEYWORDS([m4@&t@_popdef m4@&t@_undefine])
63 # Ensure that m4sugar dies when dereferencing undefined macros, whether
64 # this is provided by m4 natively or faked by wrappers in m4sugar.
66 AT_DATA_M4SUGAR([script.4s],
68 m4_defn([good], [oops])
71 AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
72 AT_CHECK([grep good stderr], [1])
73 AT_CHECK([grep 'm4@&t@_defn: undefined.*oops' stderr], [0], [ignore])
75 AT_DATA_M4SUGAR([script.4s],
77 m4_popdef([good], [oops])
80 AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
81 AT_CHECK([grep good stderr], [1])
82 AT_CHECK([grep 'm4@&t@_popdef: undefined.*oops' stderr], [0], [ignore])
84 AT_DATA_M4SUGAR([script.4s],
86 m4_undefine([good], [oops])
89 AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
90 AT_CHECK([grep good stderr], [1])
91 AT_CHECK([grep 'm4@&t@_undefine: undefined.*oops' stderr], [0], [ignore])
100 AT_SETUP([m4@&t@_warn])
102 # m4_text_wrap is used to display the help strings. Also, check that
103 # commas are not swallowed. This can easily happen because of
106 # FIXME: For the time being we use -f to make sure we do issue the
107 # warnings. But maybe autom4te should handle that by itself?
109 AT_DATA_M4SUGAR([script.4s],
111 m4_defun([cross_warning], [m4_warn([cross], [cross])])
114 m4_warn([obsolete], [obsolete])dnl
116 m4_warn([syntax], [syntax])dnl
119 AT_CHECK_M4SUGAR([-o-], 0, [],
120 [script.4s:7: warning: syntax
123 AT_CHECK_M4SUGAR([-o- -Wall -f], 0, [],
124 [script.4s:5: warning: obsolete
125 script.4s:6: warning: cross
126 script.4s:2: cross_warning is expanded from...
127 script.4s:6: the top level
128 script.4s:7: warning: syntax
131 AT_CHECK_M4SUGAR([-o- -Wnone,cross -f], 0, [],
132 [script.4s:6: warning: cross
133 script.4s:2: cross_warning is expanded from...
134 script.4s:6: the top level
137 AT_CHECK_M4SUGAR([-o- -Wnone,cross,error -f], 1, [],
138 [[script.4s:6: warning: cross
139 script.4s:2: cross_warning is expanded from...
140 script.4s:6: the top level
146 ## --------------------------- ##
147 ## m4_require: error message. ##
148 ## --------------------------- ##
150 AT_SETUP([m4@&t@_require: error message])
152 AT_DATA_M4SUGAR([script.4s],
153 [[m4_defun([foo], [FOO])
157 AT_CHECK_M4SUGAR([], 1, [],
158 [[script.4s:2: error: m4@&t@_require(foo): cannot be used outside of an m4_defun'd macro
159 script.4s:2: the top level
160 autom4te: m4 failed with exit status: 1
165 ## ----------------------------------- ##
166 ## m4_require: circular dependencies. ##
167 ## ----------------------------------- ##
169 AT_SETUP([m4@&t@_require: circular dependencies])
171 AT_DATA_M4SUGAR([script.4s],
172 [[m4_defun([foo], [m4_require([bar])])
174 m4_defun([bar], [m4_require([foo])])
176 m4_defun([baz], [m4_require([foo])])
183 AT_CHECK_M4SUGAR([], 1, [],
184 [[script.4s:9: error: m4@&t@_require: circular dependency of foo
185 script.4s:3: bar is expanded from...
186 script.4s:1: foo is expanded from...
187 script.4s:5: baz is expanded from...
188 script.4s:9: the top level
189 autom4te: m4 failed with exit status: 1
198 AT_SETUP([m4@&t@_cond])
200 AT_CHECK_M4SUGAR_TEXT([[m4_define([side], [m4_errprintn([$1])$1])
201 m4_cond([side(1)], [1], [a],
204 m4_cond([side(2)], [1], [a],
208 m4_cond([side(3)], [1], [a],
212 m4_cond([a,a], [a,a], [yes], [no])
213 m4_cond([[a,a]], [a,a], [yes])
214 m4_cond([a,a], [a,b], [yes], [no])
215 m4_cond([a,a], [a,b], [yes])
216 m4_cond([m4_eval([0xa])])
217 m4_define([ab], [AB])dnl
219 m4_cond([1], [1], [a])b
220 m4_cond([1], [2], [3], [a])b
250 AT_SETUP([m4@&t@_split])
252 AT_CHECK_M4SUGAR_TEXT(
253 [[m4_define([active], [ACT, IVE])m4_define([bd], [oops])
258 m4_split([ active active ])end
260 m4_split([active], [ ])
261 m4_split([ active active ], [ ])end
262 m4_split([abcde], [bd])
263 m4_split([abcde], [[bd]])
264 m4_split([foo=`` bar=''])
265 m4_split([foo='' bar=``])
266 dnl these next two are from the manual; keep this in sync if the internal
267 dnl quoting strings in m4_split are changed
268 m4_define([a], [A])m4_define([b], [B])m4_define([c], [C])dnl
269 m4_split([a )}>=- b -=<{( c])
270 m4_split([a )}@&t@>=- b -=<@&t@{( c])
277 [], [active], [active], []end
280 [], [active active], []end
285 [a], [], [B], [], [c]
286 [a], [)}>=-], [b], [-=<{(], [c]
296 AT_SETUP([m4@&t@_do])
298 AT_CHECK_M4SUGAR_TEXT(
299 [[m4_define([ab], [1])m4_define([bc], [2])m4_define([abc], [3])dnl
300 m4_define([AB], [4])m4_define([BC], [5])m4_define([ABC], [6])dnl
304 m4_unquote(m4_join([], [a], [b]))c
305 m4_define([a], [A])m4_define([b], [B])m4_define([c], [C])dnl
307 m4_unquote(m4_join([], [a], [b]))c
324 AT_SETUP([m4@&t@_append])
326 AT_CHECK_M4SUGAR_TEXT(
327 [[m4_define([active], [ACTIVE])dnl
328 m4_append([sentence], [This is an])dnl
329 m4_append([sentence], [ active ])dnl
330 m4_append([sentence], [symbol.])dnl
332 m4_undefine([active])dnl
334 m4_define([active], [ACTIVE])dnl
335 m4_append([hooks], [m4_define([act1], [act2])])dnl
336 m4_append([hooks], [m4_define([act2], [active])])dnl
337 m4_undefine([active])dnl
341 dnl Test for bug fixed in 2.62 when separator is active.
342 m4_define([a], [A])dnl
343 m4_append_uniq([foo], [-], [a])dnl
344 m4_append_uniq([foo], [-], [a])dnl
345 m4_append_uniq([bar], [-], [a])dnl
346 m4_append_uniq([bar], [~], [a])dnl
347 m4_append_uniq([bar], [-], [a])dnl
352 m4_append_uniq([blah], [one], [, ], [new], [existing])
353 m4_append_uniq([blah], [two], [, ], [new], [existing])
354 m4_append_uniq([blah], [two], [, ], [new], [existing])
355 m4_append_uniq([blah], [three], [, ], [new], [existing])
356 m4_append([blah], [two], [, ])dnl
359 m4_append([list], [one], [[, ]])dnl
360 m4_append([list], [two], [[, ]])dnl
361 m4_append([list], [three], [[, ]])dnl
364 m4_append_uniq_w([numbers], [1 1 2])dnl
365 m4_append_uniq_w([numbers], [ 2 3 ])dnl
368 [[This is an ACTIVE symbol.
369 This is an active symbol.
382 [one],[two],[three],[two]
388 AT_DATA_M4SUGAR([script.4s],
389 [[m4_append_uniq([str], [a], [ ])
390 m4_append_uniq([str], [a b], [ ])
395 AT_CHECK_M4SUGAR([-o-], 0, [[a a b
396 ]], [[script.4s:2: warning: m4@&t@_append_uniq: `a b' contains ` '
406 AT_SETUP([m4@&t@_join])
408 AT_KEYWORDS([m4@&t@_joinall])
410 AT_CHECK_M4SUGAR_TEXT(
411 [[m4_define([active], [ACTIVE])
414 m4_join([, ], [one], [two])
415 m4_dquote(m4_join([, ], [one], [two]))
416 m4_join([|], [active], [active])
417 m4_join([|], ,,,[one])
418 m4_join([|], [one],,,)
419 m4_join([], ,,,[two])
420 m4_join([], [two],,,)
421 m4_join([ active ], [one], , [two])
422 m4_join([], [one], [two])
423 m4_joinall([-], [one], [], [two])
424 m4_joinall([-], [], [], [three], [], [])
425 m4_joinall([], [one], [], [two])
428 m4_joinall([-], [one])
457 AT_SETUP([m4@&t@_text_wrap])
459 # m4_text_wrap is used to display the help strings. Also, check that
460 # commas and $ are not swallowed. This can easily happen because of
463 AT_DATA_M4SUGAR([script.4s],
465 m4_text_wrap([Short string */], [ ], [/* ], 20)
467 m4_text_wrap([Much longer string */], [ ], [/* ], 20)
469 m4_text_wrap([Short doc.], [ ], [ --short ], 30)
471 m4_text_wrap([Short doc.], [ ], [ --too-wide], 30)
473 m4_text_wrap([Super long documentation.], [ ], [ --too-wide], 30)
475 m4_text_wrap([First, second , third, [,quoted]])
476 m4_define([xfff], [oops])
477 m4_text_wrap([Some $1 $2 $3 $4 embedded dollars.], [ $* ], [ $@ ], [0xfff & 20])
495 First, second , third, [,quoted]
502 AT_CHECK_M4SUGAR([-o-], 0, [expout])
506 ## -------------------- ##
507 ## m4_version_compare. ##
508 ## -------------------- ##
510 AT_SETUP([m4@&t@_version_compare])
512 AT_KEYWORDS([m4@&t@_list_cmp])
514 AT_CHECK_M4SUGAR_TEXT(
515 [[m4_version_compare([1.1], [2.0])
516 m4_version_compare([2.0b], [2.0a])
517 m4_version_compare([2.0z], [2.0y])
518 m4_version_compare([1.1.1], [1.1.1a])
519 m4_version_compare([1.2], [1.1.1a])
520 m4_version_compare([1.0], [1])
521 m4_version_compare([1.0a], [1.0a])
522 m4_version_compare([1.1a], [1.1a.1])
523 m4_version_compare([1.10], [1.1a])
524 m4_version_compare([1-1a], [1,1A])
525 m4_define([a], [oops])dnl
526 m4_version_compare([1.1a], [1.1A])
527 m4_version_compare([1z], [1aa])
528 m4_version_compare([2.61a], [2.61a-248-dc51])
529 m4_version_compare([2.61b], [2.61a-248-dc51])
549 ## ------------------------------ ##
550 ## Standard regular expressions. ##
551 ## ------------------------------ ##
553 AT_SETUP([Standard regular expressions])
555 # AT_CHECK_M4RE(RE-NAME, TEXT, INTENT = `ok' | `')
556 # ------------------------------------------------
557 # Check whether RE-NAME (a macro whose definition is a regular expression)
558 # matches TEXT. INTENT = `ok' if the match should succeed or else empty.
559 m4_define([AT_CHECK_M4RE],
560 [AT_CHECK_M4SUGAR_TEXT(
561 [[m4_bregexp([$2], ^m4_defn([$1])$, [ok])
565 AT_CHECK_M4RE([m4_re_word], [ab9_c], [ok])
566 AT_CHECK_M4RE([m4_re_word], [_9abc], [ok])
567 AT_CHECK_M4RE([m4_re_word], [9ab_c])
569 AT_CHECK_M4RE([m4_re_string], [ab9_c], [ok])
570 AT_CHECK_M4RE([m4_re_string], [_9abc], [ok])
571 AT_CHECK_M4RE([m4_re_string], [9ab_c], [ok])
572 AT_CHECK_M4RE([m4_re_string], [9a@_c])
580 AT_SETUP([m4@&t@_bmatch])
582 AT_CHECK_M4SUGAR_TEXT(
583 [[m4_bmatch([abc], [default\])
584 m4_bmatch([abc], [^a], [yes])
585 m4_bmatch([abc], [^a], [yes], [no])
586 m4_bmatch([abc], [^.a], [yes])
587 m4_bmatch([abc], [^.a], [yes], [no\])
588 m4_bmatch([abc], [a], [1], [b], [2])
589 m4_bmatch([abc], [A], [1], [b], [2])
590 m4_define([ab], [AB])dnl
591 m4_bmatch([$*], [a])b
592 m4_bmatch([$*], [\*], [a])b
593 m4_bmatch([$*], [1], [2], [a])b
608 ## --------------- ##
610 ## --------------- ##
612 AT_SETUP([m4@&t@_bpatsubsts])
614 AT_CHECK_M4SUGAR_TEXT(
615 [[m4_bpatsubsts([11], [^..$])
616 m4_bpatsubsts([11], [\(.\)1], [\12])
617 m4_bpatsubsts([11], [^..$], [], [1], [2])
618 m4_bpatsubsts([11], [\(.\)1], [\12], [1], [3])
619 m4_define([a], [oops])m4_define([c], [oops])dnl
620 m4_define([AB], [good])m4_define([bc], [good])dnl
621 m4_bpatsubsts([abc], [a], [A], [b], [B], [c])
622 m4_bpatsubsts([ab], [a])c
623 m4_bpatsubsts([ab], [c], [C], [a])c
624 m4_bpatsubsts([$1$*$@], [\$\*], [$#])
643 AT_CHECK_M4SUGAR_TEXT([[dnl
644 m4_define([myvar], [outer value])dnl
645 m4_for([myvar], 1, 3, 1, [ myvar])
646 m4_for([myvar], 1, 3, , [ myvar])
647 m4_for([myvar], 3, 1,-1, [ myvar])
648 m4_for([myvar], 3, 1, , [ myvar])
649 m4_for([myvar], 1, 3, 2, [ myvar])
650 m4_for([myvar], 3, 1,-2, [ myvar])
651 m4_for([myvar],-1,-3,-2, [ myvar])
652 m4_for([myvar],-3,-1, 2, [ myvar])
653 dnl Make sure we recalculate the bounds correctly:
654 m4_for([myvar], 1, 3, 3, [ myvar])
655 m4_for([myvar], 1, 6, 3, [ myvar])
656 m4_for([myvar],22,-7,-5, [ myvar])
657 m4_for([myvar],-2,-7,-4, [ myvar])
658 m4_for([myvar],-7,-2, 4, [ myvar])
659 dnl Make sure we are not exposed to division truncation:
660 m4_for([myvar], 2, 5, 2, [ myvar])
661 m4_for([myvar],-5,-2, 2, [ myvar])
662 m4_for([myvar], 5, 2,-2, [ myvar])
663 m4_for([myvar],-2,-5,-2, [ myvar])
664 dnl Make sure we do not divide by zero:
665 m4_for([myvar], 1, 1, , [ myvar])
666 m4_for([myvar], 1, 1,+2, [ myvar])
667 m4_for([myvar], 1, 1,-2, [ myvar])
668 dnl Make sure we do not loop endlessly
669 m4_for([myval], 1, 1, 0, [ myval])
670 dnl Make sure to properly parenthesize
671 m4_for([myvar], 3-5, -2+8, , [ myvar])
672 m4_for([myvar], -2+8, 3-5, , [ myvar])
673 m4_for([myvar], 8, 16, 3 * 2, [ myvar])
674 m4_for([myvar], 8, 16, -3 * -2, [ myvar])
675 m4_for([myvar], [2<<2], [2<<3], [-3 * (-2)], [ myvar])
676 dnl Modifying var does not affect the number of iterations
677 m4_for([myvar], 1, 5, , [ myvar[]m4_define([myvar], 5)])
678 dnl Make sure we can do nameless iteration
681 m4_foreach([myvar], [[a], [b, c], [d], [e
683 m4_foreach_w([myvar], [a b c, d,e f
721 AT_DATA_M4SUGAR([script.4s],
724 m4_for([myvar], 1, 3,-1, [ myvar])
727 AT_CHECK_M4SUGAR([], 1, [],
728 [[script.4s:3: error: assert failed: -1 > 0
729 script.4s:3: the top level
730 autom4te: m4 failed with exit status: 1
733 AT_DATA_M4SUGAR([script.4s],
736 m4_for([myvar], 1, 2, 0, [ myvar])
739 AT_CHECK_M4SUGAR([], 1, [],
740 [[script.4s:3: error: assert failed: 0 > 0
741 script.4s:3: the top level
742 autom4te: m4 failed with exit status: 1
745 AT_DATA_M4SUGAR([script.4s],
748 m4_for([myvar], 2, 1, 0, [ myvar])
751 AT_CHECK_M4SUGAR([], 1, [],
752 [[script.4s:3: error: assert failed: 0 < 0
753 script.4s:3: the top level
754 autom4te: m4 failed with exit status: 1
760 ## --------------------- ##
761 ## m4_map{,all}{,_sep}. ##
762 ## --------------------- ##
764 AT_SETUP([m4@&t@_map])
765 AT_KEYWORDS([m4@&t@_apply m4@&t@_map_sep m4@&t@_mapall m4@&t@_mapall_sep])
766 AT_KEYWORDS([m4@&t@_count])
768 AT_CHECK_M4SUGAR_TEXT([[dnl
769 m4_map([m4_count], [])
770 m4_map([ m4_count], [[],
773 m4_mapall([ m4_count], [[],
776 m4_map_sep([m4_eval], [,], [[[1+2]],
778 m4_count(m4_map_sep([m4_echo], [,], [[], [[1]], [[2]]]))
779 m4_count(m4_mapall_sep([m4_echo], [,], [[], [[1]], [[2]]]))
780 m4_map_sep([m4_eval], [[,]], [[[1+2]],
782 m4_count(m4_map_sep([m4_echo], [[,]], [[], [[1]], [[2]]]))
783 m4_count(m4_mapall_sep([m4_echo], [[,]], [[], [[1]], [[2]]]))
786 m4_map_sep([-], [:], [[]])
787 m4_mapall_sep([-], [:], [[]])
788 m4_define([a], [m4_if([$#], [0], [oops], [$1], [a], [pass], [oops])])dnl
789 m4_define([a1], [oops])dnl
790 m4_define([pass1], [oops])dnl
791 m4_map([a], [[[a]]])1
792 m4_map([m4_unquote([a])], [m4_dquote([a])])
818 AT_SETUP([m4@&t@_combine])
820 AT_CHECK_M4SUGAR_TEXT([[m4_define([a], [oops])dnl
821 m4_combine([, ], [[a], [b], [c]], [-], [1], [2], [3])
822 m4_combine([, ], [[a], [b]], [-])
823 m4_combine([, ], [[a], [b]], [-], [])
824 m4_combine([, ], [], [-], [a], [b])
825 m4_combine([, ], [[]], [-], [a], [b])
826 m4_combine([ a ], [[-], [+]], [a], [-], [+])
827 m4_combine([$* ], [[$1], [$2]], [$#], [$@])
829 [[a-1, a-2, a-3, b-1, b-2, b-3, c-1, c-2, c-3
834 -a- a -a+ a +a- a +a+
845 AT_SETUP([m4@&t@_max and m4@&t@_min])
847 AT_DATA_M4SUGAR([script.4s],
851 AT_CHECK_M4SUGAR([], 1, [],
852 [[script.4s:1: error: too few arguments to m4@&t@_max
853 script.4s:1: the top level
854 autom4te: m4 failed with exit status: 1
857 AT_DATA_M4SUGAR([script.4s],
861 AT_CHECK_M4SUGAR([], 1, [],
862 [[script.4s:1: error: too few arguments to m4@&t@_min
863 script.4s:1: the top level
864 autom4te: m4 failed with exit status: 1
867 AT_CHECK_M4SUGAR_TEXT([[dnl
877 m4_min(1m4_for([i], 2, 100, , [,i]))
878 m4_min(m4_for([i], 100, 2, , [i,])1)
889 m4_max(1m4_for([i], 2, 100, , [,i]))
890 m4_max(m4_for([i], 100, 2, , [i,])1)
924 AT_SETUP([recursion])
926 AT_KEYWORDS([m4@&t@_foreach m4@&t@_foreach_w m4@&t@_case m4@&t@_cond
927 m4@&t@_bpatsubsts m4@&t@_shiftn m4@&t@_do m4@&t@_dquote_elt m4@&t@_reverse
928 m4@&t@_map m4@&t@_join m4@&t@_joinall m4@&t@_list_cmp m4@&t@_max m4@&t@_min
929 m4@&t@_bmatch m4@&t@_transform m4@&t@_transform_pair])
931 dnl This test completes in a reasonable time if m4_foreach is linear,
932 dnl but thrashes if it is quadratic. If we are testing with m4 1.4.x,
933 dnl only the slower foreach.m4 implementation will work. But if we
934 dnl are testing with m4 1.6, we can rerun the test with __m4_version__
935 dnl undefined to exercise the alternate code path.
936 AT_DATA_M4SUGAR([script.4s],
938 m4_divert_push(0)[]dnl
939 m4_len(m4_foreach_w([j], m4_do(m4_for([i], [1], [10000], [], [,i ])), [j ]))
940 m4_shiftn(9998m4_for([i], [1], [10000], [], [,i]))
941 m4_len(m4_join([--],, m4_dquote_elt(m4_for([i], [1], [10000], [], [,i])),))
942 m4_len(m4_joinall([--], m4_map([, m4_echo],
943 m4_dquote([1]m4_for([i], [2], [10000], [], [,i])))))
944 m4_max(m4_min([1]m4_for([i], [2], [10000], [],
945 [,i]))m4_for([i], [2], [10000], [], [,i]))
946 m4_case([10000]m4_for([i], [1], [10000], [], [,i]),[end])
947 m4_list_cmp(m4_dquote(1m4_for([i], [2], [10000], [], [,i])),
948 m4_dquote(m4_reverse(10000m4_for([i], [9999], [1], [], [,i])), [0]))
949 m4_list_cmp([0], [0m4_for([i], [1], [10000], [], [,0])])
950 m4_list_cmp([0m4_for([i], [1], [10000], [], [,0])], [0])
951 m4_for([i], [1], [10000], [], [m4_define(i)])dnl
952 m4_undefine(1m4_for([i], [2], [10000], [], [,i]))dnl
953 m4_bpatsubsts([a1]m4_for([i], [1], [10000], [], [,i]), [a2], [A])
954 m4_bmatch([9997]m4_for([i], [1], [10000], [], [,^i$]))
955 m4_define([up], [m4_define([$1], m4_incr($1))$1])m4_define([j], 0)dnl
956 m4_cond(m4_for([i], [1], [10000], [], [[up([j])], [9990], i,]) [oops]) j
957 m4_count(m4_transform_pair([,m4_quote], []m4_transform([,m4_echo]m4_for([i],
958 [1], [10000], [], [,i]))))
962 AT_CHECK_M4SUGAR([-o-], [0], [[48894
977 AT_DATA_M4SUGAR([script.4s],
978 [[m4_ifdef([__m4_version__],
979 [m4_undefine([__m4_version__])],
980 [m4_divert_push(0)48894
995 m4_divert_push(0)[]dnl
996 m4_len(m4_foreach_w([j], m4_do(m4_for([i], [1], [10000], [], [,i ])), [j ]))
997 m4_shiftn(9998m4_for([i], [1], [10000], [], [,i]))
998 m4_len(m4_join([--],, m4_dquote_elt(m4_for([i], [1], [10000], [], [,i])),))
999 m4_len(m4_joinall([--], m4_map([, m4_echo],
1000 m4_dquote([1]m4_for([i], [2], [10000], [], [,i])))))
1001 m4_max(m4_min([1]m4_for([i], [2], [10000], [],
1002 [,i]))m4_for([i], [2], [10000], [], [,i]))
1003 m4_case([10000]m4_for([i], [1], [10000], [], [,i]),[end])
1004 m4_list_cmp(m4_dquote(1m4_for([i], [2], [10000], [], [,i])),
1005 m4_dquote(m4_reverse(10000m4_for([i], [9999], [1], [], [,i])), [0]))
1006 m4_list_cmp([0], [0m4_for([i], [1], [10000], [], [,0])])
1007 m4_list_cmp([0m4_for([i], [1], [10000], [], [,0])], [0])
1008 m4_for([i], [1], [10000], [], [m4_define(i)])dnl
1009 m4_undefine(1m4_for([i], [2], [10000], [], [,i]))dnl
1010 m4_bpatsubsts([a1]m4_for([i], [1], [10000], [], [,i]), [a2], [A])
1011 m4_bmatch([9997]m4_for([i], [1], [10000], [], [,^i$]))
1012 m4_define([up], [m4_define([$1], m4_incr($1))$1])m4_define([j], 0)dnl
1013 m4_cond(m4_for([i], [1], [10000], [], [[up([j])], [9990], i,]) [oops])
1014 m4_count(m4_transform_pair([,m4_quote], []m4_transform([,m4_echo]m4_for([i],
1015 [1], [10000], [], [,i]))))
1019 AT_CHECK_M4SUGAR([-o-], [0], [[48894
1041 AT_SETUP([m4@&t@_set])
1043 AT_KEYWORDS([m4@&t@_set_add m4@&t@_set_add_all m4@&t@_set_contains
1044 m4@&t@_set_contents m4@&t@_set_delete m4@&t@_set_difference m4@&t@_set_dump
1045 m4@&t@_set_empty m4@&t@_set_foreach m4@&t@_set_intersection m4@&t@_set_list
1046 m4@&t@_set_listc m4@&t@_set_remove m4@&t@_set_size m4@&t@_set_union])
1049 AT_CHECK_M4SUGAR_TEXT([[m4_set_contains([a], [1], [yes], [no])
1050 m4_set_add([a], [1], [added], [dup])
1051 m4_set_contains([a], [1], [yes], [no])
1052 m4_set_add([a], [1], [added], [dup])
1053 m4_set_contents([a])
1054 m4_set_remove([a], [1], [removed], [missing])
1055 m4_set_contains([a], [1], [yes], [no])
1056 m4_set_remove([a], [1], [removed], [missing])
1057 m4_set_add([a], [2], [added], [dup])
1058 m4_set_empty([a], [yes], [no])
1060 m4_set_empty([a], [yes], [no])
1061 m4_set_add_all([c], [1], [2], [3])
1062 m4_set_add_all([a]m4_set_listc([c]))
1063 m4_set_contents([c], [-])
1064 m4_set_dump([a], [-])
1065 m4_set_contents([a])
1066 m4_set_add_all([a], [1], [2], [3])m4_set_add_all([b], [3], [], [4])
1067 m4_set_difference([a], [b])
1068 m4_set_difference([b], [a])
1069 m4_set_intersection([a], [b])
1070 m4_set_union([a], [b])
1071 m4_set_foreach([a], [i], [m4_if(m4_eval(i & 1), [1], [m4_set_remove([a], i)])])
1075 m4_set_remove([a], [2])
1076 m4_dquote(m4_set_list([a]))
1080 m4_dquote(m4_set_list([a]))
1081 m4_indir([m4_dquote]m4_set_listc([a]))
1121 # Stress tests - check for unusual names/values
1122 AT_CHECK_M4SUGAR_TEXT([[m4_define([a], [oops])dnl
1123 m4_set_add([a], [a])dnl
1124 m4_set_remove([a], [oops], [yes], [no])
1125 m4_set_add([a,b], [c])dnl
1126 m4_set_add([a,b], [$*[]])dnl
1127 m4_set_add_all([a], [b,c])dnl
1129 m4_count(m4_set_contents([a], [,]))
1130 m4_count(m4_set_list([a], [,]))
1131 m4_set_dump([a], [,])
1132 m4_set_contents([a,b], [,])
1134 m4_set_foreach([$*[]], [$*[]], [oops])
1135 m4_set_add([$*[]], [])dnl
1136 m4_set_remove([$*[]], [a], [yes], [no])
1137 m4_set_add([$*[]], [a])dnl
1138 m4_set_foreach([$*[]], [$*[]], [-m4_defn([$*[]])m4_indir([$*[]])-])
1139 m4_set_remove([$*[]], [], [yes], [no])
1140 m4_set_add([c], [,])dnl
1141 m4_set_foreach([a,b], [set], [:m4_set_listc(_m4_defn([set])):])
1156 # Stress tests - check for linear scaling (won't necessarily fail if
1157 # quadratic, but hopefully users will complain if it appears to hang)
1158 AT_CHECK_M4SUGAR_TEXT([[dnl
1159 m4_for([i], [1], [10000], [], [m4_set_add([a], i)])dnl
1160 m4_set_add_all([b]m4_for([i], [1], [10000], [], [,i]))dnl
1161 m4_set_remove([a], [1])dnl
1162 m4_set_remove([b], [10000])dnl
1163 m4_set_add_all([a]m4_for([i], [1], [10000], [], [,i]))dnl
1164 m4_for([i], [1], [10000], [], [m4_set_add([b], i)])dnl
1165 m4_len(m4_set_contents([a]))
1166 m4_len(m4_set_foreach([b], [b], [m4_if(m4_eval(b & 1), [1],
1167 [m4_set_remove([b], b, [-])])]))
1169 m4_count(m4_shift(m4_set_intersection([a], [b])))