Testcase for objective-c++ compilation (trac #5150)
authorPeter Wortmann <scpmw@leeds.ac.uk>
Fri, 22 Apr 2011 09:45:09 +0000 (10:45 +0100)
committerIan Lynagh <igloo@earth.li>
Sat, 6 Aug 2011 13:47:33 +0000 (14:47 +0100)
testsuite/driver/testglobals.py
testsuite/driver/testlib.py
testsuite/tests/driver/objc/all.T
testsuite/tests/ghc-regress/driver/objc/objcpp-hi.mm [new file with mode: 0644]
testsuite/tests/ghc-regress/driver/objc/objcpp-hi.stdout [new file with mode: 0644]

index 0e4ab05..9bcdcba 100644 (file)
@@ -202,9 +202,10 @@ class TestOptions:
        # Does this test use a literate (.lhs) file?
        self.literate = 0
 
-       # Does this test use a .c or .m file?
-       self.c_src    = 0
-       self.objc_src = 0
+       # Does this test use a .c, .m or .mm file?
+       self.c_src      = 0
+       self.objc_src   = 0
+       self.objcpp_src = 0
 
        # Command to run before the test
        self.pre_cmd = None
index 5b64539..56ce263 100644 (file)
@@ -388,6 +388,9 @@ def c_src( opts ):
 def objc_src( opts ):
     opts.objc_src = 1;
 
+def objcpp_src( opts ):
+    opts.objcpp_src = 1;
+
 # ----
 
 def pre_cmd( cmd ):
@@ -1581,6 +1584,8 @@ def add_hs_lhs_suffix(name):
         return add_suffix(name, 'c')
     elif getTestOpts().objc_src:
         return add_suffix(name, 'm')
+    elif getTestOpts().objcpp_src:
+        return add_suffix(name, 'mm')
     elif getTestOpts().literate:
         return add_suffix(name, 'lhs')
     else:
index ee22934..eb472a4 100644 (file)
@@ -8,3 +8,6 @@ skip_if_not_osx = if_not_platform(['i386-apple-darwin','x86_64-apple-darwin'], s
 
 test('objc-hi', [ skip_if_not_osx, objc_src ],
      compile_and_run, ['-framework Foundation'])
+
+test('objcpp-hi', [ skip_if_not_osx, objcpp_src ],
+     compile_and_run, ['-framework Foundation -lstdc++'])
diff --git a/testsuite/tests/ghc-regress/driver/objc/objcpp-hi.mm b/testsuite/tests/ghc-regress/driver/objc/objcpp-hi.mm
new file mode 100644 (file)
index 0000000..7a4f101
--- /dev/null
@@ -0,0 +1,35 @@
+#import <Foundation/Foundation.h>
+#import <iostream>
+
+@interface HelloWorld : NSObject {
+  // no instance variables
+}
+
+// methods
+- (void)sayHello;
+
+@end
+
+@implementation HelloWorld
+
+- (void)sayHello
+{
+  std::cout << "Hello world" << std::endl;
+}
+
+@end
+
+#import <Foundation/Foundation.h>
+
+int main (int argc, const char * argv[]) {
+  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+  // my stuff
+  HelloWorld *hw = [[HelloWorld alloc] init];
+  [hw autorelease];
+  
+  [hw sayHello];
+      
+  [pool release];
+  return 0;
+}
diff --git a/testsuite/tests/ghc-regress/driver/objc/objcpp-hi.stdout b/testsuite/tests/ghc-regress/driver/objc/objcpp-hi.stdout
new file mode 100644 (file)
index 0000000..802992c
--- /dev/null
@@ -0,0 +1 @@
+Hello world