[pypy-commit] pypy default: fix tests for win32

2019-08-12 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r97160:d08393b13818
Date: 2019-08-12 11:54 +0300
http://bitbucket.org/pypy/pypy/changeset/d08393b13818/

Log:fix tests for win32

diff --git a/extra_tests/ctypes_tests/test_win32.py 
b/extra_tests/ctypes_tests/test_win32.py
--- a/extra_tests/ctypes_tests/test_win32.py
+++ b/extra_tests/ctypes_tests/test_win32.py
@@ -5,7 +5,7 @@
 import pytest
 
 @pytest.mark.skipif("sys.platform != 'win32'")
-def test_VARIANT(self):
+def test_VARIANT():
 from ctypes import wintypes
 a = wintypes.VARIANT_BOOL()
 assert a.value is False
diff --git a/extra_tests/test_datetime.py b/extra_tests/test_datetime.py
--- a/extra_tests/test_datetime.py
+++ b/extra_tests/test_datetime.py
@@ -128,7 +128,7 @@
 import os
 import time
 if os.name == 'nt':
-skip("setting os.environ['TZ'] ineffective on windows")
+pytest.skip("setting os.environ['TZ'] ineffective on windows")
 try:
 prev_tz = os.environ.get("TZ")
 os.environ["TZ"] = "GMT"
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests to pass on win32

2018-11-11 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r95297:956dce5d3456
Date: 2018-11-11 00:25 -0800
http://bitbucket.org/pypy/pypy/changeset/956dce5d3456/

Log:fix tests to pass on win32

diff --git a/pypy/module/posix/test/test_posix2.py 
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -211,9 +211,9 @@
 def test_pickle(self):
 import pickle, os
 st = self.posix.stat(os.curdir)
-print type(st).__module__
+# print type(st).__module__
 s = pickle.dumps(st)
-print repr(s)
+# print repr(s)
 new = pickle.loads(s)
 assert new == st
 assert type(new) is type(st)
@@ -303,7 +303,7 @@
 try:
 fid = posix.fdopen(fd)
 fid.read(10)
-except OSError as e:
+except (IOError, OSError) as e:
 assert e.errno == errno.EBADF
 else:
 assert False, "using result of fdopen(fd) on closed file must 
raise"
@@ -576,6 +576,12 @@
 assert '\nOSError: [Errno 9]' in res
 else:
 assert res == 'test1\n'
