[pypy-svn] r15447 - in pypy/dist/pypy: interpreter module/time module/time/test
pedronis at codespeak.net
pedronis at codespeak.net
Sat Jul 30 23:36:35 CEST 2005
Author: pedronis
Date: Sat Jul 30 23:36:30 2005
New Revision: 15447
Added:
pypy/dist/pypy/module/time/ (props changed)
pypy/dist/pypy/module/time/__init__.py (contents, props changed)
pypy/dist/pypy/module/time/interp_time.py (contents, props changed)
pypy/dist/pypy/module/time/test/ (props changed)
pypy/dist/pypy/module/time/test/test_time.py (contents, props changed)
Modified:
pypy/dist/pypy/interpreter/baseobjspace.py
Log:
start of an implementation for time module
Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py (original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py Sat Jul 30 23:36:30 2005
@@ -165,6 +165,7 @@
if self.options.nofaking:
l.append('posix')
l.append('math')
+ l.append('time')
for name in self.options.usemodules:
if name not in l:
Added: pypy/dist/pypy/module/time/__init__.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/time/__init__.py Sat Jul 30 23:36:30 2005
@@ -0,0 +1,16 @@
+# Package initialisation
+from pypy.interpreter.mixedmodule import MixedModule
+
+import time
+
+class Module(MixedModule):
+ """time module"""
+
+ appleveldefs = {
+ }
+
+ interpleveldefs = {
+ 'clock' : 'interp_time.clock',
+ 'time' : 'interp_time.time_',
+ }
+
Added: pypy/dist/pypy/module/time/interp_time.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/time/interp_time.py Sat Jul 30 23:36:30 2005
@@ -0,0 +1,7 @@
+import time
+
+def clock(space):
+ return space.wrap(time.clock())
+
+def time_(space):
+ return space.wrap(time.time())
Added: pypy/dist/pypy/module/time/test/test_time.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/time/test/test_time.py Sat Jul 30 23:36:30 2005
@@ -0,0 +1,20 @@
+from pypy.objspace.std import StdObjSpace
+import time
+
+def setup_module(mod):
+ mod.space = StdObjSpace(usemodules=['time'])
+
+class TestTime:
+
+ def test_clock(self):
+ t0 = time.clock()
+ w_t1 = space.appexec([], """(): import time; return time.clock()""")
+ t2 = time.clock()
+ assert t0 <= space.unwrap(w_t1) <= t2
+
+ def test_time(self):
+ t0 = time.time()
+ w_t1 = space.appexec([], """(): import time; return time.time()""")
+ t2 = time.time()
+ assert t0 <= space.unwrap(w_t1) <= t2
+
More information about the Pypy-commit
mailing list