Repository : ssh://darcs.haskell.org//srv/darcs/testsuite

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/c4dbe444f35b5e9f498d34a69d0ce55b84b549a1

>---------------------------------------------------------------

commit c4dbe444f35b5e9f498d34a69d0ce55b84b549a1
Author: Austin Seipp <[email protected]>
Date:   Sun Apr 3 23:10:06 2011 -0500

    Tests for trac #5025.
    
    Also teach the testsuite how to compile objective-c code with .m as
    a suffix.

>---------------------------------------------------------------

 driver/testglobals.py                        |    5 ++-
 driver/testlib.py                            |    5 +++
 tests/ghc-regress/driver/objc/all.T          |    9 ++++++
 tests/ghc-regress/driver/objc/objc-hi.m      |   35 ++++++++++++++++++++++++++
 tests/ghc-regress/driver/objc/objc-hi.stdout |    1 +
 5 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/driver/testglobals.py b/driver/testglobals.py
index afc4aa7..152f0fe 100644
--- a/driver/testglobals.py
+++ b/driver/testglobals.py
@@ -199,8 +199,9 @@ class TestOptions:
        # Does this test use a literate (.lhs) file?
        self.literate = 0
 
-       # Does this test use a .c file?
-       self.c_src = 0
+       # Does this test use a .c or .m file?
+       self.c_src    = 0
+       self.objc_src = 0
 
        # Command to run before the test
        self.pre_cmd = None
diff --git a/driver/testlib.py b/driver/testlib.py
index 26e440c..b211da0 100644
--- a/driver/testlib.py
+++ b/driver/testlib.py
@@ -369,6 +369,9 @@ def literate( opts ):
 def c_src( opts ):
     opts.c_src = 1;
 
+def objc_src( opts ):
+    opts.objc_src = 1;
+
 # ----
 
 def pre_cmd( cmd ):
@@ -1451,6 +1454,8 @@ def add_suffix( name, suffix ):
 def add_hs_lhs_suffix(name):
     if getTestOpts().c_src:
         return add_suffix(name, 'c')
+    elif getTestOpts().objc_src:
+        return add_suffix(name, 'm')
     elif getTestOpts().literate:
         return add_suffix(name, 'lhs')
     else:
diff --git a/tests/ghc-regress/driver/objc/all.T 
b/tests/ghc-regress/driver/objc/all.T
new file mode 100644
index 0000000..e7ab578
--- /dev/null
+++ b/tests/ghc-regress/driver/objc/all.T
@@ -0,0 +1,9 @@
+def if_not_platform(platforms, f):
+    if not (config.platform in platforms):
+       return f
+    else:
+       return normal
+
+skip_if_not_osx = if_not_platform(['i386-apple-darwin','x86_64-apple-darwin'], 
skip)
+
+test('objc-hi', [ skip_if_not_osx, objc_src ], compile_and_run, ['-framework 
Foundation'])
diff --git a/tests/ghc-regress/driver/objc/objc-hi.m 
b/tests/ghc-regress/driver/objc/objc-hi.m
new file mode 100644
index 0000000..4580bd2
--- /dev/null
+++ b/tests/ghc-regress/driver/objc/objc-hi.m
@@ -0,0 +1,35 @@
+#import <Foundation/Foundation.h>
+#import <stdio.h> 
+
+@interface HelloWorld : NSObject {
+  // no instance variables
+}
+
+// methods
+- (void)sayHello;
+
+@end
+
+@implementation HelloWorld
+
+- (void)sayHello
+{
+  printf("Hello world\n");
+}
+
+@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/tests/ghc-regress/driver/objc/objc-hi.stdout 
b/tests/ghc-regress/driver/objc/objc-hi.stdout
new file mode 100644
index 0000000..802992c
--- /dev/null
+++ b/tests/ghc-regress/driver/objc/objc-hi.stdout
@@ -0,0 +1 @@
+Hello world



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to