Commits

Ronald Oussoren committed 77ae4a2

add some tests for argumentType and returnType arguments to selector

Comments (0)

Files changed (1)

Lib/objc/test/test_signatures.py

         self.assertRaises(ValueError, objc.selector, lambda(x,y):1,
                 returnType="X")
 
+    def testArgumentTypesPythonStyle(self):
+        # Check that argumentTypes + returnType is correctly converted to
+        # a signature
+
+        s = objc.selector(lambda self: None, argumentTypes='ii', returnType='i')
+        self.assertEquals(s.signature, 'i@:ii')
+
+        s = objc.selector(lambda self: None, argumentTypes='Oi', returnType='i')
+        self.assertEquals(s.signature, 'i@:@i')
+
+        s = objc.selector(lambda self: None, argumentTypes='', returnType='l')
+        self.assertEquals(s.signature, objc._C_LNG + '@:')
+
+        s = objc.selector(lambda self: None, argumentTypes='', returnType='f')
+        self.assertEquals(s.signature, objc._C_FLT + '@:')
+
+        s = objc.selector(lambda self: None, argumentTypes='', returnType='d')
+        self.assertEquals(s.signature, objc._C_DBL + '@:')
+
+        s = objc.selector(lambda self: None, argumentTypes='', returnType='i')
+        self.assertEquals(s.signature, objc._C_INT + '@:')
+
+        s = objc.selector(lambda self: None, argumentTypes='', returnType='s')
+        self.assertEquals(s.signature, '@@:')
+
+        s = objc.selector(lambda self: None, argumentTypes='', returnType='S')
+        self.assertEquals(s.signature, '@@:')
+
+        s = objc.selector(lambda self: None, argumentTypes='', returnType='z')
+        self.assertEquals(s.signature, '@@:')
+
+        s = objc.selector(lambda self: None, argumentTypes='zbhilcfdO', returnType='z')
+        self.assertEquals(s.signature, '@@:@csilcfd@')
+
+
     def testAll(self):
         if hasattr(objc, '_C_BOOL'):
             self.assertEquals(objc._C_BOOL, "B")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.