aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNicola Pero <nicola@brainstorm.co.uk>2001-12-17 17:27:08 +0000
committerNicola Pero <nicola@gcc.gnu.org>2001-12-17 17:27:08 +0000
commit18c8746d1360487f7a1335e8b475313ca34d78bf (patch)
tree5b35f1e708c21d1e7069eb6d6635b8b7adcbb6aa /gcc
parente5e0f6f5392b636c5478ef7fb4853fb01ad8257f (diff)
downloadgcc-18c8746d1360487f7a1335e8b475313ca34d78bf.zip
gcc-18c8746d1360487f7a1335e8b475313ca34d78bf.tar.gz
gcc-18c8746d1360487f7a1335e8b475313ca34d78bf.tar.bz2
New test for loading unclaimed categories in Objective-C
From-SVN: r48111
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/objc.dg/special/special.exp46
-rw-r--r--gcc/testsuite/objc.dg/special/unclaimed-category-1.h27
-rw-r--r--gcc/testsuite/objc.dg/special/unclaimed-category-1.m65
-rw-r--r--gcc/testsuite/objc.dg/special/unclaimed-category-1a.m31
5 files changed, 177 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 43bcac0..4f87ba6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+Mon Dec 17 16:54:56 2001 Nicola Pero <nicola@brainstorm.co.uk>
+
+ * objc.dg/special/: New directory.
+ * objc.dg/special/special.exp: New file.
+ * objc.dg/special/unclaimed-category-1.h: New file.
+ * objc.dg/special/unclaimed-category-1a.m: New file.
+ * objc.dg/special/unclaimed-category-1.m: New file.
+
2001-12-17 Andreas Jaeger <aj@suse.de>
* gcc.c-torture/compile/20011217-2.c: New test.
diff --git a/gcc/testsuite/objc.dg/special/special.exp b/gcc/testsuite/objc.dg/special/special.exp
new file mode 100644
index 0000000..09552a7
--- /dev/null
+++ b/gcc/testsuite/objc.dg/special/special.exp
@@ -0,0 +1,46 @@
+# GCC Objective-C testsuite that uses the `dg.exp' driver.
+# Copyright (C) 1997, 2001 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 of the License, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Load support procs.
+load_lib objc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS ""
+}
+
+# Initialize `dg'.
+dg-init
+
+#
+# unclaimed-category-1 test
+#
+# This test is special because we must compile two different modules,
+# unclaimed-category-1a.m and unclaimed-category-1.m, then link
+# together, then run the resulting executable.
+set lines [objc_target_compile "$srcdir/$subdir/unclaimed-category-1a.m" "unclaimed-category-1a.o" object ""]
+if ![string match "" $lines] then {
+ fail "unclaimed-category-1a.o"
+} else {
+ dg-runtest "$srcdir/$subdir/unclaimed-category-1.m" "unclaimed-category-1a.o" ""
+ file delete unclaimed-category-1a.o
+}
+
+# All done.
+dg-finish
+
diff --git a/gcc/testsuite/objc.dg/special/unclaimed-category-1.h b/gcc/testsuite/objc.dg/special/unclaimed-category-1.h
new file mode 100644
index 0000000..6c73d28
--- /dev/null
+++ b/gcc/testsuite/objc.dg/special/unclaimed-category-1.h
@@ -0,0 +1,27 @@
+/* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+/* Test loading unclaimed categories - categories of a class defined
+ separately from the class itself. */
+
+@interface TestClass
+{
+ id isa;
+}
+- (int)D;
+@end
+
+@interface TestClass (A)
+- (int)A;
+@end
+
+@interface TestClass (B)
+- (int)B;
+@end
+
+@interface TestClass (C)
+- (int)C;
+@end
+
+
diff --git a/gcc/testsuite/objc.dg/special/unclaimed-category-1.m b/gcc/testsuite/objc.dg/special/unclaimed-category-1.m
new file mode 100644
index 0000000..f9cbfc8
--- /dev/null
+++ b/gcc/testsuite/objc.dg/special/unclaimed-category-1.m
@@ -0,0 +1,65 @@
+/* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */
+/* { dg-do run } */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+/* Test loading unclaimed categories - categories of a class defined
+ separately from the class itself. */
+
+
+/* unclaimed-category-1.m contains only the class definition but not
+ the categories. unclaimed-category-1a.m contains only the
+ categories of the class, but not the class itself. We want to
+ check that the runtime can load the class from one module (file)
+ and the categories from another module (file). */
+
+#include "unclaimed-category-1.h"
+
+@implementation TestClass
+- (int)D
+{
+ return 4;
+}
+@end
+
+
+int main (void)
+{
+ TestClass *test;
+ Class testClass;
+
+ testClass = objc_get_class ("TestClass");
+ if (testClass == Nil)
+ {
+ abort ();
+ }
+
+ test = (TestClass *)(class_create_instance (testClass));
+ if (test == nil)
+ {
+ abort ();
+ }
+
+ if ([test A] != 1)
+ {
+ abort ();
+ }
+
+ if ([test B] != 2)
+ {
+ abort ();
+ }
+
+ if ([test C] != 3)
+ {
+ abort ();
+ }
+
+
+ if ([test D] != 4)
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc.dg/special/unclaimed-category-1a.m b/gcc/testsuite/objc.dg/special/unclaimed-category-1a.m
new file mode 100644
index 0000000..6bcd1b4
--- /dev/null
+++ b/gcc/testsuite/objc.dg/special/unclaimed-category-1a.m
@@ -0,0 +1,31 @@
+/* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+/* Test loading unclaimed categories - categories of a class defined
+ separately from the class itself. */
+
+#include "unclaimed-category-1.h"
+
+@implementation TestClass (A)
+- (int)A
+{
+ return 1;
+}
+@end
+
+@implementation TestClass (B)
+- (int)B
+{
+ return 2;
+}
+@end
+
+@implementation TestClass (C)
+- (int)C
+{
+ return 3;
+}
+@end
+
+