diff test_pymonkey.py @ 29:608d086d12e3

Added a new PYM_pyObjectToJsval() function that only supports unicode for the moment. Also, whereever we're assuming that Py_UNICODE is UCS-2, we're surrounding such code with #ifndef Py_UNICODE_WIDE.
author Atul Varma <varmaa@toolness.com>
date Tue, 30 Jun 2009 21:23:04 -0700
parents bd30f5c02fc3
children d0a3f358072a
line wrap: on
line diff
--- a/test_pymonkey.py	Mon Jun 29 14:09:01 2009 -0700
+++ b/test_pymonkey.py	Tue Jun 30 21:23:04 2009 -0700
@@ -9,19 +9,19 @@
         cx.init_standard_classes(obj)
         return cx.evaluate_script(obj, code, '<string>', 1)
 
-    def testDefineFunctionWorks(self):
+    def testJsWrappedPythonFunctionReturnsUnicode(self):
         cx = pymonkey.Runtime().new_context()
         obj = cx.new_object()
         cx.init_standard_classes(obj)
 
-        result = {'wasCalled': False}
-
         def hai2u():
-            result['wasCalled'] = True
+            return u"o hai"
 
         cx.define_function(obj, hai2u, "hai2u")
-        cx.evaluate_script(obj, 'hai2u()', '<string>', 1)
-        self.assertTrue(result['wasCalled'])
+        self.assertEqual(
+            cx.evaluate_script(obj, 'hai2u()', '<string>', 1),
+            u"o hai"
+            )
 
     def testObjectIsIdentityPreserving(self):
         cx = pymonkey.Runtime().new_context()