New test for loading unclaimed categories in Objective-C
authorNicola Pero <nicola@brainstorm.co.uk>
Mon, 17 Dec 2001 17:27:08 +0000 (17:27 +0000)
committerNicola Pero <nicola@gcc.gnu.org>
Mon, 17 Dec 2001 17:27:08 +0000 (17:27 +0000)
From-SVN: r48111

gcc/testsuite/ChangeLog
gcc/testsuite/objc.dg/special/special.exp [new file with mode: 0644]
gcc/testsuite/objc.dg/special/unclaimed-category-1.h [new file with mode: 0644]
gcc/testsuite/objc.dg/special/unclaimed-category-1.m [new file with mode: 0644]
gcc/testsuite/objc.dg/special/unclaimed-category-1a.m [new file with mode: 0644]

index 43bcac065a32e81674b3f645499fcb33c68e7618..4f87ba605ee47df1bb3f0b8c3e5898d61f3dcea3 100644 (file)
@@ -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 (file)
index 0000000..09552a7
--- /dev/null
@@ -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 (file)
index 0000000..6c73d28
--- /dev/null
@@ -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 (file)
index 0000000..f9cbfc8
--- /dev/null
@@ -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 (file)
index 0000000..6bcd1b4
--- /dev/null
@@ -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
+
+