objc++, objc: add first semantic tests
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 30 Apr 2012 12:17:44 +0000 (14:17 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 2 May 2012 15:38:36 +0000 (17:38 +0200)
* t/objcxx-minidemo.sh: New test.
* t/objc-minidemo.sh: Likewise.
* t/list-of-tests.mk: Add them.

Co-authored-by: Peter Breitenlohner <peb@mppmu.mpg.de>
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
t/list-of-tests.mk
t/objc-minidemo.sh [new file with mode: 0755]
t/objcxx-minidemo.sh [new file with mode: 0755]

index bc6dfe2..d19c74a 100644 (file)
@@ -704,7 +704,9 @@ t/notrans.sh \
 t/number.sh \
 t/objc.sh \
 t/objc2.sh \
+t/objc-minidemo.sh \
 t/objcxx-basic.sh \
+t/objcxx-minidemo.sh \
 t/objext-pr10128.sh \
 t/obsolete.sh \
 t/oldvars.sh \
diff --git a/t/objc-minidemo.sh b/t/objc-minidemo.sh
new file mode 100755 (executable)
index 0000000..acd7e19
--- /dev/null
@@ -0,0 +1,76 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Dummy demo package using Objective C and doing distcheck.
+# See also sister test 'objcxx-minidemo.sh'.
+
+required=native
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_OBJC
+AC_CONFIG_HEADERS([config.h])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AM_DEFAULT_SOURCE_EXT = .m
+bin_PROGRAMS = ok
+noinst_PROGRAMS = ko
+TESTS = $(bin_PROGRAMS) $(XFAIL_TESTS)
+XFAIL_TESTS = $(noinst_PROGRAMS)
+END
+
+cat > ok.m << 'END'
+/* The use of #import makes this valid Object C but invalid C. */
+#import <stdio.h>
+#import <config.h>
+int main (void)
+{
+    printf ("Success (%s)\n", PACKAGE_STRING);
+    return 0;
+}
+END
+
+cat > ko.m << 'END'
+/* The use of #import makes this valid Object C but invalid C. */
+#import <stdio.h>
+int main (void)
+{
+    printf("Failure\n");
+    return 1;
+}
+END
+
+if $ACLOCAL; then
+  : We have a modern enough autoconf, go ahead.
+elif test $? -eq 63; then
+  skip_ "Object C++ support requires Autoconf 2.65 or later"
+else
+  Exit 1 # Some other aclocal failure.
+fi
+
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE --add-missing
+
+./configure
+$MAKE
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/t/objcxx-minidemo.sh b/t/objcxx-minidemo.sh
new file mode 100755 (executable)
index 0000000..fe93ea6
--- /dev/null
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Dummy demo package using Objective C++ and doing distcheck.
+# See also sister test 'objc-minidemo.sh'.
+
+required=native
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+dnl Support for Object C++ was introduced only in Autoconf 2.65.
+AC_PREREQ([2.65])
+AC_PROG_OBJCXX
+AC_CONFIG_HEADERS([config.h])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AM_DEFAULT_SOURCE_EXT = .mm
+bin_PROGRAMS = ok
+noinst_PROGRAMS = ko
+TESTS = $(bin_PROGRAMS) $(XFAIL_TESTS)
+XFAIL_TESTS = $(noinst_PROGRAMS)
+END
+
+cat > ok.mm << 'END'
+/* The use of #import makes this valid Object C++ but invalid C++. */
+#import <iostream>
+#import <config.h>
+using namespace std;
+int main (void)
+{
+    cout << "Success (" << PACKAGE_STRING << ")\n";
+    return 0;
+}
+END
+
+cat > ko.mm << 'END'
+/* The use of #import makes this valid Object C++ but invalid C++. */
+#import <cstdio>
+int main (void)
+{
+    printf("Failure\n");
+    return 1;
+}
+END
+
+if $ACLOCAL; then
+  : We have a modern enough autoconf, go ahead.
+elif test $? -eq 63; then
+  skip_ "Object C++ support requires Autoconf 2.65 or later"
+else
+  Exit 1 # Some other aclocal failure.
+fi
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE --add-missing
+
+./configure
+$MAKE
+$MAKE check
+$MAKE distcheck
+
+: