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])
576 ## --------------- ##
578 ## --------------- ##
580 AT_SETUP([m4@&t@_bpatsubsts])
582 AT_CHECK_M4SUGAR_TEXT(
583 [[m4_bpatsubsts([11], [^..$])
584 m4_bpatsubsts([11], [\(.\)1], [\12])
585 m4_bpatsubsts([11], [^..$], [], [1], [2])
586 m4_bpatsubsts([11], [\(.\)1], [\12], [1], [3])
587 m4_define([a], [oops])m4_define([c], [oops])dnl
588 m4_define([AB], [good])m4_define([bc], [good])dnl
589 m4_bpatsubsts([abc], [a], [A], [b], [B], [c])
590 m4_bpatsubsts([ab], [a])c
591 m4_bpatsubsts([ab], [c], [C], [a])c
592 m4_bpatsubsts([$1$*$@], [\$\*], [$#])
611 AT_CHECK_M4SUGAR_TEXT([[dnl
612 m4_define([myvar], [outer value])dnl
613 m4_for([myvar], 1, 3, 1, [ myvar])
614 m4_for([myvar], 1, 3, , [ myvar])
615 m4_for([myvar], 3, 1,-1, [ myvar])
616 m4_for([myvar], 3, 1, , [ myvar])
617 m4_for([myvar], 1, 3, 2, [ myvar])
618 m4_for([myvar], 3, 1,-2, [ myvar])
619 m4_for([myvar],-1,-3,-2, [ myvar])
620 m4_for([myvar],-3,-1, 2, [ myvar])
621 dnl Make sure we recalculate the bounds correctly:
622 m4_for([myvar], 1, 3, 3, [ myvar])
623 m4_for([myvar], 1, 6, 3, [ myvar])
624 m4_for([myvar],22,-7,-5, [ myvar])
625 m4_for([myvar],-2,-7,-4, [ myvar])
626 m4_for([myvar],-7,-2, 4, [ myvar])
627 dnl Make sure we are not exposed to division truncation:
628 m4_for([myvar], 2, 5, 2, [ myvar])
629 m4_for([myvar],-5,-2, 2, [ myvar])
630 m4_for([myvar], 5, 2,-2, [ myvar])
631 m4_for([myvar],-2,-5,-2, [ myvar])
632 dnl Make sure we do not divide by zero:
633 m4_for([myvar], 1, 1, , [ myvar])
634 m4_for([myvar], 1, 1,+2, [ myvar])
635 m4_for([myvar], 1, 1,-2, [ myvar])
636 dnl Make sure we do not loop endlessly
637 m4_for([myval], 1, 1, 0, [ myval])
638 dnl Make sure to properly parenthesize
639 m4_for([myvar], 3-5, -2+8, , [ myvar])
640 m4_for([myvar], -2+8, 3-5, , [ myvar])
641 m4_for([myvar], 8, 16, 3 * 2, [ myvar])
642 m4_for([myvar], 8, 16, -3 * -2, [ myvar])
643 m4_for([myvar], [2<<2], [2<<3], [-3 * (-2)], [ myvar])
644 dnl Modifying var does not affect the number of iterations
645 m4_for([myvar], 1, 5, , [ myvar[]m4_define([myvar], 5)])
646 dnl Make sure we can do nameless iteration
649 m4_foreach([myvar], [[a], [b, c], [d], [e
651 m4_foreach_w([myvar], [a b c, d,e f
689 AT_DATA_M4SUGAR([script.4s],
692 m4_for([myvar], 1, 3,-1, [ myvar])
695 AT_CHECK_M4SUGAR([], 1, [],
696 [[script.4s:3: error: assert failed: -1 > 0
697 script.4s:3: the top level
698 autom4te: m4 failed with exit status: 1
701 AT_DATA_M4SUGAR([script.4s],
704 m4_for([myvar], 1, 2, 0, [ myvar])
707 AT_CHECK_M4SUGAR([], 1, [],
708 [[script.4s:3: error: assert failed: 0 > 0
709 script.4s:3: the top level
710 autom4te: m4 failed with exit status: 1
713 AT_DATA_M4SUGAR([script.4s],
716 m4_for([myvar], 2, 1, 0, [ myvar])
719 AT_CHECK_M4SUGAR([], 1, [],
720 [[script.4s:3: error: assert failed: 0 < 0
721 script.4s:3: the top level
722 autom4te: m4 failed with exit status: 1
728 ## --------------- ##
730 ## --------------- ##
732 AT_SETUP([m4@&t@_map])
733 AT_KEYWORDS([m4@&t@_apply])
734 AT_KEYWORDS([m4@&t@_count])
736 AT_CHECK_M4SUGAR_TEXT([[dnl
737 m4_map([m4_count], [])
738 m4_map([ m4_count], [[],
741 m4_map_sep([m4_eval], [,], [[[1+2]],
743 m4_define([a], [m4_if([$#], [0], [oops], [$1], [a], [pass], [oops])])dnl
744 m4_define([a1], [oops])dnl
745 m4_define([pass1], [oops])dnl
746 m4_map([a], [[[a]]])1
747 m4_map([m4_unquote([a])], [m4_dquote([a])])
763 AT_SETUP([m4@&t@_combine])
765 AT_CHECK_M4SUGAR_TEXT([[m4_define([a], [oops])dnl
766 m4_combine([, ], [[a], [b], [c]], [-], [1], [2], [3])
767 m4_combine([, ], [[a], [b]], [-])
768 m4_combine([, ], [[a], [b]], [-], [])
769 m4_combine([, ], [], [-], [a], [b])
770 m4_combine([, ], [[]], [-], [a], [b])
771 m4_combine([ a ], [[-], [+]], [a], [-], [+])
772 m4_combine([$* ], [[$1], [$2]], [$#], [$@])
774 [[a-1, a-2, a-3, b-1, b-2, b-3, c-1, c-2, c-3
779 -a- a -a+ a +a- a +a+
790 AT_SETUP([m4@&t@_max and m4@&t@_min])
792 AT_DATA_M4SUGAR([script.4s],
796 AT_CHECK_M4SUGAR([], 1, [],
797 [[script.4s:1: error: too few arguments to m4@&t@_max
798 script.4s:1: the top level
799 autom4te: m4 failed with exit status: 1
802 AT_DATA_M4SUGAR([script.4s],
806 AT_CHECK_M4SUGAR([], 1, [],
807 [[script.4s:1: error: too few arguments to m4@&t@_min
808 script.4s:1: the top level
809 autom4te: m4 failed with exit status: 1
812 AT_CHECK_M4SUGAR_TEXT([[dnl
822 m4_min(1m4_for([i], 2, 100, , [,i]))
823 m4_min(m4_for([i], 100, 2, , [i,])1)
834 m4_max(1m4_for([i], 2, 100, , [,i]))
835 m4_max(m4_for([i], 100, 2, , [i,])1)
869 AT_SETUP([recursion])
871 AT_KEYWORDS([m4@&t@_foreach m4@&t@_foreach_w m4@&t@_case m4@&t@_cond
872 m4@&t@_bpatsubsts m4@&t@_shiftn m4@&t@_do m4@&t@_dquote_elt m4@&t@_reverse
873 m4@&t@_map m4@&t@_join m4@&t@_joinall m4@&t@_list_cmp m4@&t@_max m4@&t@_min])
875 dnl This test completes in a reasonable time if m4_foreach is linear,
876 dnl but thrashes if it is quadratic. If we are testing with m4 1.4.x,
877 dnl only the slower foreach.m4 implementation will work. But if we
878 dnl are testing with m4 1.6, we can rerun the test with __m4_version__
879 dnl undefined to exercise the alternate code path.
880 AT_DATA_M4SUGAR([script.4s],
882 m4_divert_push(0)[]dnl
883 m4_len(m4_foreach_w([j], m4_do(m4_for([i], [1], [10000], [], [,i ])), [j ]))
884 m4_shiftn(9998m4_for([i], [1], [10000], [], [,i]))
885 m4_len(m4_join([--],, m4_dquote_elt(m4_for([i], [1], [10000], [], [,i])),))
886 m4_len(m4_joinall([--], m4_map([, m4_echo],
887 m4_dquote([1]m4_for([i], [2], [10000], [], [,i])))))
888 m4_max(m4_min([1]m4_for([i], [2], [10000], [],
889 [,i]))m4_for([i], [2], [10000], [], [,i]))
890 m4_case([10000]m4_for([i], [1], [10000], [], [,i]),[end])
891 m4_list_cmp(m4_dquote(1m4_for([i], [2], [10000], [], [,i])),
892 m4_dquote(m4_reverse(10000m4_for([i], [9999], [1], [], [,i])), [0]))
893 m4_list_cmp([0], [0m4_for([i], [1], [10000], [], [,0])])
894 m4_list_cmp([0m4_for([i], [1], [10000], [], [,0])], [0])
895 m4_for([i], [1], [10000], [], [m4_define(i)])dnl
896 m4_undefine(1m4_for([i], [2], [10000], [], [,i]))dnl
897 m4_bpatsubsts([a1]m4_for([i], [1], [10000], [], [,i]), [a2], [A])
898 m4_define([up], [m4_define([$1], m4_incr($1))$1])m4_define([j], 0)dnl
899 m4_cond(m4_for([i], [1], [10000], [], [[up([j])], [9990], i,]) [oops]) j
903 AT_CHECK_M4SUGAR([-o-], [0], [[48894
916 AT_DATA_M4SUGAR([script.4s],
917 [[m4_ifdef([__m4_version__],
918 [m4_undefine([__m4_version__])],
919 [m4_divert_push(0)48894
932 m4_divert_push(0)[]dnl
933 m4_len(m4_foreach_w([j], m4_do(m4_for([i], [1], [10000], [], [,i ])), [j ]))
934 m4_shiftn(9998m4_for([i], [1], [10000], [], [,i]))
935 m4_len(m4_join([--],, m4_dquote_elt(m4_for([i], [1], [10000], [], [,i])),))
936 m4_len(m4_joinall([--], m4_map([, m4_echo],
937 m4_dquote([1]m4_for([i], [2], [10000], [], [,i])))))
938 m4_max(m4_min([1]m4_for([i], [2], [10000], [],
939 [,i]))m4_for([i], [2], [10000], [], [,i]))
940 m4_case([10000]m4_for([i], [1], [10000], [], [,i]),[end])
941 m4_list_cmp(m4_dquote(1m4_for([i], [2], [10000], [], [,i])),
942 m4_dquote(m4_reverse(10000m4_for([i], [9999], [1], [], [,i])), [0]))
943 m4_list_cmp([0], [0m4_for([i], [1], [10000], [], [,0])])
944 m4_list_cmp([0m4_for([i], [1], [10000], [], [,0])], [0])
945 m4_for([i], [1], [10000], [], [m4_define(i)])dnl
946 m4_undefine(1m4_for([i], [2], [10000], [], [,i]))dnl
947 m4_bpatsubsts([a1]m4_for([i], [1], [10000], [], [,i]), [a2], [A])
948 m4_define([up], [m4_define([$1], m4_incr($1))$1])m4_define([j], 0)dnl
949 m4_cond(m4_for([i], [1], [10000], [], [[up([j])], [9990], i,]) [oops])
953 AT_CHECK_M4SUGAR([-o-], [0], [[48894
973 AT_SETUP([m4@&t@_set])
975 AT_KEYWORDS([m4@&t@_set_add m4@&t@_set_add_all m4@&t@_set_contains
976 m4@&t@_set_contents m4@&t@_set_delete m4@&t@_set_difference m4@&t@_set_dump
977 m4@&t@_set_empty m4@&t@_set_foreach m4@&t@_set_intersection m4@&t@_set_list
978 m4@&t@_set_listc m4@&t@_set_remove m4@&t@_set_size m4@&t@_set_union])
981 AT_CHECK_M4SUGAR_TEXT([[m4_set_contains([a], [1], [yes], [no])
982 m4_set_add([a], [1], [added], [dup])
983 m4_set_contains([a], [1], [yes], [no])
984 m4_set_add([a], [1], [added], [dup])
986 m4_set_remove([a], [1], [removed], [missing])
987 m4_set_contains([a], [1], [yes], [no])
988 m4_set_remove([a], [1], [removed], [missing])
989 m4_set_add([a], [2], [added], [dup])
990 m4_set_empty([a], [yes], [no])
992 m4_set_empty([a], [yes], [no])
993 m4_set_add_all([c], [1], [2], [3])
994 m4_set_add_all([a]m4_set_listc([c]))
995 m4_set_contents([c], [-])
996 m4_set_dump([a], [-])
998 m4_set_add_all([a], [1], [2], [3])m4_set_add_all([b], [3], [], [4])
999 m4_set_difference([a], [b])
1000 m4_set_difference([b], [a])
1001 m4_set_intersection([a], [b])
1002 m4_set_union([a], [b])
1003 m4_set_foreach([a], [i], [m4_if(m4_eval(i & 1), [1], [m4_set_remove([a], i)])])
1007 m4_set_remove([a], [2])
1008 m4_dquote(m4_set_list([a]))
1012 m4_dquote(m4_set_list([a]))
1013 m4_indir([m4_dquote]m4_set_listc([a]))
1053 # Stress tests - check for unusual names/values
1054 AT_CHECK_M4SUGAR_TEXT([[m4_define([a], [oops])dnl
1055 m4_set_add([a], [a])dnl
1056 m4_set_remove([a], [oops], [yes], [no])
1057 m4_set_add([a,b], [c])dnl
1058 m4_set_add([a,b], [$*[]])dnl
1059 m4_set_add_all([a], [b,c])dnl
1061 m4_count(m4_set_contents([a], [,]))
1062 m4_count(m4_set_list([a], [,]))
1063 m4_set_dump([a], [,])
1064 m4_set_contents([a,b], [,])
1066 m4_set_foreach([$*[]], [$*[]], [oops])
1067 m4_set_add([$*[]], [])dnl
1068 m4_set_remove([$*[]], [a], [yes], [no])
1069 m4_set_add([$*[]], [a])dnl
1070 m4_set_foreach([$*[]], [$*[]], [-m4_defn([$*[]])m4_indir([$*[]])-])
1071 m4_set_remove([$*[]], [], [yes], [no])
1072 m4_set_add([c], [,])dnl
1073 m4_set_foreach([a,b], [set], [:m4_set_listc(_m4_defn([set])):])
1088 # Stress tests - check for linear scaling (won't necessarily fail if
1089 # quadratic, but hopefully users will complain if it appears to hang)
1090 AT_CHECK_M4SUGAR_TEXT([[dnl
1091 m4_for([i], [1], [10000], [], [m4_set_add([a], i)])dnl
1092 m4_set_add_all([b]m4_for([i], [1], [10000], [], [,i]))dnl
1093 m4_set_remove([a], [1])dnl
1094 m4_set_remove([b], [10000])dnl
1095 m4_set_add_all([a]m4_for([i], [1], [10000], [], [,i]))dnl
1096 m4_for([i], [1], [10000], [], [m4_set_add([b], i)])dnl
1097 m4_len(m4_set_contents([a]))
1098 m4_len(m4_set_foreach([b], [b], [m4_if(m4_eval(b & 1), [1],
1099 [m4_set_remove([b], b, [-])])]))
1101 m4_count(m4_shift(m4_set_intersection([a], [b])))