+if sys.platform == "win32":
+# using startfile in app_startfile creates global state
+test_popen.dont_track_allocations = True
+test_popen_with.dont_track_allocations = True
+test_popen_child_fds.dont_track_allocations = True
+
 
 if hasattr(__import__(os.name), '_getfullpathname'):
 def test__getfullpathname(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests

2018-06-25 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94781:2ae825a19da0
Date: 2018-06-25 21:42 -0700
http://bitbucket.org/pypy/pypy/changeset/2ae825a19da0/

Log:fix tests

diff --git a/pypy/module/cpyext/test/test_unicodeobject.py 
b/pypy/module/cpyext/test/test_unicodeobject.py
--- a/pypy/module/cpyext/test/test_unicodeobject.py
+++ b/pypy/module/cpyext/test/test_unicodeobject.py
@@ -4,7 +4,7 @@
 from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
 from pypy.module.cpyext.unicodeobject import (
 Py_UNICODE, PyUnicodeObject, new_empty_unicode)
-from pypy.module.cpyext.api import PyObjectP, PyObject
+from pypy.module.cpyext.api import PyObjectP, PyObject, INTP_real
 from pypy.module.cpyext.pyobject import decref, from_ref
 from rpython.rtyper.lltypesystem import rffi, lltype
 import sys, py
@@ -464,8 +464,8 @@
 value = 1
 else:
 value = 0
-pendian = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
-pendian[0] = rffi.cast(rffi.INT, value)
+pendian = lltype.malloc(INTP_real.TO, 1, flavor='raw')
+pendian[0] = rffi.cast(rffi.INT_real, value)
 else:
 pendian = None
 
@@ -477,7 +477,7 @@
 rffi.free_charp(strict_charp)
 if pendian:
 if realendian is not None:
-assert rffi.cast(rffi.INT, realendian) == pendian[0]
+assert rffi.cast(rffi.INT_real, realendian) == pendian[0]
 lltype.free(pendian, flavor='raw')
 
 test("\x61\x00\x62\x00\x63\x00\x64\x00", -1)
@@ -500,8 +500,8 @@
 value = 1
 else:
 value = 0
-pendian = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
-pendian[0] = rffi.cast(rffi.INT, value)
+pendian = lltype.malloc(INTP_real.TO, 1, flavor='raw')
+pendian[0] = rffi.cast(rffi.INT_real, value)
 else:
 pendian = None
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests

2018-06-25 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94780:9272d1b47f51
Date: 2018-06-25 21:35 -0700
http://bitbucket.org/pypy/pypy/changeset/9272d1b47f51/

Log:fix tests

diff --git a/pypy/module/cpyext/test/test_pystrtod.py 
b/pypy/module/cpyext/test/test_pystrtod.py
--- a/pypy/module/cpyext/test/test_pystrtod.py
+++ b/pypy/module/cpyext/test/test_pystrtod.py
@@ -4,7 +4,7 @@
 from pypy.module.cpyext.test.test_api import BaseApiTest, raises_w
 from rpython.rtyper.lltypesystem import rffi
 from rpython.rtyper.lltypesystem import lltype
-from pypy.module.cpyext.pystrtod import PyOS_string_to_double
+from pypy.module.cpyext.pystrtod import PyOS_string_to_double, INTP_real
 
 
 class TestPyOS_string_to_double(BaseApiTest):
@@ -90,7 +90,7 @@
 class TestPyOS_double_to_string(BaseApiTest):
 
 def test_format_code(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(150.0, 'e', 1, 0, ptype)
 assert '1.5e+02' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -99,7 +99,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_precision(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(3.14159269397, 'g', 5, 0, ptype)
 assert '3.1416' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -108,7 +108,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_flags_sign(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(-3.14, 'g', 3, 1, ptype)
 assert '-3.14' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -117,7 +117,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_flags_add_dot_0(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(3, 'g', 5, 2, ptype)
 assert '3.0' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -126,7 +126,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_flags_alt(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(314., 'g', 3, 4, ptype)
 assert '314.' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -135,7 +135,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_ptype_nan(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(float('nan'), 'g', 3, 4, ptype)
 assert 'nan' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -144,7 +144,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_ptype_infinity(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(1e200 * 1e200, 'g', 0, 0, ptype)
 assert 'inf' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -153,8 +153,8 @@
 lltype.free(ptype, flavor='raw')
 
 def test_ptype_null(self, api):
-ptype = lltype.nullptr(rffi.INTP.TO)
+ptype = lltype.nullptr(INTP_real.TO)
 r = api.PyOS_double_to_string(3.14, 'g', 3, 0, ptype)
 assert '3.14' == rffi.charp2str(r)
-assert ptype == lltype.nullptr(rffi.INTP.TO)
+assert ptype == lltype.nullptr(INTP_real.TO)
 rffi.free_charp(r)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests

2017-11-03 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r92916:503b1a72abab
Date: 2017-11-03 17:11 +0200
http://bitbucket.org/pypy/pypy/changeset/503b1a72abab/

Log:fix tests

diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -213,8 +213,9 @@
 old_dir = os.getcwd()
 try:
 os.chdir(str(builddir))
-for source, target in binaries:
-smartstrip(bindir.join(target), keep_debug=options.keep_debug)
+if not _fake:
+for source, target in binaries:
+smartstrip(bindir.join(target), keep_debug=options.keep_debug)
 #
 if USE_ZIPFILE_MODULE:
 import zipfile
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests, hopefully

2017-09-09 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r92362:e2f4a15ea640
Date: 2017-09-09 15:01 +0200
http://bitbucket.org/pypy/pypy/changeset/e2f4a15ea640/

Log:fix tests, hopefully

diff --git a/rpython/jit/codewriter/test/test_longlong.py 
b/rpython/jit/codewriter/test/test_longlong.py
--- a/rpython/jit/codewriter/test/test_longlong.py
+++ b/rpython/jit/codewriter/test/test_longlong.py
@@ -17,7 +17,7 @@
 class FakeBuiltinCallControl:
 def guess_call_kind(self, op):
 return 'builtin'
-def getcalldescr(self, op, oopspecindex=None, extraeffect=None, 
extradescr=None):
+def getcalldescr(self, op, oopspecindex=None, **kwargs):
 assert oopspecindex is not None# in this test
 return 'calldescr-%d' % oopspecindex
 def calldescr_canraise(self, calldescr):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests and scatter real_time parameter to other functions needed

2017-06-05 Thread plan_rich
Author: Richard Plangger 
Branch: 
Changeset: r91525:82f30247c9bb
Date: 2017-06-05 09:06 -0400
http://bitbucket.org/pypy/pypy/changeset/82f30247c9bb/

Log:fix tests and scatter real_time parameter to other functions needed

diff --git a/pypy/module/_vmprof/test/test__vmprof.py 
b/pypy/module/_vmprof/test/test__vmprof.py
--- a/pypy/module/_vmprof/test/test__vmprof.py
+++ b/pypy/module/_vmprof/test/test__vmprof.py
@@ -60,7 +60,7 @@
 import _vmprof
 gc.collect()  # try to make the weakref list deterministic
 gc.collect()  # by freeing all dead code objects
-_vmprof.enable(tmpfileno, 0.01, 0, 0, 0)
+_vmprof.enable(tmpfileno, 0.01, 0, 0, 0, 0)
 _vmprof.disable()
 s = open(self.tmpfilename, 'rb').read()
 no_of_codes = count(s)
@@ -73,7 +73,7 @@
 
 gc.collect()
 gc.collect()
-_vmprof.enable(tmpfileno2, 0.01, 0, 0, 0)
+_vmprof.enable(tmpfileno2, 0.01, 0, 0, 0, 0)
 
 exec """def foo2():
 pass
@@ -88,18 +88,18 @@
 
 def test_enable_ovf(self):
 import _vmprof
-raises(_vmprof.VMProfError, _vmprof.enable, 2, 0, 0, 0, 0)
-raises(_vmprof.VMProfError, _vmprof.enable, 2, -2.5, 0, 0, 0)
-raises(_vmprof.VMProfError, _vmprof.enable, 2, 1e300, 0, 0, 0)
-raises(_vmprof.VMProfError, _vmprof.enable, 2, 1e300 * 1e300, 0, 0, 0)
+raises(_vmprof.VMProfError, _vmprof.enable, 2, 0, 0, 0, 0, 0)
+raises(_vmprof.VMProfError, _vmprof.enable, 2, -2.5, 0, 0, 0, 0)
+raises(_vmprof.VMProfError, _vmprof.enable, 2, 1e300, 0, 0, 0, 0)
+raises(_vmprof.VMProfError, _vmprof.enable, 2, 1e300 * 1e300, 0, 0, 0, 
0)
 NaN = (1e300*1e300) / (1e300*1e300)
-raises(_vmprof.VMProfError, _vmprof.enable, 2, NaN, 0, 0, 0)
+raises(_vmprof.VMProfError, _vmprof.enable, 2, NaN, 0, 0, 0, 0)
 
 def test_is_enabled(self):
 import _vmprof
 tmpfile = open(self.tmpfilename, 'wb')
 assert _vmprof.is_enabled() is False
-_vmprof.enable(tmpfile.fileno(), 0.01, 0, 0, 0)
+_vmprof.enable(tmpfile.fileno(), 0.01, 0, 0, 0, 0)
 assert _vmprof.is_enabled() is True
 _vmprof.disable()
 assert _vmprof.is_enabled() is False
@@ -108,7 +108,7 @@
 import _vmprof
 tmpfile = open(self.tmpfilename, 'wb')
 assert _vmprof.get_profile_path() is None
-_vmprof.enable(tmpfile.fileno(), 0.01, 0, 0, 0)
+_vmprof.enable(tmpfile.fileno(), 0.01, 0, 0, 0, 0)
 path = _vmprof.get_profile_path()
 if path != tmpfile.name:
 with open(path, "rb") as fd1:
diff --git a/rpython/rlib/rvmprof/__init__.py b/rpython/rlib/rvmprof/__init__.py
--- a/rpython/rlib/rvmprof/__init__.py
+++ b/rpython/rlib/rvmprof/__init__.py
@@ -33,8 +33,8 @@
 return code._vmprof_unique_id
 return 0
 
-def enable(fileno, interval, memory=0, native=0):
-_get_vmprof().enable(fileno, interval, memory, native)
+def enable(fileno, interval, memory=0, native=0, real_time=0):
+_get_vmprof().enable(fileno, interval, memory, native, real_time)
 
 def disable():
 _get_vmprof().disable()
diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py
--- a/rpython/rlib/rvmprof/cintf.py
+++ b/rpython/rlib/rvmprof/cintf.py
@@ -84,7 +84,7 @@
 eci = global_eci
 vmprof_init = rffi.llexternal("vmprof_init",
   [rffi.INT, rffi.DOUBLE, rffi.INT, rffi.INT,
-   rffi.CCHARP, rffi.INT],
+   rffi.CCHARP, rffi.INT, rffi.INT],
   rffi.CCHARP, compilation_info=eci)
 vmprof_enable = rffi.llexternal("vmprof_enable", [rffi.INT, rffi.INT, 
rffi.INT],
 rffi.INT,
diff --git a/rpython/rlib/rvmprof/rvmprof.py b/rpython/rlib/rvmprof/rvmprof.py
--- a/rpython/rlib/rvmprof/rvmprof.py
+++ b/rpython/rlib/rvmprof/rvmprof.py
@@ -124,7 +124,7 @@
 self._gather_all_code_objs = gather_all_code_objs
 
 @jit.dont_look_inside
-def enable(self, fileno, interval, memory=0, native=0):
+def enable(self, fileno, interval, memory=0, native=0, real_time=0):
 """Enable vmprof.  Writes go to the given 'fileno'.
 The sampling interval is given by 'interval' as a number of
 seconds, as a float which must be smaller than 1.0.
@@ -138,12 +138,12 @@
 native = 0 # force disabled on Windows
 lines = 0 # not supported on PyPy currently
 
-p_error = self.cintf.vmprof_init(fileno, interval, lines, memory, 
"pypy", native)
+p_error = self.cintf.vmprof_init(fileno, interval, lines, memory, 
"pypy", native, real_time)
 if p_error:
 raise VMProfError(rffi.charp2str(p_error))
 
 self._gather_all_code_objs()
-res = self.cintf.vmprof_enable(memory, native)
+res = self.cintf.vmprof_enable(memory, native, real_time)
 

[pypy-commit] pypy default: fix tests

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90186:56d384d17f52
Date: 2017-02-19 09:55 +0100
http://bitbucket.org/pypy/pypy/changeset/56d384d17f52/

Log:fix tests

diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -492,7 +492,7 @@
 
 class TestPosixAscii(BasePosixUnicodeOrAscii):
 def _get_filename(self):
-return str(udir.join('test_open_ascii'))
+return unicode(udir.join('test_open_ascii'))
 
 @rposix_requires('openat')
 def test_openat(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests that import test_vector

2017-01-22 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r89686:858ae6e5cbfe
Date: 2017-01-22 17:35 +0100
http://bitbucket.org/pypy/pypy/changeset/858ae6e5cbfe/

Log:fix tests that import test_vector

diff --git a/rpython/jit/backend/ppc/test/test_ppcvector.py 
b/rpython/jit/backend/ppc/test/test_ppcvector.py
--- a/rpython/jit/backend/ppc/test/test_ppcvector.py
+++ b/rpython/jit/backend/ppc/test/test_ppcvector.py
@@ -1,10 +1,10 @@
 import py
 from rpython.jit.backend.ppc.test import test_basic
-from rpython.jit.metainterp.test import test_vector
+from rpython.jit.metainterp.test import test_zvector
 from rpython.jit.backend.ppc.detect_feature import detect_vsx
 
 
-class TestBasic(test_basic.JitPPCMixin, test_vector.VectorizeTests):
+class TestBasic(test_basic.JitPPCMixin, test_zvector.VectorizeTests):
 # for the individual tests see
 # > ../../../metainterp/test/test_basic.py
 def setup_method(self, method):
diff --git a/rpython/jit/backend/x86/test/test_x86vector.py 
b/rpython/jit/backend/x86/test/test_x86vector.py
--- a/rpython/jit/backend/x86/test/test_x86vector.py
+++ b/rpython/jit/backend/x86/test/test_x86vector.py
@@ -6,11 +6,11 @@
 from rpython.jit.backend.x86.test import test_basic
 from rpython.jit.backend.x86.test.test_assembler import \
 (TestRegallocPushPop as BaseTestAssembler)
-from rpython.jit.metainterp.test import test_vector
+from rpython.jit.metainterp.test import test_zvector
 from rpython.rtyper.lltypesystem import lltype
 from rpython.jit.backend.detect_cpu import getcpuclass
 
-class TestBasic(test_basic.Jit386Mixin, test_vector.VectorizeTests):
+class TestBasic(test_basic.Jit386Mixin, test_zvector.VectorizeTests):
 # for the individual tests see
 # > ../../../metainterp/test/test_basic.py
 def setup_method(self, method):
diff --git a/rpython/jit/backend/zarch/test/test_zarchvector.py 
b/rpython/jit/backend/zarch/test/test_zarchvector.py
--- a/rpython/jit/backend/zarch/test/test_zarchvector.py
+++ b/rpython/jit/backend/zarch/test/test_zarchvector.py
@@ -1,10 +1,10 @@
 import py
 from rpython.jit.backend.zarch.test import test_basic
-from rpython.jit.metainterp.test import test_vector
+from rpython.jit.metainterp.test import test_zvector
 from rpython.jit.backend.zarch.detect_feature import detect_simd_z
 
 
-class TestBasic(test_basic.JitZARCHMixin, test_vector.VectorizeTests):
+class TestBasic(test_basic.JitZARCHMixin, test_zvector.VectorizeTests):
 # for the individual tests see
 # > ../../../metainterp/test/test_basic.py
 def setup_method(self, method):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests

2016-11-08 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88205:4c405c663a1c
Date: 2016-11-08 11:47 +0100
http://bitbucket.org/pypy/pypy/changeset/4c405c663a1c/

Log:fix tests

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -543,6 +543,9 @@
 return OperationError(space.w_KeyboardInterrupt, space.w_None)
 except MemoryError:
 return OperationError(space.w_MemoryError, space.w_None)
+except NotImplementedError:   # not on top of pypy! tests only
+return OperationError(space.w_SystemError,
+  space.wrap("NotImplementedError"))
 except rstackovf.StackOverflow as e:
 rstackovf.check_stack_overflow()
 return oefmt(space.w_RuntimeError,
diff --git a/pypy/module/gc/test/test_app_referents.py 
b/pypy/module/gc/test/test_app_referents.py
--- a/pypy/module/gc/test/test_app_referents.py
+++ b/pypy/module/gc/test/test_app_referents.py
@@ -4,12 +4,13 @@
 
 def test_interface_to_dump_rpy_heap_str(space):
 filename = str(udir.join('dump_rpy_heap.str'))
-try:
-space.appexec([space.wrap(filename)], """(filename):
-import gc
-gc.dump_rpy_heap(filename)""")
-except NotImplementedError:
-pass
+space.appexec([space.wrap(filename)], """(filename):
+import gc
+try:
+gc.dump_rpy_heap(filename)
+except SystemError:
+pass
+""")
 assert os.path.exists(filename)
 
 def test_interface_to_dump_rpy_heap_file(space):
@@ -20,20 +21,22 @@
 f.write('X')
 return f""")
 assert os.path.getsize(filename) == 0   # the 'X' was not flushed yet
-try:
-space.appexec([w_f], """(f):
-import gc
-gc.dump_rpy_heap(f)""")
-except NotImplementedError:
-pass
+space.appexec([w_f], """(f):
+import gc
+try:
+gc.dump_rpy_heap(f)
+except SystemError:
+pass
+""")
 assert os.path.getsize(filename) == 1   # the 'X' was flushed here
 
 def test_interface_to_dump_rpy_heap_fd(space):
 filename = str(udir.join('dump_rpy_heap.fd'))
 f = open(filename, 'wb')
-try:
-space.appexec([space.wrap(f.fileno())], """(fd):
-import gc
-gc.dump_rpy_heap(fd)""")
-except NotImplementedError:
-pass
+space.appexec([space.wrap(f.fileno())], """(fd):
+import gc
+try:
+gc.dump_rpy_heap(fd)
+except SystemError:
+pass
+""")
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix tests (test_throw1 and test_throw2 were identical at this point)

2016-09-16 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r87137:f6eabcc3367c
Date: 2016-09-16 16:10 +0200
http://bitbucket.org/pypy/pypy/changeset/f6eabcc3367c/

Log:Fix tests (test_throw1 and test_throw2 were identical at this point)

diff --git a/pypy/interpreter/test/test_generator.py 
b/pypy/interpreter/test/test_generator.py
--- a/pypy/interpreter/test/test_generator.py
+++ b/pypy/interpreter/test/test_generator.py
@@ -57,6 +57,7 @@
 def f():
 yield 2
 g = f()
+g.next()
 raises(NameError, g.throw, NameError, "Error")
 
 def test_throw2(self):
@@ -64,6 +65,7 @@
 yield 2
 g = f()
 raises(NameError, g.throw, NameError("Error"))
+raises(StopIteration, g.next)
 
 def test_throw3(self):
 def f():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix tests, now that 'lltype.typeOf(very_large_long)' gives an error

2016-07-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r85917:0cafa40b38a9
Date: 2016-07-29 20:25 +0200
http://bitbucket.org/pypy/pypy/changeset/0cafa40b38a9/

Log:Fix tests, now that 'lltype.typeOf(very_large_long)' gives an error

diff --git a/pypy/objspace/std/test/test_stdobjspace.py 
b/pypy/objspace/std/test/test_stdobjspace.py
--- a/pypy/objspace/std/test/test_stdobjspace.py
+++ b/pypy/objspace/std/test/test_stdobjspace.py
@@ -66,17 +66,18 @@
 
 def test_wrap_various_unsigned_types(self):
 import sys
+from rpython.rlib.rarithmetic import r_uint
 from rpython.rtyper.lltypesystem import lltype, rffi
 space = self.space
 value = sys.maxint * 2
-x = rffi.cast(lltype.Unsigned, value)
+x = r_uint(value)
 assert space.eq_w(space.wrap(value), space.wrap(x))
-x = rffi.cast(rffi.UINTPTR_T, value)
+x = rffi.cast(rffi.UINTPTR_T, r_uint(value))
 assert x > 0
 assert space.eq_w(space.wrap(value), space.wrap(x))
 value = 6
-x = rffi.cast(rffi.USHORT, value)
+x = rffi.cast(rffi.USHORT, r_uint(value))
 assert space.eq_w(space.wrap(value), space.wrap(x))
 value = 200
-x = rffi.cast(rffi.UCHAR, value)
+x = rffi.cast(rffi.UCHAR, r_uint(value))
 assert space.eq_w(space.wrap(value), space.wrap(x))
diff --git a/rpython/jit/backend/x86/test/test_regloc.py 
b/rpython/jit/backend/x86/test/test_regloc.py
--- a/rpython/jit/backend/x86/test/test_regloc.py
+++ b/rpython/jit/backend/x86/test/test_regloc.py
@@ -147,7 +147,7 @@
 py.test.skip()
 
 def test_reuse_scratch_register(self):
-base_addr = 0xFEDCBA9876543210
+base_addr = intmask(0xFEDCBA9876543210)
 cb = LocationCodeBuilder64()
 cb.begin_reuse_scratch_register()
 cb.MOV(ecx, heap(base_addr))
@@ -167,7 +167,7 @@
 # 
 
 def test_64bit_address_1(self):
-base_addr = 0xFEDCBA9876543210
+base_addr = intmask(0xFEDCBA9876543210)
 cb = LocationCodeBuilder64()
 cb.CMP(ecx, AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr))
 # this case is a CMP_rj
@@ -181,7 +181,7 @@
 assert cb.getvalue() == expected_instructions
 
 def test_64bit_address_2(self):
-base_addr = 0xFEDCBA9876543210
+base_addr = intmask(0xFEDCBA9876543210)
 cb = LocationCodeBuilder64()
 cb.MOV(ecx, AddressLoc(ImmedLoc(0), edx, 3, base_addr))
 # this case is a CMP_ra
@@ -195,7 +195,7 @@
 assert cb.getvalue() == expected_instructions
 
 def test_64bit_address_3(self):
-base_addr = 0xFEDCBA9876543210
+base_addr = intmask(0xFEDCBA9876543210)
 cb = LocationCodeBuilder64()
 cb.MOV(ecx, AddressLoc(edx, ImmedLoc(0), 0, base_addr))
 # this case is a CMP_rm
@@ -211,7 +211,7 @@
 assert cb.getvalue() == expected_instructions
 
 def test_64bit_address_4(self):
-base_addr = 0xFEDCBA9876543210
+base_addr = intmask(0xFEDCBA9876543210)
 cb = LocationCodeBuilder64()
 cb.begin_reuse_scratch_register()
 assert cb._reuse_scratch_register is True
@@ -234,7 +234,7 @@
 # 
 
 def test_MOV_64bit_constant_into_r11(self):
-base_constant = 0xFEDCBA9876543210
+base_constant = intmask(0xFEDCBA9876543210)
 cb = LocationCodeBuilder64()
 cb.MOV(r11, imm(base_constant))
 
@@ -245,7 +245,7 @@
 assert cb.getvalue() == expected_instructions
 
 def test_MOV_64bit_constant_into_rax(self):
-base_constant = 0xFEDCBA9876543210
+base_constant = intmask(0xFEDCBA9876543210)
 cb = LocationCodeBuilder64()
 cb.MOV(eax, imm(base_constant))
 
@@ -256,7 +256,7 @@
 assert cb.getvalue() == expected_instructions
 
 def test_MOV_64bit_address_into_r11(self):
-base_addr = 0xFEDCBA9876543210
+base_addr = intmask(0xFEDCBA9876543210)
 cb = LocationCodeBuilder64()
 cb.MOV(r11, heap(base_addr))
 
@@ -270,7 +270,7 @@
 
 def test_MOV_immed32_into_64bit_address_1(self):
 immed = -0x01234567
-base_addr = 0xFEDCBA9876543210
+base_addr = intmask(0xFEDCBA9876543210)
 cb = LocationCodeBuilder64()
 cb.MOV(AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr),
ImmedLoc(immed))
@@ -286,7 +286,7 @@
 
 def test_MOV_immed32_into_64bit_address_2(self):
 immed = -0x01234567
-base_addr = 0xFEDCBA9876543210
+base_addr = intmask(0xFEDCBA9876543210)
 cb = LocationCodeBuilder64()
 cb.MOV(AddressLoc(ImmedLoc(0), edx, 3, base_addr),
ImmedLoc(immed))
@@ -302,7 +302,7 @@
 
 def test_MOV_immed32_into_64bit_address_3(self):
 immed = -0x01234567
-base_addr = 0xFEDCBA9876543210
+base_addr = 

[pypy-commit] pypy default: fix tests for win32

2016-07-07 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r85599:8ab2ec92dcfc
Date: 2016-07-07 18:11 +0300
http://bitbucket.org/pypy/pypy/changeset/8ab2ec92dcfc/

Log:fix tests for win32

diff --git a/pypy/module/cpyext/test/foo.c b/pypy/module/cpyext/test/foo.c
--- a/pypy/module/cpyext/test/foo.c
+++ b/pypy/module/cpyext/test/foo.c
@@ -747,6 +747,7 @@
 if (PyType_Ready() < 0)
 INITERROR;
 
+TupleLike.tp_flags = Py_TPFLAGS_DEFAULT;
 TupleLike.tp_base = _Type;
 if (PyType_Ready() < 0)
 INITERROR;
diff --git a/pypy/module/cpyext/test/test_bytesobject.py 
b/pypy/module/cpyext/test/test_bytesobject.py
--- a/pypy/module/cpyext/test/test_bytesobject.py
+++ b/pypy/module/cpyext/test/test_bytesobject.py
@@ -113,9 +113,10 @@
 module = self.import_extension('foo', [
 ("getbytes", "METH_NOARGS",
  """
- PyObject* s1 = PyBytes_FromStringAndSize("test", 4);
- char* c = PyBytes_AsString(s1);
- PyObject* s2 = PyBytes_FromStringAndSize(c, 4);
+ char *c;
+ PyObject* s2, *s1 = PyBytes_FromStringAndSize("test", 4);
+ c = PyBytes_AsString(s1);
+ s2 = PyBytes_FromStringAndSize(c, 4);
  Py_DECREF(s1);
  return s2;
  """),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests for 32 bit and running as root in chroot

2016-05-08 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r84315:392dd419f5d0
Date: 2016-05-09 03:19 +
http://bitbucket.org/pypy/pypy/changeset/392dd419f5d0/

Log:fix tests for 32 bit and running as root in chroot

tests still fail since rffi.INTPTR_T is ending up as a 'Signed' in
the ptr-to-function signature

diff --git a/pypy/module/cpyext/test/test_api.py 
b/pypy/module/cpyext/test/test_api.py
--- a/pypy/module/cpyext/test/test_api.py
+++ b/pypy/module/cpyext/test/test_api.py
@@ -1,4 +1,4 @@
-import py
+import py, pytest
 from rpython.rtyper.lltypesystem import rffi, lltype
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.module.cpyext.state import State
@@ -100,7 +100,8 @@
 PyPy_TypedefTest2(space, ppos)
 lltype.free(ppos, flavor='raw')
 
-
+@pytest.mark.skipif(os.environ.get('USER')=='root', 
+reason='root can write to all files')
 def test_copy_header_files(tmpdir):
 api.copy_header_files(tmpdir, True)
 def check(name):
diff --git a/pypy/module/cpyext/test/test_bytesobject.py 
b/pypy/module/cpyext/test/test_bytesobject.py
--- a/pypy/module/cpyext/test/test_bytesobject.py
+++ b/pypy/module/cpyext/test/test_bytesobject.py
@@ -40,7 +40,7 @@
  #endif
  if(s->ob_type->tp_basicsize != expected_size)
  {
- printf("tp_basicsize==%ld\\n", s->ob_type->tp_basicsize); 
+ printf("tp_basicsize==%zd\\n", s->ob_type->tp_basicsize); 
  result = 0;
  }
  Py_DECREF(s);
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -1521,7 +1521,7 @@
 # Instantiated in cpyext/ndarrayobject. It is here since ufunc calls
 # set_dims_and_steps, otherwise ufunc, ndarrayobject would have circular
 # imports
-npy_intpp = rffi.LONGP
+npy_intpp = rffi.INTPTR_T
 LONG_SIZE = LONG_BIT / 8
 CCHARP_SIZE = _get_bitsize('P') / 8
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests

2015-10-26 Thread mattip
Author: mattip 
Branch: 
Changeset: r80460:53d7da76969d
Date: 2015-10-26 23:32 +1100
http://bitbucket.org/pypy/pypy/changeset/53d7da76969d/

Log:fix tests

diff --git a/pypy/module/cpyext/test/test_ndarrayobject.py 
b/pypy/module/cpyext/test/test_ndarrayobject.py
--- a/pypy/module/cpyext/test/test_ndarrayobject.py
+++ b/pypy/module/cpyext/test/test_ndarrayobject.py
@@ -430,5 +430,5 @@
 assert (out == arr * 2).all()
 
 times2prime = mod.create_ufunc_signature()
-out = times2prime(arr, sig='(d)->(d)', extobj=[0, 0, None])
+out = times2prime(arr, sig='d->d', extobj=[0, 0, None])
 assert (out == arr * 2).all()
diff --git a/pypy/module/micronumpy/test/test_subtype.py 
b/pypy/module/micronumpy/test/test_subtype.py
--- a/pypy/module/micronumpy/test/test_subtype.py
+++ b/pypy/module/micronumpy/test/test_subtype.py
@@ -437,7 +437,7 @@
 assert (b == a).all()
 
 d = np.empty([6,2], dtype=float)
-d.view(int).fill(0xdeadbeef)
+d.view('int64').fill(0xdeadbeef)
 e = d[0::3,:]
 e[...] = [[1, 2], [3, 4]]
 assert e.strides == (48, 8)
@@ -447,7 +447,7 @@
 assert (g == [[1, 2], [3, 4]]).all()
 
 k = np.empty([2, 8], dtype=float)
-k.view(int).fill(0xdeadbeef)
+k.view('int64').fill(0xdeadbeef)
 m = k[:, ::-4]
 m[...] = [[1, 2], [3, 4]]
 assert m.strides == (64, -32)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix tests

2015-08-19 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r79061:ae500e6ab940
Date: 2015-08-19 17:21 +0200
http://bitbucket.org/pypy/pypy/changeset/ae500e6ab940/

Log:Fix tests

diff --git a/pypy/module/_vmprof/test/test__vmprof.py 
b/pypy/module/_vmprof/test/test__vmprof.py
--- a/pypy/module/_vmprof/test/test__vmprof.py
+++ b/pypy/module/_vmprof/test/test__vmprof.py
@@ -21,11 +21,12 @@
 i = 0
 count = 0
 i += 5 * WORD # header
-assert s[i] == '\x04'
-i += 1 # marker
-assert s[i] == '\x04'
-i += 1 # length
-i += len('pypy')
+assert s[i] == '\x05'# MARKER_HEADER
+assert s[i + 1] == '\x00'# 0
+assert s[i + 2] == '\x01'# VERSION_THREAD_ID
+assert s[i + 3] == chr(4)# len('pypy')
+assert s[i + 4: i + 8] == 'pypy'
+i += 8
 while i  len(s):
 if s[i] == '\x03':
 break
diff --git a/pypy/module/_vmprof/test/test_direct.py 
b/pypy/module/_vmprof/test/test_direct.py
--- a/pypy/module/_vmprof/test/test_direct.py
+++ b/pypy/module/_vmprof/test/test_direct.py
@@ -42,7 +42,7 @@
 }
 
 
- + open(str(srcdir.join(rvmprof_get_custom_offset.h))).read())
+ + open(str(srcdir.join(vmprof_get_custom_offset.h))).read())
 
 class TestDirect(object):
 def test_infrastructure(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests, error messages to be strictly numpy 1.9.0

2015-05-30 Thread mattip
Author: mattip matti.pi...@gmail.com
Branch: 
Changeset: r77717:acba2565aeee
Date: 2015-05-29 16:21 +0300
http://bitbucket.org/pypy/pypy/changeset/acba2565aeee/

Log:fix tests, error messages to be strictly numpy 1.9.0

diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -579,7 +579,9 @@
 try:
 ofs, dtype = self.dtype.fields[item]
 except KeyError:
-raise oefmt(space.w_ValueError, field named %s not found, item)
+raise oefmt(space.w_IndexError, 222only integers, slices (`:`), 
+ellipsis (`...`), numpy.newaxis (`None`) and integer or 
+boolean arrays are valid indices)
 dtype.itemtype.store(self.arr, self.ofs, ofs,
  dtype.coerce(space, w_value))
 
diff --git a/pypy/module/micronumpy/concrete.py 
b/pypy/module/micronumpy/concrete.py
--- a/pypy/module/micronumpy/concrete.py
+++ b/pypy/module/micronumpy/concrete.py
@@ -207,7 +207,7 @@
 raise ArrayArgumentException
 return self._lookup_by_index(space, view_w)
 if shape_len == 0:
-raise oefmt(space.w_IndexError, 0-d arrays can't be indexed)
+raise oefmt(space.w_IndexError, too many indices for array)
 elif shape_len  1:
 raise IndexError
 idx = support.index_w(space, w_idx)
@@ -218,7 +218,11 @@
 if space.isinstance_w(w_idx, space.w_str):
 idx = space.str_w(w_idx)
 dtype = self.dtype
-if not dtype.is_record() or idx not in dtype.fields:
+if not dtype.is_record():
+raise oefmt(space.w_IndexError, only integers, slices (`:`), 
+ellipsis (`...`), numpy.newaxis (`None`) and integer or 
+boolean arrays are valid indices)
+elif idx not in dtype.fields:
 raise oefmt(space.w_ValueError, field named %s not found, 
idx)
 return RecordChunk(idx)
 elif (space.isinstance_w(w_idx, space.w_int) or
diff --git a/pypy/module/micronumpy/ndarray.py 
b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -100,10 +100,10 @@
 
 def getitem_filter(self, space, arr):
 if arr.ndims()  1 and arr.get_shape() != self.get_shape():
-raise OperationError(space.w_ValueError, space.wrap(
+raise OperationError(space.w_IndexError, space.wrap(
 boolean index array should have 1 dimension))
 if arr.get_size()  self.get_size():
-raise OperationError(space.w_ValueError, space.wrap(
+raise OperationError(space.w_IndexError, space.wrap(
 index out of range for array))
 size = loop.count_all_true(arr)
 if arr.ndims() == 1:
@@ -116,10 +116,10 @@
 
 def setitem_filter(self, space, idx, val):
 if idx.ndims()  1 and idx.get_shape() != self.get_shape():
-raise OperationError(space.w_ValueError, space.wrap(
+raise OperationError(space.w_IndexError, space.wrap(
 boolean index array should have 1 dimension))
 if idx.get_size()  self.get_size():
-raise OperationError(space.w_ValueError, space.wrap(
+raise OperationError(space.w_IndexError, space.wrap(
 index out of range for array))
 size = loop.count_all_true(idx)
 if size  val.get_size() and val.get_size() != 1:
@@ -205,9 +205,13 @@
 def descr_getitem(self, space, w_idx):
 if space.is_w(w_idx, space.w_Ellipsis):
 return self
-elif isinstance(w_idx, W_NDimArray) and w_idx.get_dtype().is_bool() \
-and w_idx.ndims()  0:
-w_ret = self.getitem_filter(space, w_idx)
+elif isinstance(w_idx, W_NDimArray) and w_idx.get_dtype().is_bool():
+if w_idx.ndims()  0:
+w_ret = self.getitem_filter(space, w_idx)
+else:
+raise oefmt(space.w_IndexError,
+in the future, 0-d boolean arrays will be 
+interpreted as a valid boolean index)
 else:
 try:
 w_ret = self.implementation.descr_getitem(space, self, w_idx)
diff --git a/pypy/module/micronumpy/support.py 
b/pypy/module/micronumpy/support.py
--- a/pypy/module/micronumpy/support.py
+++ b/pypy/module/micronumpy/support.py
@@ -19,7 +19,9 @@
 try:
 return space.int_w(space.int(w_obj))
 except OperationError:
-raise oefmt(space.w_IndexError, cannot convert index to integer)
+raise oefmt(space.w_IndexError, only integers, slices (`:`), 
+ellipsis (`...`), numpy.newaxis (`None`) and integer or 
+boolean arrays are valid indices)
 
 
 @jit.unroll_safe
diff --git 

[pypy-commit] pypy default: Fix tests: the EF numbers have shifted

2015-04-08 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r76745:2133c4325644
Date: 2015-04-08 09:43 +0200
http://bitbucket.org/pypy/pypy/changeset/2133c4325644/

Log:Fix tests: the EF numbers have shifted

diff --git a/pypy/module/pypyjit/test_pypy_c/test_buffers.py 
b/pypy/module/pypyjit/test_pypy_c/test_buffers.py
--- a/pypy/module/pypyjit/test_pypy_c/test_buffers.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_buffers.py
@@ -42,7 +42,7 @@
 assert loop.match_by_id('unpack', 
 guard_not_invalidated(descr=...)
 p90 = newstr(4)
-call(ConstClass(copy_raw_to_string), i55, p90, 0, 4, descr=Callv 
0 irii EF=4)
+call(ConstClass(copy_raw_to_string), i55, p90, 0, 4, descr=Callv 
0 irii EF=5)
 guard_no_exception(descr=...)
 i91 = strgetitem(p90, 0)
 i92 = strgetitem(p90, 1)
diff --git a/pypy/module/pypyjit/test_pypy_c/test_call.py 
b/pypy/module/pypyjit/test_pypy_c/test_call.py
--- a/pypy/module/pypyjit/test_pypy_c/test_call.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_call.py
@@ -355,7 +355,7 @@
 i17 = arraylen_gc(p15, descr=ArrayS .)
 i18 = int_lt(i17, i15)
 # a cond call to _ll_list_resize_hint_really_look_inside_iff
-cond_call(i18, _, p8, i15, 1, descr=Callv 0 rii EF=4)
+cond_call(i18, _, p8, i15, 1, descr=Callv 0 rii EF=5)
 guard_no_exception(descr=...)
 p17 = getfield_gc(p8, descr=FieldP list.items .*)
 setarrayitem_gc(p17, i13, i12, descr=ArrayS .)
@@ -395,7 +395,7 @@
 setarrayitem_gc(p24, 0, p26, descr=ArrayP .)
 setfield_gc(p22, p24, descr=FieldP .*Arguments.inst_arguments_w 
.*)
 }}}
-p32 = call_may_force(_, p18, p22, descr=Callr . rr EF=6)
+p32 = call_may_force(_, p18, p22, descr=Callr . rr EF=7)
 ...
 )
 
diff --git a/pypy/module/pypyjit/test_pypy_c/test_containers.py 
b/pypy/module/pypyjit/test_pypy_c/test_containers.py
--- a/pypy/module/pypyjit/test_pypy_c/test_containers.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_containers.py
@@ -74,7 +74,7 @@
 setfield_gc(p13, p15, descr=FieldP dicttable.indexes .+)
 setfield_gc(p13, ConstPtr(0), descr=FieldP dicttable.entries .+)
 }}}
-i17 = call(ConstClass(ll_dict_lookup_trampoline), p13, p10, i12, 
1, descr=Calli . rrii EF=4 OS=4)
+i17 = call(ConstClass(ll_dict_lookup_trampoline), p13, p10, i12, 
1, descr=Calli . rrii EF=5 OS=4)
 {{{
 setfield_gc(p13, 0, descr=FieldS dicttable.lookup_function_no .+)
 setfield_gc(p13, 0, descr=FieldS dicttable.num_live_items .+)
@@ -82,10 +82,10 @@
 }}}
 guard_no_exception(descr=...)
 p20 = new_with_vtable(ConstClass(W_IntObject))
-call(ConstClass(_ll_dict_setitem_lookup_done_trampoline), p13, 
p10, p20, i12, i17, descr=Callv 0 rrrii EF=4)
+call(ConstClass(_ll_dict_setitem_lookup_done_trampoline), p13, 
p10, p20, i12, i17, descr=Callv 0 rrrii EF=5)
 setfield_gc(p20, i5, descr=FieldS .*W_IntObject.inst_intval .*)
 guard_no_exception(descr=...)
-i23 = call(ConstClass(ll_call_lookup_function), p13, p10, i12, 0, 
descr=Calli . rrii EF=4 OS=4)
+i23 = call(ConstClass(ll_call_lookup_function), p13, p10, i12, 0, 
descr=Calli . rrii EF=5 OS=4)
 guard_no_exception(descr=...)
 i27 = int_lt(i23, 0)
 guard_false(i27, descr=...)
diff --git a/pypy/module/pypyjit/test_pypy_c/test_ffi.py 
b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
--- a/pypy/module/pypyjit/test_pypy_c/test_ffi.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
@@ -35,7 +35,7 @@
 guard_not_invalidated(descr=...)
 i17 = force_token()
 setfield_gc(p0, i17, descr=.* .*PyFrame.vable_token .*)
-f21 = call_release_gil(%s, 2.00, 3.00, descr=Callf 8 ff 
EF=6)
+f21 = call_release_gil(%s, 2.00, 3.00, descr=Callf 8 ff 
EF=7)
 guard_not_forced(descr=...)
 guard_no_exception(descr=...)
  % pow_addr)
@@ -202,7 +202,7 @@
 assert loop.match_by_id('cfficall', 
 p96 = force_token()
 setfield_gc(p0, p96, descr=FieldP 
pypy.interpreter.pyframe.PyFrame.vable_token .)
-f97 = call_release_gil(91, i59, 1.0, 3, descr=Callf 8 fi EF=6 
OS=62)
+f97 = call_release_gil(91, i59, 1.0, 3, descr=Callf 8 fi EF=7 
OS=62)
 guard_not_forced(descr=...)
 guard_no_exception(descr=...)
 , ignore_ops=['guard_not_invalidated'])
@@ -266,7 +266,7 @@
 loop, = log.loops_by_id('cfficall')
 assert loop.match_by_id('cfficall', 
 ...
-f1 = call_release_gil(..., descr=Calli 4 ii EF=6 OS=62)
+f1 = call_release_gil(..., descr=Calli 4 ii EF=7 OS=62)
 ...
 )
 
@@ 

[pypy-commit] pypy default: fix tests

2014-12-30 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r75158:f5be5d01dac9
Date: 2014-12-30 12:55 +0200
http://bitbucket.org/pypy/pypy/changeset/f5be5d01dac9/

Log:fix tests

diff --git a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py 
b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
@@ -285,8 +285,7 @@
 # knownclass unknown
 expected = 
 [p0]
-guard_nonnull(p0) []
-guard_class(p0, ConstClass(node_vtable)) []
+guard_nonnull_class(p0, ConstClass(node_vtable)) []
 
 self.guards(knownclass_info, unknown_info, unknown_val, expected)
 self.check_invalid(knownclass_info, unknown_info, unknownnull_val)
@@ -390,8 +389,7 @@
 info2 = NotVirtualStateInfo(PtrOptValue(self.nodebox))
 expected = 
 [p0]
-guard_nonnull(p0) []
-guard_class(p0, ConstClass(node_vtable)) []
+guard_nonnull_class(p0, ConstClass(node_vtable)) []
 
 self.guards(info1, info2, self.nodebox, expected)
 self.check_invalid(info1, info2, BoxPtr())
@@ -444,8 +442,7 @@
 
 expected = 
 [p0]
-guard_nonnull(p0) []
-guard_class(p0, ConstClass(node_vtable)) []
+guard_nonnull_class(p0, ConstClass(node_vtable)) []
 
 state = vstate1.generate_guards(vstate2, [value, value], self.cpu)
 self.compare(state.extra_guards, expected, [self.nodebox])
@@ -480,8 +477,7 @@
 
 expected = 
 [p0]
-guard_nonnull(p0) []
-guard_class(p0, ConstClass(node_vtable)) []
+guard_nonnull_class(p0, ConstClass(node_vtable)) []
 
 self.guards(info1, info2, value1, expected, [self.nodebox])
 
@@ -505,8 +501,7 @@
 
 expected = 
 [p0]
-guard_nonnull(p0) []
-guard_class(p0, ConstClass(node_vtable)) []
+guard_nonnull_class(p0, ConstClass(node_vtable)) []
 
 self.guards(info1, info2, value1, expected, [self.nodebox])
 
@@ -532,8 +527,7 @@
 
 expected = 
 [p0]
-guard_nonnull(p0) []
-guard_class(p0, ConstClass(node_vtable)) []
+guard_nonnull_class(p0, ConstClass(node_vtable)) []
 
 self.guards(info1, info2, value1, expected, [self.nodebox])
 
@@ -560,8 +554,7 @@
 
 expected = 
 [p0]
-guard_nonnull(p0) []
-guard_class(p0, ConstClass(node_vtable)) []
+guard_nonnull_class(p0, ConstClass(node_vtable)) []
 
 self.guards(info1, info2, value1, expected, [self.nodebox])
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests on 32bit

2014-10-09 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r73878:aab89610d3d8
Date: 2014-10-10 00:24 -0400
http://bitbucket.org/pypy/pypy/changeset/aab89610d3d8/

Log:fix tests on 32bit

diff --git a/pypy/module/micronumpy/test/test_arrayops.py 
b/pypy/module/micronumpy/test/test_arrayops.py
--- a/pypy/module/micronumpy/test/test_arrayops.py
+++ b/pypy/module/micronumpy/test/test_arrayops.py
@@ -207,7 +207,7 @@
 exc = raises(TypeError, np.result_type, a=2)
 assert str(exc.value) == result_type() takes no keyword arguments
 assert np.result_type(True) is np.dtype('bool')
-assert np.result_type(1) is np.dtype('int64')
+assert np.result_type(1) is np.dtype('int')
 assert np.result_type(1.) is np.dtype('float64')
 assert np.result_type(1+2j) is np.dtype('complex128')
 assert np.result_type(1, 1.) is np.dtype('float64')
diff --git a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py 
b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
--- a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
@@ -101,8 +101,8 @@
 f149 = raw_load(i100, i129, descr=ArrayF 8)
 p150 = getfield_gc_pure(p123, descr=FieldP 
pypy.module.micronumpy.iterators.IterState.inst_indices .+)
 i151 = int_add(i117, 1)
-setarrayitem_gc(p150, 1, 0, descr=ArrayS 8)
-setarrayitem_gc(p150, 0, 0, descr=ArrayS 8)
+setarrayitem_gc(p150, 1, 0, descr=ArrayS .+)
+setarrayitem_gc(p150, 0, 0, descr=ArrayS .+)
 guard_not_invalidated(descr=...)
 i154 = getfield_raw(ticker_address, descr=FieldS 
pypysig_long_struct.c_value 0)
 i155 = int_lt(i154, 0)
@@ -143,8 +143,8 @@
 p152 = getfield_gc_pure(p126, descr=FieldP 
pypy.module.micronumpy.iterators.IterState.inst_indices .+)
 i153 = int_add(i120, 1)
 i154 = getfield_raw(ticker_address, descr=FieldS 
pypysig_long_struct.c_value 0)
-setarrayitem_gc(p152, 1, 0, descr=ArrayS 8)
-setarrayitem_gc(p152, 0, 0, descr=ArrayS 8)
+setarrayitem_gc(p152, 1, 0, descr=ArrayS .+)
+setarrayitem_gc(p152, 0, 0, descr=ArrayS .+)
 i157 = int_lt(i154, 0)
 guard_false(i157, descr=...)
 p158 = new_with_vtable(...)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests for changeset 5ed628789a2c

2013-11-23 Thread mattip
Author: Matti Picus matti.pi...@gmail.com
Branch: 
Changeset: r68292:287eb01c11f4
Date: 2013-11-23 20:05 +0200
http://bitbucket.org/pypy/pypy/changeset/287eb01c11f4/

Log:fix tests for changeset 5ed628789a2c

diff --git a/rpython/jit/backend/x86/test/test_ztranslation_basic.py 
b/rpython/jit/backend/x86/test/test_ztranslation_basic.py
--- a/rpython/jit/backend/x86/test/test_ztranslation_basic.py
+++ b/rpython/jit/backend/x86/test/test_ztranslation_basic.py
@@ -1,11 +1,11 @@
 from rpython.jit.backend.llsupport.test.ztranslation_test import 
TranslationTest
 from rpython.jit.backend.x86.arch import WORD
+import sys
 
 
 class TestTranslationX86(TranslationTest):
 def _check_cbuilder(self, cbuilder):
-# We assume here that we have sse2.  If not, the CPUClass
-# needs to be changed to CPU386_NO_SSE2, but well.
-if WORD == 4:
+# msse2 and sse are always on on x86-64
+if WORD == 4 and sys.platform != 'win32':
 assert '-msse2' in cbuilder.eci.compile_extra
 assert '-mfpmath=sse' in cbuilder.eci.compile_extra
diff --git a/rpython/jit/backend/x86/test/test_ztranslation_call_assembler.py 
b/rpython/jit/backend/x86/test/test_ztranslation_call_assembler.py
--- a/rpython/jit/backend/x86/test/test_ztranslation_call_assembler.py
+++ b/rpython/jit/backend/x86/test/test_ztranslation_call_assembler.py
@@ -1,11 +1,13 @@
 from rpython.jit.backend.llsupport.test.ztranslation_test import 
TranslationTestCallAssembler
 from rpython.translator.translator import TranslationContext
 from rpython.config.translationoption import DEFL_GC
-
+from rpython.jit.backend.x86.arch import WORD
+import sys
 
 class TestTranslationCallAssemblerX86(TranslationTestCallAssembler):
 def _check_cbuilder(self, cbuilder):
-# We assume here that we have sse2.  If not, the CPUClass
+#We assume here that we have sse2.  If not, the CPUClass
 # needs to be changed to CPU386_NO_SSE2, but well.
-assert '-msse2' in cbuilder.eci.compile_extra
-assert '-mfpmath=sse' in cbuilder.eci.compile_extra
\ No newline at end of file
+if WORD == 4 and sys.platform != 'win32':
+assert '-msse2' in cbuilder.eci.compile_extra
+assert '-mfpmath=sse' in cbuilder.eci.compile_extra
diff --git a/rpython/jit/backend/x86/test/test_ztranslation_jit_stats.py 
b/rpython/jit/backend/x86/test/test_ztranslation_jit_stats.py
--- a/rpython/jit/backend/x86/test/test_ztranslation_jit_stats.py
+++ b/rpython/jit/backend/x86/test/test_ztranslation_jit_stats.py
@@ -1,11 +1,14 @@
 from rpython.jit.backend.llsupport.test.ztranslation_test import 
TranslationTestJITStats
 from rpython.translator.translator import TranslationContext
 from rpython.config.translationoption import DEFL_GC
+from rpython.jit.backend.x86.arch import WORD
+import sys
 
 
 class TestTranslationJITStatsX86(TranslationTestJITStats):
 def _check_cbuilder(self, cbuilder):
-# We assume here that we have sse2.  If not, the CPUClass
+#We assume here that we have sse2.  If not, the CPUClass
 # needs to be changed to CPU386_NO_SSE2, but well.
-assert '-msse2' in cbuilder.eci.compile_extra
-assert '-mfpmath=sse' in cbuilder.eci.compile_extra
\ No newline at end of file
+if WORD == 4 and sys.platform != 'win32':
+assert '-msse2' in cbuilder.eci.compile_extra
+assert '-mfpmath=sse' in cbuilder.eci.compile_extra
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix tests

2013-10-11 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r67304:731bb6f2c1d4
Date: 2013-10-11 09:01 +0200
http://bitbucket.org/pypy/pypy/changeset/731bb6f2c1d4/

Log:Fix tests

diff --git a/rpython/rtyper/test/test_rstr.py b/rpython/rtyper/test/test_rstr.py
--- a/rpython/rtyper/test/test_rstr.py
+++ b/rpython/rtyper/test/test_rstr.py
@@ -3,6 +3,7 @@
 import py
 
 from rpython.flowspace.model import summary
+from rpython.annotator.model import AnnotatorError
 from rpython.rtyper.lltypesystem.lltype import typeOf, Signed, malloc
 from rpython.rtyper.lltypesystem.rstr import LLHelpers, STR
 from rpython.rtyper.rstr import AbstractLLHelpers
@@ -361,16 +362,16 @@
 res = self.interpret(fn, [i, j])
 assert res == fn(i, j)
 
-def test_find_TyperError(self):
+def test_find_AnnotatorError(self):
 const = self.const
 def f():
 s = const('abc')
 s.find(s, 0, -10)
-py.test.raises(TyperError, self.interpret, f, ())
+py.test.raises(AnnotatorError, self.interpret, f, ())
 def f():
 s = const('abc')
 s.find(s, -10)
-py.test.raises(TyperError, self.interpret, f, ())
+py.test.raises(AnnotatorError, self.interpret, f, ())
 
 def test_find_empty_string(self):
 const = self.const
@@ -420,9 +421,8 @@
 const = self.const
 def f(i):
 return const(abc).rfind(const(''), i)
-e = py.test.raises(TyperError, self.interpret, f, [-5])
-assert str(e.value).startswith(
-'str.rfind() start must be proven non-negative')
+e = py.test.raises(AnnotatorError, self.interpret, f, [-5])
+assert rfind: not proven to have non-negative start in str(e.value)
 
 def test_find_char(self):
 const = self.const
@@ -900,16 +900,16 @@
 res = self.interpret(fn, [])
 assert res == 1
 
-def test_count_TyperError(self):
+def test_count_AnnotatorError(self):
 const = self.const
 def f():
 s = const('abc')
 s.count(s, 0, -10)
-py.test.raises(TyperError, self.interpret, f, ())
+py.test.raises(AnnotatorError, self.interpret, f, ())
 def f():
 s = const('abc')
 s.count(s, -10)
-py.test.raises(TyperError, self.interpret, f, ())
+py.test.raises(AnnotatorError, self.interpret, f, ())
 
 def test_getitem_exc(self):
 const = self.const
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests for 32 bit

2013-05-26 Thread mattip
Author: mattip matti.pi...@gmail.com
Branch: 
Changeset: r64573:af17470a3036
Date: 2013-05-26 23:52 +0300
http://bitbucket.org/pypy/pypy/changeset/af17470a3036/

Log:fix tests for 32 bit

diff --git a/pypy/module/micronumpy/test/test_dtypes.py 
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -786,7 +786,7 @@
 
 def test_create_subarrays(self):
 from numpypy import dtype
-d = dtype([(x, float, (2,)), (y, int, (2,))])
+d = dtype([(x, float, (2,)), (y, int64, (2,))])
 assert d.itemsize == 32
 assert d.name == void256
 keys = d.fields.keys()
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -2715,7 +2715,7 @@
 a[0][x][0] = 200
 assert a[0][x][0] == 200
 
-d = dtype([(x, int, (2, 3))])
+d = dtype([(x, int64, (2, 3))])
 a = array([([[1, 2, 3], [4, 5, 6]],)], dtype=d)
 
 assert a[0][x].dtype == dtype(int64)
@@ -2735,7 +2735,7 @@
 def test_multidim_subarray(self):
 from numpypy import dtype, array
 
-d = dtype([(x, int, (2, 3))])
+d = dtype([(x, int64, (2, 3))])
 a = array([([[1, 2, 3], [4, 5, 6]],)], dtype=d)
 
 assert a[0][x].dtype == dtype(int64)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix tests when run with -A: CPython folds constants differently.

2013-04-26 Thread amauryfa
Author: Amaury Forgeot d'Arc amaur...@gmail.com
Branch: 
Changeset: r63665:d47342f86927
Date: 2013-04-26 22:07 +0200
http://bitbucket.org/pypy/pypy/changeset/d47342f86927/

Log:Fix tests when run with -A: CPython folds constants differently. In
particular, unused values are not removed from co_consts.

diff --git a/pypy/interpreter/test/test_compiler.py 
b/pypy/interpreter/test/test_compiler.py
--- a/pypy/interpreter/test/test_compiler.py
+++ b/pypy/interpreter/test/test_compiler.py
@@ -765,6 +765,9 @@
 
 class AppTestOptimizer:
 
+def setup_class(cls):
+cls.w_runappdirect = cls.space.wrap(cls.runappdirect)
+
 def test_remove_ending(self):
 source = def f():
 return 3
@@ -785,7 +788,8 @@
 def test_none_constant(self):
 import opcode
 co = compile(def f(): return None, test, exec).co_consts[0]
-assert None not in co.co_names
+if not self.runappdirect:  # This is a pypy optimization
+assert None not in co.co_names
 co = co.co_code
 op = ord(co[0]) + (ord(co[1])  8)
 assert op == opcode.opmap[LOAD_CONST]
@@ -800,29 +804,48 @@
 def code(source):
 return compile(source, test, exec)
 co = code(x = 10//4)
-assert len(co.co_consts) == 2
-assert co.co_consts[0] == 2
+if self.runappdirect:
+assert 2 in co.co_consts
+else:
+# PyPy is more precise
+assert len(co.co_consts) == 2
+assert co.co_consts[0] == 2
 co = code(x = 10/4)
 assert len(co.co_consts) == 3
 assert co.co_consts[:2] == (10, 4)
 co = code(from __future__ import division\nx = 10/4)
-assert co.co_consts[2] == 2.5
+if self.runappdirect:
+assert 2.5 in co.co_consts
+else:
+assert co.co_consts[2] == 2.5
 
 def test_tuple_folding(self):
 co = compile(x = (1, 2, 3), test, exec)
-assert co.co_consts == ((1, 2, 3), None)
+if not self.runappdirect:
+# PyPy is more precise
+assert co.co_consts == ((1, 2, 3), None)
+else:
+assert (1, 2, 3) in co.co_consts
+assert None in co.co_consts
 co = compile(x = (), test, exec)
-assert co.co_consts == ((), None)
+assert set(co.co_consts) == set(((), None))
 
 def test_unary_folding(self):
+def check_const(co, value):
+assert value in co.co_consts
+if not self.runappdirect:
+# This is a pypy optimization
+assert co.co_consts[0] == value
 co = compile(x = -(3), test, exec)
-assert co.co_consts[0] == -3
+check_const(co, -3)
 co = compile(x = ~3, test, exec)
-assert co.co_consts[0] == ~3
+check_const(co, ~3)
 co = compile(x = +(-3), test, exec)
-assert co.co_consts[0] == -3
+check_const(co, -3)
 co = compile(x = not None, test, exec)
-assert co.co_consts[0] is True
+if not self.runappdirect:
+# CPython does not have this optimization
+assert co.co_consts == (True, None)
 
 def test_folding_of_binops_on_constants(self):
 def disassemble(func):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests

2013-03-24 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: 
Changeset: r62722:9c3bfca89540
Date: 2013-03-24 12:03 +0200
http://bitbucket.org/pypy/pypy/changeset/9c3bfca89540/

Log:fix tests

diff --git a/rpython/jit/backend/arm/test/test_regalloc2.py 
b/rpython/jit/backend/arm/test/test_regalloc2.py
--- a/rpython/jit/backend/arm/test/test_regalloc2.py
+++ b/rpython/jit/backend/arm/test/test_regalloc2.py
@@ -1,6 +1,6 @@
 import py
 from rpython.jit.metainterp.history import ResOperation, BoxInt, ConstInt,\
- BoxPtr, ConstPtr, BasicFailDescr
+ BoxPtr, ConstPtr, BasicFailDescr, BasicFinalDescr
 from rpython.jit.metainterp.history import JitCellToken
 from rpython.jit.metainterp.resoperation import rop
 from rpython.jit.backend.detect_cpu import getcpuclass
@@ -17,15 +17,17 @@
 ResOperation(rop.INT_ADD, [v1, v1], v2),
 ResOperation(rop.INT_INVERT, [v2], v3),
 ResOperation(rop.UINT_RSHIFT, [v1, ConstInt(3)], v4),
-ResOperation(rop.FINISH, [v4, v3], None, descr=BasicFailDescr()),
+ResOperation(rop.GUARD_FALSE, [v1], None, descr=BasicFailDescr()),
+ResOperation(rop.FINISH, [], None, descr=BasicFinalDescr(1)),
 ]
+operations[-2].setfailargs([v4, v3])
 cpu = CPU(None, None)
 cpu.setup_once()
 looptoken = JitCellToken()
 cpu.compile_loop(inputargs, operations, looptoken)
-cpu.execute_token(looptoken, 9)
-assert cpu.get_latest_value_int(0) == (9  3)
-assert cpu.get_latest_value_int(1) == (~18)
+deadframe = cpu.execute_token(looptoken, 9)
+assert cpu.get_int_value(deadframe, 0) == (9  3)
+assert cpu.get_int_value(deadframe, 1) == (~18)
 
 def test_bug_int_is_true_1():
 v1 = BoxInt()
@@ -39,16 +41,18 @@
 ResOperation(rop.INT_MUL, [v2, v1], v3),
 ResOperation(rop.INT_IS_TRUE, [v2], tmp5),
 ResOperation(rop.INT_IS_ZERO, [tmp5], v4),
-ResOperation(rop.FINISH, [v4, v3, tmp5], None, descr=BasicFailDescr()),
+ResOperation(rop.GUARD_FALSE, [v1], None, descr=BasicFailDescr()),
+ResOperation(rop.FINISH, [], None, descr=BasicFinalDescr()),
 ]
+operations[-2].setfailargs([v4, v3, tmp5])
 cpu = CPU(None, None)
 cpu.setup_once()
 looptoken = JitCellToken()
 cpu.compile_loop(inputargs, operations, looptoken)
-cpu.execute_token(looptoken, -10)
-assert cpu.get_latest_value_int(0) == 0
-assert cpu.get_latest_value_int(1) == -1000
-assert cpu.get_latest_value_int(2) == 1
+deadframe = cpu.execute_token(looptoken, -10)
+assert cpu.get_int_value(deadframe, 0) == 0
+assert cpu.get_int_value(deadframe, 1) == -1000
+assert cpu.get_int_value(deadframe, 2) == 1
 
 def test_bug_0():
 v1 = BoxInt()
@@ -135,28 +139,29 @@
 ResOperation(rop.UINT_GT, [v33, ConstInt(-11)], v38),
 ResOperation(rop.INT_NEG, [v7], v39),
 ResOperation(rop.INT_GT, [v24, v32], v40),
-ResOperation(rop.FINISH, [v40, v36, v37, v31, v16, v34, v35, v23, v22, 
v29, v14, v39, v30, v38], None, descr=BasicFailDescr()),
+ResOperation(rop.GUARD_FALSE, [v1], None, descr=BasicFailDescr()),
 ]
+operations[-1].setfailargs([v40, v36, v37, v31, v16, v34, v35, v23, v22, 
v29, v14, v39, v30, v38])
 cpu = CPU(None, None)
 cpu.setup_once()
 looptoken = JitCellToken()
 cpu.compile_loop(inputargs, operations, looptoken)
 args = [-13 , 10 , 10 , 8 , -8 , -16 , -18 , 46 , -12 , 26]
-cpu.execute_token(looptoken, *args)
-assert cpu.get_latest_value_int(0) == 0
-assert cpu.get_latest_value_int(1) == 0
-assert cpu.get_latest_value_int(2) == 0
-assert cpu.get_latest_value_int(3) == 0
-assert cpu.get_latest_value_int(4) == 1
-assert cpu.get_latest_value_int(5) == -7
-assert cpu.get_latest_value_int(6) == 1
-assert cpu.get_latest_value_int(7) == 0
-assert cpu.get_latest_value_int(8) == -2
-assert cpu.get_latest_value_int(9) == 18
-assert cpu.get_latest_value_int(10) == 1
-assert cpu.get_latest_value_int(11) == 18
-assert cpu.get_latest_value_int(12) == -1
-assert cpu.get_latest_value_int(13) == 0
+deadframe = cpu.execute_token(looptoken, *args)
+assert cpu.get_int_value(deadframe, 0) == 0
+assert cpu.get_int_value(deadframe, 1) == 0
+assert cpu.get_int_value(deadframe, 2) == 0
+assert cpu.get_int_value(deadframe, 3) == 0
+assert cpu.get_int_value(deadframe, 4) == 1
+assert cpu.get_int_value(deadframe, 5) == -7
+assert cpu.get_int_value(deadframe, 6) == 1
+assert cpu.get_int_value(deadframe, 7) == 0
+assert cpu.get_int_value(deadframe, 8) == -2
+assert cpu.get_int_value(deadframe, 9) == 18
+assert cpu.get_int_value(deadframe, 10) == 1
+assert cpu.get_int_value(deadframe, 11) == 18
+assert cpu.get_int_value(deadframe, 12) == -1
+assert cpu.get_int_value(deadframe, 13) == 0
 
 def test_bug_1():
 v1 = BoxInt()
@@ -241,35 +246,36 @@
 ResOperation(rop.INT_GT, [v4, v11], v38),

[pypy-commit] pypy default: fix tests for -A

2012-12-12 Thread mattip
Author: mattip matti.pi...@gmail.com
Branch: 
Changeset: r59410:5b0bb368c5e1
Date: 2012-12-12 14:35 -0800
http://bitbucket.org/pypy/pypy/changeset/5b0bb368c5e1/

Log:fix tests for -A

diff --git a/pypy/module/micronumpy/test/test_complex.py 
b/pypy/module/micronumpy/test/test_complex.py
--- a/pypy/module/micronumpy/test/test_complex.py
+++ b/pypy/module/micronumpy/test/test_complex.py
@@ -94,30 +94,42 @@
 cls.w_testcases128 = cls.space.wrap(list(parse_testfile(fname128)))
 cls.w_testcases64 = cls.space.wrap(list(parse_testfile(fname64)))
 
-def cls_c_pow(space, args_w):
-try:
-retVal = c_pow(*map(space.unwrap, args_w))
-return space.wrap(retVal)
-except ValueError, e:
-if option.runappdirect:
-raise
-raise OperationError(cls.space.w_ValueError,
-cls.space.wrap(e.message))
-cls.w_c_pow = cls.space.wrap(interp2app(cls_c_pow))
 cls.w_runAppDirect = cls.space.wrap(option.runappdirect)
 cls.w_isWindows = cls.space.wrap(os.name == 'nt')
 
-def cls_rAlmostEqual(space, __args__):
-args, kwargs = __args__.unpack()
-args = map(space.unwrap, args)
-kwargs = dict([
-(k, space.unwrap(v))
-for k, v in kwargs.iteritems()
-])
-if '__pypy__' not in sys.builtin_module_names:
-kwargs['isnumpy'] = True
-return space.wrap(rAlmostEqual(*args, **kwargs))
-cls.w_rAlmostEqual = cls.space.wrap(interp2app(cls_rAlmostEqual))
+if cls.runappdirect:
+def cls_rAlmostEqual(space, *args, **kwargs):
+return rAlmostEqual(*args, **kwargs)
+cls.w_rAlmostEqual = cls.space.wrap(cls_rAlmostEqual)
+def cls_c_pow(space, *args):
+return c_pow(*args)
+cls.w_c_pow = cls.space.wrap(cls_c_pow)
+else:
+def cls_rAlmostEqual(space, __args__):
+args, kwargs = __args__.unpack()
+args = map(space.unwrap, args)
+kwargs = dict([
+(k, space.unwrap(v))
+for k, v in kwargs.iteritems()
+])
+if '__pypy__' not in sys.builtin_module_names:
+kwargs['isnumpy'] = True
+return space.wrap(rAlmostEqual(*args, **kwargs))
+cls.w_rAlmostEqual = cls.space.wrap(interp2app(cls_rAlmostEqual))
+def cls_c_pow(space, args_w):
+try:
+retVal = c_pow(*map(space.unwrap, args_w))
+return space.wrap(retVal)
+except ZeroDivisionError, e:
+raise OperationError(cls.space.w_ZeroDivisionError,
+cls.space.wrap(e.message))
+except OverflowError, e:
+raise OperationError(cls.space.w_OverflowError,
+cls.space.wrap(e.message))
+except ValueError, e:
+raise OperationError(cls.space.w_ValueError,
+cls.space.wrap(e.message))
+cls.w_c_pow = cls.space.wrap(interp2app(cls_c_pow))
 
 def test_fabs(self):
 from _numpypy import fabs, complex128
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix tests for missing 'itertools'.

2012-10-29 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r58561:5bdab3fa8259
Date: 2012-10-29 10:49 +0100
http://bitbucket.org/pypy/pypy/changeset/5bdab3fa8259/

Log:Fix tests for missing 'itertools'.

diff --git a/pypy/module/imp/test/test_app.py b/pypy/module/imp/test/test_app.py
--- a/pypy/module/imp/test/test_app.py
+++ b/pypy/module/imp/test/test_app.py
@@ -3,6 +3,8 @@
 
 class AppTestImpModule:
 def setup_class(cls):
+from pypy.conftest import gettestobjspace
+cls.space = gettestobjspace(usemodules=('imp', 'itertools'))
 cls.w_imp = cls.space.getbuiltinmodule('imp')
 cls.w_file_module = cls.space.wrap(__file__)
 
diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -38,7 +38,7 @@
 test_reload = def test():\nraise ValueError\n,
 infinite_reload = import infinite_reload; 
reload(infinite_reload),
 del_sys_module = import sys\ndel 
sys.modules['del_sys_module']\n,
-itertools = hello_world = 42\n,
+_md5 = hello_world = 42\n,
 gc = should_never_be_seen = 42\n,
 )
 root.ensure(notapackage, dir=1)# empty, no __init__.py
@@ -148,7 +148,7 @@
 class AppTestImport:
 
 def setup_class(cls): # interpreter-level
-cls.space = gettestobjspace(usemodules=['itertools'])
+cls.space = gettestobjspace(usemodules=['_md5'])
 cls.w_runappdirect = cls.space.wrap(conftest.option.runappdirect)
 cls.saved_modules = _setup(cls.space)
 #XXX Compile class
@@ -597,34 +597,34 @@
 
 def test_shadow_extension_1(self):
 if self.runappdirect: skip(hard to test: module is already imported)
-# 'import itertools' is supposed to find itertools.py if there is
+# 'import _md5' is supposed to find _md5.py if there is
 # one in sys.path.
 import sys
-assert 'itertools' not in sys.modules
-import itertools
-assert hasattr(itertools, 'hello_world')
-assert not hasattr(itertools, 'count')
-assert '(built-in)' not in repr(itertools)
-del sys.modules['itertools']
+assert '_md5' not in sys.modules
+import _md5
+assert hasattr(_md5, 'hello_world')
+assert not hasattr(_md5, 'count')
+assert '(built-in)' not in repr(_md5)
+del sys.modules['_md5']
 
 def test_shadow_extension_2(self):
 if self.runappdirect: skip(hard to test: module is already imported)
-# 'import itertools' is supposed to find the built-in module even
+# 'import _md5' is supposed to find the built-in module even
 # if there is also one in sys.path as long as it is *after* the
 # special entry '.../lib_pypy/__extensions__'.  (Note that for now
-# there is one in lib_pypy/itertools.py, which should not be seen
+# there is one in lib_pypy/_md5.py, which should not be seen
 # either; hence the (built-in) test below.)
 import sys
-assert 'itertools' not in sys.modules
+assert '_md5' not in sys.modules
 sys.path.append(sys.path.pop(0))
 try:
-import itertools
-assert not hasattr(itertools, 'hello_world')
-assert hasattr(itertools, 'izip')
-assert '(built-in)' in repr(itertools)
+import _md5
+assert not hasattr(_md5, 'hello_world')
+assert hasattr(_md5, 'digest_size')
+assert '(built-in)' in repr(_md5)
 finally:
 sys.path.insert(0, sys.path.pop())
-del sys.modules['itertools']
+del sys.modules['_md5']
 
 def test_invalid_pathname(self):
 import imp
@@ -1005,7 +1005,7 @@
 class AppTestImportHooks(object):
 
 def setup_class(cls):
-space = cls.space = gettestobjspace(usemodules=('struct',))
+space = cls.space = gettestobjspace(usemodules=('struct', 'itertools'))
 mydir = os.path.dirname(__file__)
 cls.w_hooktest = space.wrap(os.path.join(mydir, 'hooktest'))
 space.appexec([space.wrap(mydir)], 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix tests around utf8 encoding

2012-09-25 Thread amauryfa
Author: Amaury Forgeot d'Arc amaur...@gmail.com
Branch: 
Changeset: r57589:10e2fbb7bcec
Date: 2012-09-25 23:51 +0200
http://bitbucket.org/pypy/pypy/changeset/10e2fbb7bcec/

Log:Fix tests around utf8 encoding

diff --git a/pypy/objspace/std/ropeunicodeobject.py 
b/pypy/objspace/std/ropeunicodeobject.py
--- a/pypy/objspace/std/ropeunicodeobject.py
+++ b/pypy/objspace/std/ropeunicodeobject.py
@@ -71,7 +71,7 @@
 if result is not None:
 return W_RopeObject(result)
 elif encoding == utf-8:
-result = rope.unicode_encode_utf8(node)
+result = rope.unicode_encode_utf8(node, allow_surrogates=True)
 if result is not None:
 return W_RopeObject(result)
 return encode_object(space, w_unistr, encoding, errors)
diff --git a/pypy/rlib/rope.py b/pypy/rlib/rope.py
--- a/pypy/rlib/rope.py
+++ b/pypy/rlib/rope.py
@@ -1485,7 +1485,7 @@
 if rope.is_bytestring():
 return rope
 
-def unicode_encode_utf8(rope):
+def unicode_encode_utf8(rope, allow_surrogates=False):
 from pypy.rlib.runicode import unicode_encode_utf_8
 if rope.is_ascii():
 return rope
@@ -1494,7 +1494,8 @@
 unicode_encode_utf8(rope.right))
 elif isinstance(rope, LiteralUnicodeNode):
 return LiteralStringNode(
-unicode_encode_utf_8(rope.u, len(rope.u), strict))
+unicode_encode_utf_8(rope.u, len(rope.u), strict,
+ allow_surrogates=allow_surrogates))
 elif isinstance(rope, LiteralStringNode):
 return LiteralStringNode(_str_encode_utf_8(rope.s))
 
diff --git a/pypy/rpython/rstr.py b/pypy/rpython/rstr.py
--- a/pypy/rpython/rstr.py
+++ b/pypy/rpython/rstr.py
@@ -28,8 +28,10 @@
 from pypy.rpython.annlowlevel import hlstr
 value = hlstr(llvalue)
 assert value is not None
-univalue, _ = self.rstr_decode_utf_8(value, len(value), 'strict',
- False, 
self.ll_raise_unicode_exception_decode)
+univalue, _ = self.rstr_decode_utf_8(
+value, len(value), 'strict', final=False,
+errorhandler=self.ll_raise_unicode_exception_decode,
+allow_surrogates=False)
 return self.ll.llunicode(univalue)
 
 def ll_raise_unicode_exception_decode(self, errors, encoding, msg, s,
@@ -50,9 +52,9 @@
 self.runicode_encode_utf_8 = None
 
 def ensure_ll_encode_utf8(self):
-from pypy.rlib.runicode import unicode_encode_utf_8
-self.runicode_encode_utf_8 = func_with_new_name(unicode_encode_utf_8,
-
'runicode_encode_utf_8')
+from pypy.rlib.runicode import unicode_encode_utf_8_impl
+self.runicode_encode_utf_8 = func_with_new_name(
+unicode_encode_utf_8_impl, 'runicode_encode_utf_8')
 
 def rtype_method_upper(self, hop):
 raise TypeError(Cannot do toupper on unicode string)
@@ -65,9 +67,16 @@
 from pypy.rpython.annlowlevel import hlunicode
 s = hlunicode(ll_s)
 assert s is not None
-bytes = self.runicode_encode_utf_8(s, len(s), 'strict')
+bytes = self.runicode_encode_utf_8(
+s, len(s), 'strict',
+errorhandler=self.ll_raise_unicode_exception_decode,
+allow_surrogates=False)
 return self.ll.llstr(bytes)
 
+def ll_raise_unicode_exception_encode(self, errors, encoding, msg, u,
+  startingpos, endingpos):
+raise UnicodeEncodeError(encoding, u, startingpos, endingpos, msg)
+
 class __extend__(annmodel.SomeString):
 def rtyper_makerepr(self, rtyper):
 return rtyper.type_system.rstr.string_repr
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix tests.

2012-03-04 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r53175:0541ffa5b060
Date: 2012-03-04 11:57 +0100
http://bitbucket.org/pypy/pypy/changeset/0541ffa5b060/

Log:Fix tests.

diff --git a/pypy/jit/backend/x86/test/test_gc_integration.py 
b/pypy/jit/backend/x86/test/test_gc_integration.py
--- a/pypy/jit/backend/x86/test/test_gc_integration.py
+++ b/pypy/jit/backend/x86/test/test_gc_integration.py
@@ -28,7 +28,7 @@
 
 class MockGcRootMap(object):
 is_shadow_stack = False
-def get_basic_shape(self, is_64_bit):
+def get_basic_shape(self):
 return ['shape']
 def add_frame_offset(self, shape, offset):
 shape.append(offset)
diff --git a/pypy/jit/backend/x86/test/test_recompilation.py 
b/pypy/jit/backend/x86/test/test_recompilation.py
--- a/pypy/jit/backend/x86/test/test_recompilation.py
+++ b/pypy/jit/backend/x86/test/test_recompilation.py
@@ -34,7 +34,6 @@
 '''
 loop = self.interpret(ops, [0])
 previous = loop._jitcelltoken.compiled_loop_token.frame_depth
-assert loop._jitcelltoken.compiled_loop_token.param_depth == 0
 assert self.getint(0) == 20
 ops = '''
 [i1]
@@ -51,7 +50,6 @@
 bridge = self.attach_bridge(ops, loop, -2)
 descr = loop.operations[3].getdescr()
 new = descr._x86_bridge_frame_depth
-assert descr._x86_bridge_param_depth == 0
 # the force_spill() forces the stack to grow
 assert new  previous
 fail = self.run(loop, 0)
@@ -116,10 +114,8 @@
 loop_frame_depth = loop._jitcelltoken.compiled_loop_token.frame_depth
 bridge = self.attach_bridge(ops, loop, 6)
 guard_op = loop.operations[6]
-assert loop._jitcelltoken.compiled_loop_token.param_depth == 0
 # the force_spill() forces the stack to grow
 assert guard_op.getdescr()._x86_bridge_frame_depth  loop_frame_depth
-assert guard_op.getdescr()._x86_bridge_param_depth == 0
 self.run(loop, 0, 0, 0, 0, 0, 0)
 assert self.getint(0) == 1
 assert self.getint(1) == 20
diff --git a/pypy/jit/backend/x86/test/test_regalloc.py 
b/pypy/jit/backend/x86/test/test_regalloc.py
--- a/pypy/jit/backend/x86/test/test_regalloc.py
+++ b/pypy/jit/backend/x86/test/test_regalloc.py
@@ -606,23 +606,37 @@
 assert self.getints(9) == [0, 1, 1, 1, 1, 1, 1, 1, 1]
 
 class TestRegAllocCallAndStackDepth(BaseTestRegalloc):
-def expected_param_depth(self, num_args):
+def expected_frame_depth(self, num_call_args, num_pushed_input_args=0):
 # Assumes the arguments are all non-float
 if IS_X86_32:
-return num_args
+extra_esp = num_call_args
+return extra_esp
 elif IS_X86_64:
-return max(num_args - 6, 0)
+# 'num_pushed_input_args' is for X86_64 only
+extra_esp = max(num_call_args - 6, 0)
+return num_pushed_input_args + extra_esp
 
 def test_one_call(self):
 ops = '''
-[i0, i1, i2, i3, i4, i5, i6, i7, i8, i9]
+[i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i9b]
 i10 = call(ConstClass(f1ptr), i0, descr=f1_calldescr)
-finish(i10, i1, i2, i3, i4, i5, i6, i7, i8, i9)
+finish(i10, i1, i2, i3, i4, i5, i6, i7, i8, i9, i9b)
 '''
-loop = self.interpret(ops, [4, 7, 9, 9 ,9, 9, 9, 9, 9, 9])
-assert self.getints(10) == [5, 7, 9, 9, 9, 9, 9, 9, 9, 9]
+loop = self.interpret(ops, [4, 7, 9, 9 ,9, 9, 9, 9, 9, 9, 8])
+assert self.getints(11) == [5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 8]
 clt = loop._jitcelltoken.compiled_loop_token
-assert clt.param_depth == self.expected_param_depth(1)
+assert clt.frame_depth == self.expected_frame_depth(1, 5)
+
+def test_one_call_reverse(self):
+ops = '''
+[i1, i2, i3, i4, i5, i6, i7, i8, i9, i9b, i0]
+i10 = call(ConstClass(f1ptr), i0, descr=f1_calldescr)
+finish(i10, i1, i2, i3, i4, i5, i6, i7, i8, i9, i9b)
+'''
+loop = self.interpret(ops, [7, 9, 9 ,9, 9, 9, 9, 9, 9, 8, 4])
+assert self.getints(11) == [5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 8]
+clt = loop._jitcelltoken.compiled_loop_token
+assert clt.frame_depth == self.expected_frame_depth(1, 6)
 
 def test_two_calls(self):
 ops = '''
@@ -634,7 +648,7 @@
 loop = self.interpret(ops, [4, 7, 9, 9 ,9, 9, 9, 9, 9, 9])
 assert self.getints(10) == [5*7, 7, 9, 9, 9, 9, 9, 9, 9, 9]
 clt = loop._jitcelltoken.compiled_loop_token
-assert clt.param_depth == self.expected_param_depth(2)
+assert clt.frame_depth == self.expected_frame_depth(2, 5)
 
 def test_call_many_arguments(self):
 # NB: The first and last arguments in the call are constants. This
@@ -648,25 +662,31 @@
 loop = self.interpret(ops, [2, 3, 4, 5, 6, 7, 8, 9])
 assert self.getint(0) == 55
 clt = loop._jitcelltoken.compiled_loop_token
-assert clt.param_depth == 

[pypy-commit] pypy default: fix tests and translation. decrease the wait time

2011-10-26 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r48469:d40090f37f98
Date: 2011-10-26 09:37 +0200
http://bitbucket.org/pypy/pypy/changeset/d40090f37f98/

Log:fix tests and translation. decrease the wait time

diff --git a/pypy/module/rctime/interp_time.py 
b/pypy/module/rctime/interp_time.py
--- a/pypy/module/rctime/interp_time.py
+++ b/pypy/module/rctime/interp_time.py
@@ -246,8 +246,8 @@
 @unwrap_spec(secs=float)
 def sleep(space, secs):
 if secs  0:
-raise space.OperationError(space.w_IOError,
-   space.wrap(Invalid argument: negative 
time in sleep))
+raise OperationError(space.w_IOError,
+ space.wrap(Invalid argument: negative time 
in sleep))
 pytime.sleep(secs)
 else:
 from pypy.rlib import rwin32
@@ -269,8 +269,8 @@
 @unwrap_spec(secs=float)
 def sleep(space, secs):
 if secs  0:
-raise space.OperationError(space.w_IOError,
-   space.wrap(Invalid argument: negative 
time in sleep))
+raise OperationError(space.w_IOError,
+ space.wrap(Invalid argument: negative time 
in sleep))
 # as decreed by Guido, only the main thread can be
 # interrupted.
 main_thread = space.fromcache(State).main_thread
diff --git a/pypy/module/rctime/test/test_rctime.py 
b/pypy/module/rctime/test/test_rctime.py
--- a/pypy/module/rctime/test/test_rctime.py
+++ b/pypy/module/rctime/test/test_rctime.py
@@ -20,7 +20,7 @@
 import sys
 import os
 raises(TypeError, rctime.sleep, foo)
-rctime.sleep(1.2345)
+rctime.sleep(0.12345)
 raises(IOError, rctime.sleep, -1.0)
 
 def test_clock(self):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests

2011-09-28 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: 
Changeset: r47656:c54d4c8c465a
Date: 2011-09-28 10:19 -0400
http://bitbucket.org/pypy/pypy/changeset/c54d4c8c465a/

Log:fix tests

diff --git a/pypy/module/pypyjit/test_pypy_c/test_min_max.py 
b/pypy/module/pypyjit/test_pypy_c/test_min_max.py
--- a/pypy/module/pypyjit/test_pypy_c/test_min_max.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_min_max.py
@@ -42,7 +42,7 @@
 assert len(guards)  20
 assert loop.match_by_id('max',
 ...
-p76 = call_may_force(ConstClass(min_max_loop__max), _, _, 
descr=...)
+p76 = call_may_force(ConstClass(min_max_trampoline), _, _, 
descr=...)
 ...
 )
 
@@ -63,6 +63,6 @@
 assert len(guards)  20
 assert loop.match_by_id('max',
 ...
-p76 = call_may_force(ConstClass(min_max_loop__max), _, _, 
descr=...)
+p76 = call_may_force(ConstClass(min_max_trampoline), _, _, 
descr=...)
 ...
 )
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix tests on OS/X (hopefully).

2011-09-07 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r47130:5190d760b26c
Date: 2011-09-07 13:05 +0200
http://bitbucket.org/pypy/pypy/changeset/5190d760b26c/

Log:Fix tests on OS/X (hopefully).

diff --git a/pypy/module/pypyjit/test_pypy_c/test__ffi.py 
b/pypy/module/pypyjit/test_pypy_c/test__ffi.py
--- a/pypy/module/pypyjit/test_pypy_c/test__ffi.py
+++ b/pypy/module/pypyjit/test_pypy_c/test__ffi.py
@@ -29,11 +29,13 @@
 pow_addr, res = log.result
 assert res == 8.0 * 300
 loop, = log.loops_by_filename(self.filepath)
+if 'ConstClass(pow)' in repr(loop):   # e.g. OS/X
+pow_addr = 'ConstClass(pow)'
 assert loop.match_by_id('fficall', 
 guard_not_invalidated(descr=...)
 i17 = force_token()
 setfield_gc(p0, i17, descr=.* .*PyFrame.vable_token .*)
-f21 = call_release_gil(%d, 2.00, 3.00, 
descr=FloatCallDescr)
+f21 = call_release_gil(%s, 2.00, 3.00, 
descr=FloatCallDescr)
 guard_not_forced(descr=...)
 guard_no_exception(descr=...)
  % pow_addr)
@@ -129,4 +131,5 @@
 assert opnames.count('call_release_gil') == 1
 idx = opnames.index('call_release_gil')
 call = ops[idx]
-assert int(call.args[0]) == fabs_addr
+assert (call.args[0] == 'ConstClass(fabs)' or# e.g. OS/X
+int(call.args[0]) == fabs_addr)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix tests, and a clean up, by not reusing a Descr across various loops.

2011-08-03 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r46231:7f3f578cb546
Date: 2011-08-03 08:26 +0200
http://bitbucket.org/pypy/pypy/changeset/7f3f578cb546/

Log:Fix tests, and a clean up, by not reusing a Descr across various
loops.

diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -671,8 +671,6 @@
 assert exception, PropagateExceptionDescr: no exception??
 raise metainterp_sd.ExitFrameWithExceptionRef(cpu, exception)
 
-propagate_exception_descr = PropagateExceptionDescr()
-
 def compile_tmp_callback(cpu, jitdriver_sd, greenboxes, redboxes,
  memory_manager=None):
 Make a LoopToken that corresponds to assembler code that just
@@ -706,7 +704,7 @@
 finishargs = []
 #
 jd = jitdriver_sd
-faildescr = propagate_exception_descr
+faildescr = PropagateExceptionDescr()
 operations = [
 ResOperation(rop.CALL, callargs, result, descr=jd.portal_calldescr),
 ResOperation(rop.GUARD_NO_EXCEPTION, [], None, descr=faildescr),
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -1379,7 +1379,7 @@
 num = self.cpu.get_fail_descr_number(tokens[0].finishdescr)
 setattr(self.cpu, 'done_with_this_frame_%s_v' % name, num)
 #
-exc_descr = compile.propagate_exception_descr
+exc_descr = compile.PropagateExceptionDescr()
 num = self.cpu.get_fail_descr_number(exc_descr)
 self.cpu.propagate_exception_v = num
 #
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests and improve signature

2011-07-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r45799:2c43451adecb
Date: 2011-07-21 10:41 +0200
http://bitbucket.org/pypy/pypy/changeset/2c43451adecb/

Log:fix tests and improve signature

diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -444,12 +444,10 @@
 
 def _sliceloop1(self, start, stop, step, arr):
 storage = self.parent.storage
-signature = Signature()
-new_sig = self.signature.transition(signature)
 i = start
 j = 0
 while i  stop:
-slice_driver1.jit_merge_point(signature=signature, self=self,
+slice_driver1.jit_merge_point(signature=arr.signature, self=self,
 step=step, stop=stop, i=i, j=j, arr=arr)
 storage[i] = arr.eval(j)
 j += 1
@@ -457,12 +455,10 @@
 
 def _sliceloop2(self, start, stop, step, arr):
 storage = self.parent.storage
-signature = Signature()
-new_sig = self.signature.transition(signature)
 i = start
 j = 0
 while i  stop:
-slice_driver2.jit_merge_point(signature=signature, self=self,
+slice_driver2.jit_merge_point(signature=arr.signature, self=self,
 step=step, stop=stop, i=i, j=j, arr=arr)
 storage[i] = arr.eval(j)
 j += 1
@@ -516,7 +512,7 @@
 i = start
 j = 0
 while i  stop:
-slice_driver1.jit_merge_point(signature=self.signature, self=self,
+slice_driver1.jit_merge_point(signature=arr.signature, self=self,
 step=step, stop=stop, i=i, j=j, arr=arr)
 self.storage[i] = arr.eval(j)
 j += 1
@@ -526,7 +522,7 @@
 i = start
 j = 0
 while i  stop:
-slice_driver2.jit_merge_point(signature=self.signature, self=self,
+slice_driver2.jit_merge_point(signature=arr.signature, self=self,
 step=step, stop=stop, i=i, j=j, arr=arr)
 self.storage[i] = arr.eval(j)
 j += 1
diff --git a/pypy/module/micronumpy/test/test_zjit.py 
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -49,8 +49,6 @@
 assert result == f(5)
 
 def test_neg(self):
-space = self.space
-
 def f(i):
 ar = SingleDimArray(i)
 v = Call1(neg, ar, Signature())
@@ -105,6 +103,7 @@
   float_gt: 1, int_add: 1,
   int_lt: 1, guard_true: 1, 
   guard_false: 1, jump: 1})
+assert result == f(5)
 
 def test_min(self):
 space = self.space
@@ -122,6 +121,7 @@
float_lt: 1, int_add: 1,
int_lt: 1, guard_true: 2,
jump: 1})
+assert result == f(5)
 
 def test_argmin(self):
 space = self.space
@@ -139,6 +139,7 @@
float_lt: 1, int_add: 1,
int_lt: 1, guard_true: 2,
jump: 1})
+assert result == f(5)
 
 def test_all(self):
 space = self.space
@@ -154,6 +155,7 @@
 self.check_loops({getarrayitem_raw: 2, float_add: 1,
   int_add: 1, float_ne: 1,
   int_lt: 1, guard_true: 2, jump: 1})
+assert result == f(5)
 
 def test_any(self):
 space = self.space
@@ -166,6 +168,7 @@
 self.check_loops({getarrayitem_raw: 2, float_add: 1,
   int_add: 1, float_ne: 1, guard_false: 1,
   int_lt: 1, guard_true: 1, jump: 1})
+assert result == f(5)
 
 def test_already_forecd(self):
 def f(i):
@@ -257,7 +260,11 @@
 ar = SingleDimArray(step*i)
 ar2 = SingleDimArray(i)
 ar2.storage[1] = 5.5
-ar.setslice(space, 0, step*i, step, i, ar2.descr_add(space, ar2))
+if NonConstant(False):
+arg = ar2
+else:
+arg = ar2.descr_add(space, ar2)
+ar.setslice(space, 0, step*i, step, i, arg)
 return ar.get_concrete().storage[3]
 
 result = self.meta_interp(f, [5], listops=True, backendopt=True)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests to consistenty use array descrs

2011-07-21 Thread cfbolz
Author: Carl Friedrich Bolz cfb...@gmx.de
Branch: 
Changeset: r45833:2ead4778c7ac
Date: 2011-07-21 18:56 +0200
http://bitbucket.org/pypy/pypy/changeset/2ead4778c7ac/

Log:fix tests to consistenty use array descrs

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py 
b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -2820,11 +2820,11 @@
 def test_residual_call_invalidate_some_arrays(self):
 ops = 
 [p1, p2, i1]
-p3 = getarrayitem_gc(p1, 0, descr=arraydescr2)
+p3 = getarrayitem_gc(p2, 0, descr=arraydescr2)
 p4 = getarrayitem_gc(p2, 1, descr=arraydescr2)
 i2 = getarrayitem_gc(p1, 1, descr=arraydescr)
 i3 = call(i1, descr=writearraydescr)
-p5 = getarrayitem_gc(p1, 0, descr=arraydescr2)
+p5 = getarrayitem_gc(p2, 0, descr=arraydescr2)
 p6 = getarrayitem_gc(p2, 1, descr=arraydescr2)
 i4 = getarrayitem_gc(p1, 1, descr=arraydescr)
 escape(p3)
@@ -2837,7 +2837,7 @@
 
 expected = 
 [p1, p2, i1]
-p3 = getarrayitem_gc(p1, 0, descr=arraydescr2)
+p3 = getarrayitem_gc(p2, 0, descr=arraydescr2)
 p4 = getarrayitem_gc(p2, 1, descr=arraydescr2)
 i2 = getarrayitem_gc(p1, 1, descr=arraydescr)
 i3 = call(i1, descr=writearraydescr)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests

2011-07-16 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r45664:f12c4e733acd
Date: 2011-07-16 10:00 +0200
http://bitbucket.org/pypy/pypy/changeset/f12c4e733acd/

Log:fix tests

diff --git a/pypy/module/micronumpy/compile.py 
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -4,6 +4,7 @@
 
 
 from pypy.module.micronumpy.interp_numarray import FloatWrapper, SingleDimArray
+from pypy.rlib.objectmodel import specialize
 
 class BogusBytecode(Exception):
 pass
@@ -15,8 +16,12 @@
 return a
 
 class TrivialSpace(object):
-def wrap(self, x):
-return x
+w_ValueError = None
+
+@specialize.argtype(1)
+def wrap(self, w_obj):
+return w_obj
+
 
 def numpy_compile(bytecode, array_size):
 space = TrivialSpace()
diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -7,6 +7,8 @@
 from pypy.tool.sourcetools import func_with_new_name
 import math
 
+INSERT_SORT_THRESH = 15
+
 def dummy1(v):
 assert isinstance(v, float)
 return v
@@ -21,6 +23,8 @@
  reds = ['result_size', 'i', 'self', 'result'])
 all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
 any_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
+slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'self', 'arr'])
+slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'self', 'arr'])
 
 class Signature(object):
 def __init__(self):
@@ -88,6 +92,18 @@
 signature = Signature()
 def impl(self, space, w_other):
 w_other = convert_to_array(space, w_other)
+try:
+w_other_size = w_other.find_size()
+self_size = self.find_size()
+except ValueError:
+# this will be raised if one of the arrays is a scalar.
+pass
+else:
+# Need a better dimension check here for N-dim arrays
+if w_other_size != self_size:
+raise OperationError(space.w_ValueError,
+space.wrap(Cannot %s arrays of unequal dimensions \
+% function.__name__))
 new_sig = self.signature.transition(signature)
 res = Call2(
 function,
@@ -111,7 +127,7 @@
 signature = Signature()
 def impl(self, space, w_other):
 new_sig = self.signature.transition(signature)
-w_other = FloatWrapper(space.float_w(w_other))
+w_other = convert_to_array(space, w_other)
 res = Call2(
 function,
 w_other,
@@ -235,6 +251,80 @@
 else:
 return self.descr_mul(space, w_other)
 
+def _insertion_sort(self, storage, left, right):
+i = left + 1
+while i = right:
+temp = storage[i]
+j = i - 1
+while j = left and storage[j]  temp:
+storage[j + 1] = storage[j]
+j -= 1
+storage[j + 1] = temp
+i += 1
+
+def descr_sort(self, space):
+storage = self.get_concrete().storage
+# can replace these with integer/bool numpy arrays when we add dtypes
+lefts = [0]
+rights = [self.find_size() - 1]
+checkpivots = [False]
+while lefts:
+left = lefts.pop()
+right = rights.pop()
+checkpivot = checkpivots.pop()
+# just use middle element for now. will change to med of 3 soon
+mid = left + (right - left) / 2
+pivot = storage[mid]
+if checkpivot and pivot == storage[left - 1]:
+storage[mid], storage[left] = storage[left], storage[mid]
+i = left + 1
+j = right
+while 1:
+while storage[j] != pivot:
+j -= 1
+while storage[i] == pivot:
+if i = j: break
+i += 1
+if i = j: break
+storage[i], storage[j] = storage[j], storage[i]
+storage[j] = pivot
+if right  j + 1:
+if right - j + 1  INSERT_SORT_THRESH:
+self._insertion_sort(storage, j + 1, right)
+else:
+lefts.append(j + 1)
+rights.append(right)
+checkpivots.append(False)
+else:
+storage[mid], storage[right] = storage[right], storage[mid]
+i = left
+j = right - 1
+while 1:
+while storage[i]  pivot:
+i += 1
+   

[pypy-commit] pypy default: fix tests

2011-06-06 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r44750:a32dd231d58c
Date: 2011-06-06 15:19 +0200
http://bitbucket.org/pypy/pypy/changeset/a32dd231d58c/

Log:fix tests

diff --git a/pypy/jit/backend/llgraph/llimpl.py 
b/pypy/jit/backend/llgraph/llimpl.py
--- a/pypy/jit/backend/llgraph/llimpl.py
+++ b/pypy/jit/backend/llgraph/llimpl.py
@@ -601,14 +601,13 @@
 return _op_default_implementation
 
 def op_debug_merge_point(self, _, *args):
-#from pypy.jit.metainterp.warmspot import get_stats
-#loc = ConstPtr(value)._get_str()
-#try:
-#stats = get_stats()
-#except AttributeError:
-#pass
-#else:
-#stats.add_merge_point_location(loc)
+from pypy.jit.metainterp.warmspot import get_stats
+try:
+stats = get_stats()
+except AttributeError:
+pass
+else:
+stats.add_merge_point_location(args[1:])
 pass
 
 def op_guard_true(self, _, value):
diff --git a/pypy/jit/metainterp/test/test_logger.py 
b/pypy/jit/metainterp/test/test_logger.py
--- a/pypy/jit/metainterp/test/test_logger.py
+++ b/pypy/jit/metainterp/test/test_logger.py
@@ -51,9 +51,14 @@
 ts = llhelper
 
 def make_metainterp_sd(self):
+class FakeJitDriver(object):
+class warmstate(object):
+get_location_str = staticmethod(lambda args: 
args[0]._get_str())
+
 class FakeMetaInterpSd:
 cpu = AbstractCPU()
 cpu.ts = self.ts
+jitdrivers_sd = [FakeJitDriver()]
 def get_name_from_address(self, addr):
 return 'Name'
 return FakeMetaInterpSd()
@@ -111,11 +116,11 @@
 def test_debug_merge_point(self):
 inp = '''
 []
-debug_merge_point(info, 0)
+debug_merge_point(0, dupa)
 '''
 _, loop, oloop = self.reparse(inp, check_equal=False)
-assert loop.operations[0].getarg(0)._get_str() == 'info'
-assert oloop.operations[0].getarg(0)._get_str() == 'info'
+assert loop.operations[0].getarg(1)._get_str() == dupa
+assert oloop.operations[0].getarg(0)._get_str() == dupa
 
 def test_floats(self):
 inp = '''
diff --git a/pypy/jit/metainterp/test/test_warmspot.py 
b/pypy/jit/metainterp/test/test_warmspot.py
--- a/pypy/jit/metainterp/test/test_warmspot.py
+++ b/pypy/jit/metainterp/test/test_warmspot.py
@@ -80,7 +80,7 @@
 self.meta_interp(f, [123, 10])
 assert len(get_stats().locations) = 4
 for loc in get_stats().locations:
-assert loc == 'GREEN IS 123.'
+assert loc == (123,)
 
 def test_set_param_enable_opts(self):
 from pypy.rpython.annlowlevel import llstr, hlstr
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix tests.

2011-06-05 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r44714:382ce2271a5b
Date: 2011-06-05 13:40 +0200
http://bitbucket.org/pypy/pypy/changeset/382ce2271a5b/

Log:Fix tests.

diff --git a/pypy/jit/metainterp/test/test_warmstate.py 
b/pypy/jit/metainterp/test/test_warmstate.py
--- a/pypy/jit/metainterp/test/test_warmstate.py
+++ b/pypy/jit/metainterp/test/test_warmstate.py
@@ -181,6 +181,7 @@
 cpu = None
 memory_manager = None
 class FakeJitDriverSD:
+jitdriver = None
 _green_args_spec = [lltype.Signed, lltype.Float]
 _get_printable_location_ptr = None
 _confirm_enter_jit_ptr = None
@@ -207,6 +208,7 @@
 cpu = None
 memory_manager = None
 class FakeJitDriverSD:
+jitdriver = None
 _green_args_spec = [lltype.Signed, lltype.Float]
 _get_printable_location_ptr = llhelper(GET_LOCATION, get_location)
 _confirm_enter_jit_ptr = None
@@ -230,6 +232,7 @@
 cpu = None
 memory_manager = None
 class FakeJitDriverSD:
+jitdriver = None
 _green_args_spec = [lltype.Signed, lltype.Float]
 _get_printable_location_ptr = None
 _confirm_enter_jit_ptr = llhelper(ENTER_JIT, confirm_enter_jit)
@@ -253,6 +256,7 @@
 cpu = None
 memory_manager = None
 class FakeJitDriverSD:
+jitdriver = None
 _green_args_spec = [lltype.Signed, lltype.Float]
 _get_printable_location_ptr = None
 _confirm_enter_jit_ptr = None
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit