+2006-12-01 Bruno Haible <bruno@clisp.org>
+
+ * modules/moo-tests: New file.
+ * tests/test-moo-aroot.oo.c: New file.
+ * tests/test-moo-aroot.oo.h: New file.
+ * tests/test-moo-assign.c: New file.
+ * tests/test-moo-asub1.oo.c: New file.
+ * tests/test-moo-asub1.oo.h: New file.
+ * tests/test-moo-root.oo.c: New file.
+ * tests/test-moo-root.oo.h: New file.
+ * tests/test-moo-sub1.oo.c: New file.
+ * tests/test-moo-sub1.oo.h: New file.
+ * tests/test-moo-sub2.oo.c: New file.
+ * tests/test-moo-sub2.oo.h: New file.
+ * Makefile.am (EXTRA_DIST): Add the new files.
+
2006-12-01 Bruno Haible <bruno@clisp.org>
* modules/term-ostream-tests: New file.
modules/libxml \
modules/memory-ostream \
modules/moo \
+modules/moo-tests \
modules/no-c++ \
modules/ostream \
modules/progreloc \
modules/xerror \
modules/xgetcwd \
modules/xreadlink \
+tests/test-moo-aroot.oo.c \
+tests/test-moo-aroot.oo.h \
+tests/test-moo-assign.c \
+tests/test-moo-asub1.oo.c \
+tests/test-moo-asub1.oo.h \
+tests/test-moo-root.oo.c \
+tests/test-moo-root.oo.h \
+tests/test-moo-sub1.oo.c \
+tests/test-moo-sub1.oo.h \
+tests/test-moo-sub2.oo.c \
+tests/test-moo-sub2.oo.h \
tests/test-term-ostream.c \
tests/test-term-ostream-xterm \
tests/test-term-ostream-xterm.out \
--- /dev/null
+Files:
+tests/test-moo-root.oo.h
+tests/test-moo-root.oo.c
+tests/test-moo-sub1.oo.h
+tests/test-moo-sub1.oo.c
+tests/test-moo-sub2.oo.h
+tests/test-moo-sub2.oo.c
+tests/test-moo-aroot.oo.h
+tests/test-moo-aroot.oo.c
+tests/test-moo-asub1.oo.h
+tests/test-moo-asub1.oo.c
+tests/test-moo-assign.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+test-moo-root.h test-moo-root.c root.priv.h root.vt.h : $(top_srcdir)/build-aux/moopp test-moo-root.oo.h test-moo-root.oo.c
+ $(top_srcdir)/build-aux/moopp $(srcdir)/test-moo-root.oo.c $(srcdir)/test-moo-root.oo.h
+
+test-moo-sub1.h test-moo-sub1.c sub1.priv.h sub1.vt.h : $(top_srcdir)/build-aux/moopp test-moo-root.oo.h test-moo-sub1.oo.h test-moo-sub1.oo.c
+ $(top_srcdir)/build-aux/moopp $(srcdir)/test-moo-sub1.oo.c $(srcdir)/test-moo-sub1.oo.h $(srcdir)/test-moo-root.oo.h
+
+test-moo-sub2.h test-moo-sub2.c sub2.priv.h sub2.vt.h : $(top_srcdir)/build-aux/moopp test-moo-root.oo.h test-moo-sub1.oo.h test-moo-sub2.oo.h test-moo-sub2.oo.c
+ $(top_srcdir)/build-aux/moopp $(srcdir)/test-moo-sub2.oo.c $(srcdir)/test-moo-sub2.oo.h $(srcdir)/test-moo-sub1.oo.h $(srcdir)/test-moo-root.oo.h
+
+test-moo-aroot.h test-moo-aroot.c aroot.priv.h aroot.vt.h : $(top_srcdir)/build-aux/moopp test-moo-aroot.oo.h test-moo-aroot.oo.c
+ $(top_srcdir)/build-aux/moopp $(srcdir)/test-moo-aroot.oo.c $(srcdir)/test-moo-aroot.oo.h
+
+test-moo-asub1.h test-moo-asub1.c asub1.priv.h asub1.vt.h : $(top_srcdir)/build-aux/moopp test-moo-aroot.oo.h test-moo-asub1.oo.h test-moo-asub1.oo.c
+ $(top_srcdir)/build-aux/moopp $(srcdir)/test-moo-asub1.oo.c $(srcdir)/test-moo-asub1.oo.h $(srcdir)/test-moo-aroot.oo.h
+
--- /dev/null
+#include <config.h>
+
+/* Specification. */
+#include "test-moo-aroot.h"
+
+#pragma implementation
--- /dev/null
+#include <stdlib.h>
+#include "moo.h"
+
+/* Define an abstract root class. */
+struct aroot
+{
+methods:
+ int write (aroot_t x, void *buf, size_t len);
+ void do_free (aroot_t x);
+};
--- /dev/null
+/* Test assignments.
+ Errors are signalled in C++ mode only, not by a C compiler. */
+#include "test-moo-sub2.h"
+
+void foo ()
+{
+ root_t a;
+ sub1_t b;
+ sub2_t c;
+
+ /* Test initializations. */
+ root_t a1 = a;
+ root_t a2 = b;
+ root_t a3 = c;
+ sub1_t b1 = a; /* ERROR */
+ sub1_t b2 = b;
+ sub1_t b3 = c;
+ sub2_t c1 = a; /* ERROR */
+ sub2_t c2 = b; /* ERROR */
+ sub2_t c3 = c;
+
+ /* Test assignments. */
+ a = a1;
+ a = b1;
+ a = c1;
+ b = a2; /* ERROR */
+ b = b2;
+ b = c2;
+ c = a3; /* ERROR */
+ c = b3; /* ERROR */
+ c = c3;
+}
--- /dev/null
+#include <config.h>
+
+/* Specification. */
+#include "test-moo-asub1.h"
+
+#pragma implementation
+
+int asub1::write (asub1_t x, void *buf, size_t len)
+{
+ fwrite (buf, 1, len, x->fp);
+ return 0;
+}
+
+void asub1::do_free (asub1_t x)
+{
+ free (x);
+}
--- /dev/null
+#include "test-moo-aroot.h"
+
+#include <stdio.h>
+
+/* Define a subclass. */
+struct asub1 : struct aroot
+{
+ FILE *fp;
+methods:
+};
--- /dev/null
+#include <config.h>
+
+/* Specification. */
+#include "test-moo-root.h"
+
+#include <stdio.h>
+
+#pragma implementation
+
+int root::write (root_t x, void *buf, size_t len)
+{
+ fwrite (buf, 1, len, stdout);
+ return 0;
+}
+
+void root::do_free (root_t x)
+{
+ free (x);
+}
--- /dev/null
+#include <stdlib.h>
+#include "moo.h"
+
+/* Define a root class. */
+struct root
+{
+methods:
+ int write (root_t x, void *buf, size_t len);
+ void do_free (root_t x);
+};
--- /dev/null
+#include <config.h>
+
+/* Specification. */
+#include "test-moo-sub1.h"
+
+#pragma implementation
+
+/* Test an override. */
+int sub1::write (sub1_t x, void *buf, size_t len)
+{
+ fwrite (buf, 1, len, x->fp);
+ return 0;
+}
--- /dev/null
+#include "test-moo-root.h"
+
+#include <stdio.h>
+
+/* Define a subclass. */
+struct sub1 : struct root
+{
+ FILE *fp;
+methods:
+};
--- /dev/null
+#include <config.h>
+
+/* Specification. */
+#include "test-moo-sub2.h"
+
+#include <stdio.h>
+
+#pragma implementation
+
+void
+sub2::begin_indent (sub2_t x)
+{
+ x->indent++;
+}
+
+void
+sub2::end_indent (sub2_t x)
+{
+ x->indent--;
+}
--- /dev/null
+#include "test-moo-sub1.h"
+
+/* Define a subclass. */
+struct sub2 : struct sub1
+{
+ int indent;
+methods:
+ void begin_indent (sub2_t x);
+ void end_indent (sub2_t x);
+};