[pypy-commit] pypy call-via-pyobj: rename, expand passing test to show how subclass can affect base class's nb_multiply
mattip
pypy.commits at gmail.com
Sat Jul 9 17:34:21 EDT 2016
Author: Matti Picus <matti.picus at gmail.com>
Branch: call-via-pyobj
Changeset: r85638:d87275ed7128
Date: 2016-07-09 07:54 -0400
http://bitbucket.org/pypy/pypy/changeset/d87275ed7128/
Log: rename, expand passing test to show how subclass can affect base
class's nb_multiply
passes w/-A and untranslated
diff --git a/pypy/module/cpyext/test/test_arraymodule.py b/pypy/module/cpyext/test/test_arraymodule.py
--- a/pypy/module/cpyext/test/test_arraymodule.py
+++ b/pypy/module/cpyext/test/test_arraymodule.py
@@ -78,13 +78,26 @@
rra = pickle.loads(s) # rra is arr backwards
#assert arr.tolist() == rra.tolist()
- def test_binop_mul_impl(self):
+ def test_subclass(self):
# check that rmul is called
module = self.import_module(name='array')
arr = module.array('i', [2])
res = [1, 2, 3] * arr
assert res == [1, 2, 3, 1, 2, 3]
+
+ arr = module.arraybase('i', [2])
+ res = [1, 2, 3] * arr
+ assert res == [1, 2, 3, 1, 2, 3]
+
+ # switch nb_multiply on Arraytype,
+ # switches BaseArraytpye as well since tp_as_number is a reference
module.switch_multiply()
+
+ arr = module.array('i', [2])
+ res = [1, 2, 3] * arr
+ assert res == [2, 4, 6]
+
+ arr = module.arraybase('i', [2])
res = [1, 2, 3] * arr
assert res == [2, 4, 6]
More information about the pypy-commit
mailing list