diff tests/test_pymonkey.py @ 145:5d53f6293a81

Added a basic context.get_stack() function.
author Atul Varma <varmaa@toolness.com>
date Fri, 28 Aug 2009 22:46:07 -0700
parents df97699fc104
children b1cf9decc36f
line wrap: on
line diff
--- a/tests/test_pymonkey.py	Mon Aug 24 22:47:15 2009 -0700
+++ b/tests/test_pymonkey.py	Fri Aug 28 22:46:07 2009 -0700
@@ -48,6 +48,21 @@
                 u'SyntaxError: missing ; before statement'
                 )
 
+    def testGetStackWorks(self):
+        stack_holder = []
+
+        def func(cx, this, args):
+            stack_holder.append(cx.get_stack())
+
+        cx = pymonkey.Runtime().new_context()
+        obj = cx.new_object()
+        cx.init_standard_classes(obj)
+        jsfunc = cx.new_function(func, func.__name__)
+        cx.define_property(obj, func.__name__, jsfunc)
+        cx.evaluate_script(obj, 'func()', '<string>', 1)
+        self.assertEqual(stack_holder[0]['caller']['script'].filename,
+                         '<string>')
+
     def testScriptHasFilenameMember(self):
         cx = pymonkey.Runtime().new_context()
         script = cx.compile_script('foo', '<string>', 1)