[pypy-svn] r25683 - in pypy/dist/pypy/objspace/flow: . test
tismer at codespeak.net
tismer at codespeak.net
Tue Apr 11 05:47:28 CEST 2006
Author: tismer
Date: Tue Apr 11 05:47:24 2006
New Revision: 25683
Modified:
pypy/dist/pypy/objspace/flow/objspace.py
pypy/dist/pypy/objspace/flow/test/test_objspace.py
Log:
testing lazy constant.
const propagation for modules not yet implemented (do we want this?)
Modified: pypy/dist/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/flow/objspace.py (original)
+++ pypy/dist/pypy/objspace/flow/objspace.py Tue Apr 11 05:47:24 2006
@@ -193,6 +193,8 @@
self.executioncontext = ec
from pypy.objspace.flow import specialcase
specialcase.setup(self)
+ self.const_tracker = None
+ # maybe it would be cleaner to have the tracker in the EC itself?
def exception_match(self, w_exc_type, w_check_class):
self.executioncontext.recorder.crnt_block.exc_handler = True
Modified: pypy/dist/pypy/objspace/flow/test/test_objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/flow/test/test_objspace.py (original)
+++ pypy/dist/pypy/objspace/flow/test/test_objspace.py Tue Apr 11 05:47:24 2006
@@ -655,7 +655,31 @@
def test_import_something(self):
def f():
from some.unknown.module import stuff
- self.codetest(f)
+ g = self.codetest(f)
+
+ def test_lazy_constant_simple(self):
+ def f():
+ global xxx_global
+ from pypy.objspace.flow.test.test_objspace import \
+ user_defined_function as xxx_global, DATA
+ return xxx_global
+ g = self.codetest(f)
+ consts = [self.space.unwrap(c) for c in self.space.const_tracker.known_consts.values()]
+ assert user_defined_function in consts
+ assert DATA not in consts
+ global xxx_global; xxx_global = 42; del xxx_global
+
+ def not_yet_test_lazy_constant_harder(self):
+ def f():
+ global xxx_global
+ import pypy as xxx_global
+ ret = xxx_global.objspace.flow.test.test_objspace.user_defined_function
+ return ret
+ g = self.codetest(f)
+ consts = [self.space.unwrap(c) for c in self.space.const_tracker.known_consts.values()]
+ assert user_defined_function in consts
+ assert DATA not in consts
+ global xxx_global; xxx_global = 42; del xxx_global
DATA = {'x': 5,
'y': 6}
More information about the Pypy-commit
mailing list