AT_BANNER([Autotest.])
-# Copyright (C) 2004 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# Here documents for these tests contain forbidden macros.
m4_pattern_allow([^AT_])
+
+## ------------------ ##
+## Empty test suite. ##
+## ------------------ ##
+
+# This is not a sensible thing to do, but the user should not get a unhelpful
+# error message, which is what happens presently.
+AT_CHECK_AT([Empty test suite],
+[[AT_INIT([empty test suite])
+]], [:])
+
+
## ----------------------------------------------------- ##
## Newlines and command substitutions in test commands. ##
## ----------------------------------------------------- ##
# -*- Autotest -*-
-# Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software
+# Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
AT_CLEANUP
+## ------------------------------- ##
+## Substitute a 2000-byte string. ##
+## ------------------------------- ##
+
+# Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes. HP/UX
+# sed dumps core around 8 KiB. However, POSIX says that sed need not
+# handle lines longer than 2048 bytes (including the trailing newline).
+# So we'll just test a 2000-byte value.
+
+AT_SETUP([Substitute a 2000-byte string])
+
+AT_DATA([Foo.in], [@foo@
+])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_AUX_DIR($top_srcdir/config)
+AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
+AC_CONFIG_FILES([Foo])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
+)
+AT_CLEANUP
+
+
+## ------------------------------ ##
+## Define to a 2000-byte string. ##
+## ------------------------------ ##
+
+AT_SETUP([Define to a 2000-byte string])
+
+AT_CONFIGURE_AC(
+[[
+AC_DEFINE([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
+])
+AT_CLEANUP
+
+
+## ------------------------------------------ ##
+## Substitute and define special characters. ##
+## ------------------------------------------ ##
+
+# Use characters special to the shell, sed, and M4.
+
+AT_SETUP([Substitute and define special characters])
+
+AT_DATA([Foo.in], [@foo@
+])
+
+AT_CONFIGURE_AC(
+[[foo="AS@&t@_ESCAPE([[X*'[]+ ", `\($foo]])"
+AC_SUBST([foo])
+AC_DEFINE([foo], [[X*'[]+ ", `\($foo]], [Awful value.])
+AC_CONFIG_FILES([Foo])]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+AT_CHECK([cat Foo], 0, [[X*'[]+ ", `\($foo
+]])
+AT_CHECK_DEFINES([[#define foo X*'[]+ ", `\($foo
+]])
+AT_CLEANUP
+
+
+## ---------------------- ##
+## Substitute a newline. ##
+## ---------------------- ##
+
+AT_SETUP([Substitute a newline])
+AT_XFAIL_IF(:)
+
+AT_DATA([Foo.in],
+[@foo@
+])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_AUX_DIR($top_srcdir/config)
+foo='one
+two'
+AC_SUBST([foo])
+AC_CONFIG_FILES([Foo])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK([cat Foo], 0, [one
+two
+])
+AT_CLEANUP
+
+
+## ------------------ ##
+## Define a newline. ##
+## ------------------ ##
+
+AT_SETUP([Define a newline])
+AT_XFAIL_IF(:)
+AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
+two], [This spans two lines.])
+]])
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
+AT_CHECK_DEFINES([[#define foo one
+two
+]])
+AT_CLEANUP
+
+
## -------- ##
## srcdir. ##
## -------- ##