Mercurial > pymonkey
comparison 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 |
comparison
equal
deleted
inserted
replaced
28:bd30f5c02fc3 | 29:608d086d12e3 |
---|---|
7 cx = rt.new_context() | 7 cx = rt.new_context() |
8 obj = cx.new_object() | 8 obj = cx.new_object() |
9 cx.init_standard_classes(obj) | 9 cx.init_standard_classes(obj) |
10 return cx.evaluate_script(obj, code, '<string>', 1) | 10 return cx.evaluate_script(obj, code, '<string>', 1) |
11 | 11 |
12 def testDefineFunctionWorks(self): | 12 def testJsWrappedPythonFunctionReturnsUnicode(self): |
13 cx = pymonkey.Runtime().new_context() | 13 cx = pymonkey.Runtime().new_context() |
14 obj = cx.new_object() | 14 obj = cx.new_object() |
15 cx.init_standard_classes(obj) | 15 cx.init_standard_classes(obj) |
16 | 16 |
17 result = {'wasCalled': False} | |
18 | |
19 def hai2u(): | 17 def hai2u(): |
20 result['wasCalled'] = True | 18 return u"o hai" |
21 | 19 |
22 cx.define_function(obj, hai2u, "hai2u") | 20 cx.define_function(obj, hai2u, "hai2u") |
23 cx.evaluate_script(obj, 'hai2u()', '<string>', 1) | 21 self.assertEqual( |
24 self.assertTrue(result['wasCalled']) | 22 cx.evaluate_script(obj, 'hai2u()', '<string>', 1), |
23 u"o hai" | |
24 ) | |
25 | 25 |
26 def testObjectIsIdentityPreserving(self): | 26 def testObjectIsIdentityPreserving(self): |
27 cx = pymonkey.Runtime().new_context() | 27 cx = pymonkey.Runtime().new_context() |
28 obj = cx.new_object() | 28 obj = cx.new_object() |
29 cx.init_standard_classes(obj) | 29 cx.init_standard_classes(obj) |