[pypy-commit] lang-smalltalk strategies-tagging: Updated strategies tests.
anton_gulenko
noreply at buildbot.pypy.org
Thu Mar 20 13:16:07 CET 2014
Author: Anton Gulenko <anton.gulenko at googlemail.com>
Branch: strategies-tagging
Changeset: r674:f5c765f96240
Date: 2014-03-20 13:14 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/f5c765f96240/
Log: Updated strategies tests. Fixed other tests.
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -757,16 +757,17 @@
def __init__(self, space, w_self=None, w_home=None, argcnt=0, initialip=0):
self = jit.hint(self, access_directly=True, fresh_virtualizable=True)
- contextsize = w_home.as_methodcontext_get_shadow(space).myblocksize()
creating_w_self = w_self is None
if creating_w_self:
+ contextsize = w_home.as_methodcontext_get_shadow(space).myblocksize()
w_self = model.W_PointersObject(space, space.w_BlockContext, contextsize)
ContextPartShadow.__init__(self, space, w_self)
if creating_w_self:
w_self.store_shadow(self)
self.store_expected_argument_count(argcnt)
self.store_initialip(initialip)
- self.store_w_home(w_home)
+ if w_home:
+ self.store_w_home(w_home)
self.store_pc(initialip)
self.init_stack_and_temps()
diff --git a/spyvm/test/test_primitives.py b/spyvm/test/test_primitives.py
--- a/spyvm/test/test_primitives.py
+++ b/spyvm/test/test_primitives.py
@@ -14,11 +14,11 @@
class MockFrame(model.W_PointersObject):
def __init__(self, stack):
+ self.space = space
size = 6 + len(stack) + 6
self.strategy = strategies.ListStorageStrategy.singleton
self.initialize_storage(space, size)
self.store_all(space, [None] * 6 + stack + [space.w_nil] * 6)
- import pdb; pdb.set_trace()
s_self = self.as_blockcontext_get_shadow(space)
s_self.init_stack_and_temps()
s_self.reset_stack()
diff --git a/spyvm/test/test_shadow.py b/spyvm/test/test_shadow.py
--- a/spyvm/test/test_shadow.py
+++ b/spyvm/test/test_shadow.py
@@ -155,7 +155,7 @@
assert s_object.s_home() == s_object
def assert_contains_nils(w_obj):
- for i in range(w_obj.strategy.size_of(w_obj)):
+ for i in range(w_obj.basic_size()):
assert model.w_nil == w_obj.strategy.fetch(i, space, w_obj)
def test_attach_mc():
diff --git a/spyvm/test/test_strategies.py b/spyvm/test/test_strategies.py
--- a/spyvm/test/test_strategies.py
+++ b/spyvm/test/test_strategies.py
@@ -7,10 +7,8 @@
# Fieldtypes have a separate test file
space, interp = tools.setup_module(tools, filename='bootstrapped.image')
-
class_Array = space.classtable["w_Array"]
-
def arr(size):
return model.W_PointersObject(space, class_Array, size)
@@ -19,21 +17,16 @@
a.store(space, 0, arr(1))
return a
-def dense_arr(size):
+def tagging_arr(size):
a = arr(size)
a.store(space, 0, space.wrap_int(12))
return a
-def dense_arr_odd(size):
+def tagging_arr_odd(size):
a = arr(size)
a.store(space, 2, space.wrap_int(12))
return a
-def sparse_arr(size):
- a = dense_arr(size)
- a.store(space, 2, space.wrap_int(20))
- return a
-
def check_arr(arr, expected):
for i in range(arr.basic_size()):
if expected[i] == w_nil:
@@ -85,55 +78,27 @@
a.store(space, 1, arr(1))
assert a.basic_size() == 5
-# ====== Dense and Sparse *SmallInteger-StorageStrategy
+# ====== Tagging SmallInteger StorageStrategy
-def test_AllNil_to_Dense():
- a = dense_arr(5)
- assert isinstance(a.strategy, strategies.DenseSmallIntegerStorageStrategy)
+def test_AllNil_to_Int():
+ a = tagging_arr(5)
+ assert isinstance(a.strategy, strategies.TaggingSmallIntegerStorageStrategy)
check_arr(a, [12, w_nil, w_nil, w_nil, w_nil])
-def test_Dense_store():
- a = dense_arr(5)
+def test_Tagging_store():
+ a = tagging_arr(5)
a.store(space, 1, space.wrap_int(20))
a.store(space, 2, space.wrap_int(20))
- assert isinstance(a.strategy, strategies.DenseSmallIntegerStorageStrategy)
+ assert isinstance(a.strategy, strategies.TaggingSmallIntegerStorageStrategy)
check_arr(a, [12, 20, 20, w_nil, w_nil])
-def test_Dense_overwrite_middle():
- a = dense_arr(5)
- a.store(space, 1, space.wrap_int(20))
- a.store(space, 2, space.wrap_int(20))
- a.store(space, 1, space.wrap_int(30))
- check_arr(a, [12, 30, 20, w_nil, w_nil])
-
-def test_Dense_overwrite_first():
- a = dense_arr(5)
- a.store(space, 1, space.wrap_int(20))
- a.store(space, 2, space.wrap_int(20))
- a.store(space, 0, space.wrap_int(30))
- check_arr(a, [30, 20, 20, w_nil, w_nil])
-
-def test_Dense_overwrite_last():
- a = dense_arr(5)
- a.store(space, 1, space.wrap_int(20))
- a.store(space, 2, space.wrap_int(20))
- a.store(space, 2, space.wrap_int(30))
- check_arr(a, [12, 20, 30, w_nil, w_nil])
-
-def test_Dense_odd():
- a = dense_arr_odd(5)
- assert isinstance(a.strategy, strategies.DenseSmallIntegerStorageStrategy)
+def test_Tagging_store_nil_to_nil():
+ a = tagging_arr_odd(5)
+ a.store(space, 1, w_nil)
check_arr(a, [w_nil, w_nil, 12, w_nil, w_nil])
-
-def test_Dense_odd_store():
- a = dense_arr_odd(5)
- a.store(space, 1, space.wrap_int(20))
- a.store(space, 3, space.wrap_int(40))
- a.store(space, 4, space.wrap_int(30))
- check_arr(a, [w_nil, 20, 12, 40, 30])
-
-def test_Dense_odd_overwrite():
- a = dense_arr_odd(5)
+
+def test_Tagging_delete():
+ a = tagging_arr_odd(5)
a.store(space, 1, space.wrap_int(1))
a.store(space, 3, space.wrap_int(2))
a.store(space, 2, space.wrap_int(100))
@@ -141,67 +106,13 @@
a.store(space, 3, space.wrap_int(300))
check_arr(a, [w_nil, 200, 100, 300, w_nil])
-def test_Dense_store_nil_to_nil():
- a = dense_arr_odd(5)
- a.store(space, 1, w_nil)
- check_arr(a, [w_nil, w_nil, 12, w_nil, w_nil])
-
-def test_Dense_delete():
- a = dense_arr_odd(5)
- a.store(space, 1, space.wrap_int(1))
- a.store(space, 3, space.wrap_int(2))
- a.store(space, 2, space.wrap_int(100))
- a.store(space, 1, space.wrap_int(200))
- a.store(space, 3, space.wrap_int(300))
- check_arr(a, [w_nil, 200, 100, 300, w_nil])
-
-def test_Dense_delete_first():
- a = dense_arr_odd(5)
+def test_Tagging_delete_first():
+ a = tagging_arr_odd(5)
a.store(space, 1, space.wrap_int(1))
a.store(space, 1, w_nil)
check_arr(a, [w_nil, w_nil, 12, w_nil, w_nil])
-def test_Dense_delete_last():
- a = dense_arr_odd(5)
- a.store(space, 1, space.wrap_int(1))
- a.store(space, 2, w_nil)
- check_arr(a, [w_nil, 1, w_nil, w_nil, w_nil])
-
-def test_Dense_to_AllNil():
- a = dense_arr_odd(5)
- a.store(space, 2, w_nil)
- assert isinstance(a.strategy, strategies.AllNilStorageStrategy)
-
-def test_Dense_to_List():
- a = dense_arr_odd(5)
+def test_Tagging_to_List():
+ a = tagging_arr_odd(5)
a.store(space, 1, arr(1))
assert isinstance(a.strategy, strategies.ListStorageStrategy)
-
-def test_Dense_to_Sparse_by_deleting():
- a = dense_arr_odd(5)
- a.store(space, 1, space.wrap_int(10))
- a.store(space, 3, space.wrap_int(20))
- a.store(space, 2, w_nil)
- assert isinstance(a.strategy, strategies.SparseSmallIntegerStorageStrategy)
- check_arr(a, [w_nil, 10, w_nil, 20, w_nil])
-
-def test_Dense_to_Sparse_by_storing():
- a = dense_arr_odd(5)
- a.store(space, 4, space.wrap_int(10))
- assert isinstance(a.strategy, strategies.SparseSmallIntegerStorageStrategy)
- check_arr(a, [w_nil, w_nil, 12, w_nil, 10])
-
-def test_Sparse_store_nil():
- a = sparse_arr(5)
- a.store(space, 2, w_nil)
- check_arr(a, [12, w_nil, w_nil, w_nil, w_nil])
-
-def test_Sparse_store():
- a = sparse_arr(5)
- a.store(space, 4, space.wrap_int(100))
- check_arr(a, [12, w_nil, 20, w_nil, 100])
-
-def test_Sparse_to_List():
- a = sparse_arr(5)
- a.store(space, 4, arr(5))
- assert isinstance(a.strategy, strategies.ListStorageStrategy)
More information about the pypy-commit
mailing list