[pypy-svn] r29691 - in pypy/dist/pypy/translator/js: . test
fijal at codespeak.net
fijal at codespeak.net
Thu Jul 6 18:00:08 CEST 2006
Author: fijal
Date: Thu Jul 6 18:00:05 2006
New Revision: 29691
Modified:
pypy/dist/pypy/translator/js/database.py
pypy/dist/pypy/translator/js/test/test_bltn.py
Log:
Fixed thing that was working just by accident.
Added another passing test for builtin object.
Modified: pypy/dist/pypy/translator/js/database.py
==============================================================================
--- pypy/dist/pypy/translator/js/database.py (original)
+++ pypy/dist/pypy/translator/js/database.py Thu Jul 6 18:00:05 2006
@@ -410,10 +410,9 @@
return self.const._TYPE._name.split('.')[-1][:-2]
def init(self, ilasm):
- #if getattr(self.const._TYPE._class_, '_render_xmlhttp', False):
- self.db.register_comm_proxy(self.const, self.name)
- ilasm.new(self.get_name())
- #else:
+ if getattr(self.const._TYPE._class_, '_render_xmlhttp', False):
+ self.db.register_comm_proxy(self.const, self.name)
+ ilasm.new(self.get_name())
+ else:
# Otherwise they just exist, or it's not implemented
- # pass
-
+ ilasm.load_str("undefined")
Modified: pypy/dist/pypy/translator/js/test/test_bltn.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/test_bltn.py (original)
+++ pypy/dist/pypy/translator/js/test/test_bltn.py Thu Jul 6 18:00:05 2006
@@ -3,7 +3,7 @@
import py
-from pypy.rpython.ootypesystem.bltregistry import BasicExternal
+from pypy.rpython.ootypesystem.bltregistry import BasicExternal, MethodDesc
from pypy.translator.js.test.runtest import compile_function
def check_source_contains(compiled_function, pattern):
@@ -20,8 +20,27 @@
fn = compile_function(test_document_call, [])
assert check_source_contains(fn, "= document")
- assert check_source_contains(fn, ".getElementById")
+ assert check_source_contains(fn, "\.getElementById")
# check rendering transparent proxy
-#def test_simple_proxy():
+class SomeProxy(BasicExternal):
+ _render_xmlhttp = True
+ _methods = {
+ 'some_method' : MethodDesc([], 3),
+ }
+
+ _fields = {
+ }
+
+SomeProxyInstance = SomeProxy()
+
+def test_simple_proxy():
+ def simple_proxy():
+ retval = SomeProxyInstance.some_method()
+
+ fn = compile_function(simple_proxy, [])
+ assert check_source_contains(fn, "loadJSONDoc\('some_method'")
+
+# next will try out the callback
+
More information about the Pypy-commit
mailing list