[pypy-svn] r34562 - in pypy/dist/pypy/translator/js/modules: . test

fijal at codespeak.net fijal at codespeak.net
Mon Nov 13 15:21:01 CET 2006


Author: fijal
Date: Mon Nov 13 15:20:58 2006
New Revision: 34562

Modified:
   pypy/dist/pypy/translator/js/modules/dom.py
   pypy/dist/pypy/translator/js/modules/test/test_dom.py
Log:
Modified a test to suit translation needs.


Modified: pypy/dist/pypy/translator/js/modules/dom.py
==============================================================================
--- pypy/dist/pypy/translator/js/modules/dom.py	(original)
+++ pypy/dist/pypy/translator/js/modules/dom.py	Mon Nov 13 15:20:58 2006
@@ -259,11 +259,15 @@
 # some helper functions (XXX imo these can go, but the code seems to use them
 # a lot... isn't it possible to just use dom.window and dom.document instead?)
 
+window = Window()
+
 def get_document():
-    return NonConstant(Window().document)
+    return window.document
+get_document.suggested_primitive = True
 
 def get_window():
-    return NonConstant(Window())
+    return window
+get_window.suggested_primitive = True
 
 # rtyper stuff
 

Modified: pypy/dist/pypy/translator/js/modules/test/test_dom.py
==============================================================================
--- pypy/dist/pypy/translator/js/modules/test/test_dom.py	(original)
+++ pypy/dist/pypy/translator/js/modules/test/test_dom.py	Mon Nov 13 15:20:58 2006
@@ -17,7 +17,10 @@
         e.stopPropagation()
 
 def get_window():
-    return dom.get_window()
+    if TRANSLATING:
+        return dom.get_window()
+    else:
+        return dom.Window()
 
 def test_quote_html():
     assert dom._quote_html('foo&bar') == 'foo&bar'
@@ -38,7 +41,7 @@
     assert roundtrip(html) == html
 
 def code_init():
-    window = dom.get_window()
+    window = get_window()
     nodeType = window.document.nodeType
     docel = window.document.documentElement.nodeName
     children = len(window.document.documentElement.childNodes)
@@ -310,8 +313,12 @@
 
 def test_build():
     py.test.skip('Borken')
+    global TRANSLATING
+    TRANSLATING = True
     for var in globals():
         if var.startswith('code_'):
             # just build it
-            rpython2javascript(sys.modules[__name__], [var])
-
+            def f():
+                assert rpython2javascript(sys.modules[__name__], [var], use_pdb=False)
+            
+            yield f



More information about the Pypy-commit mailing list