示例#1
0
 def test_become(self):
     from __pypy__ import thunk, become
     x = []
     y = []
     assert x is not y
     become(x, y)
     assert x is y
示例#2
0
 def test_double_become2(self):
     from __pypy__ import thunk, become
     x = []
     y = []
     z = []
     become(x, y)
     become(x, z)
     assert x is y is z
示例#3
0
 def test_id(self):
     from __pypy__ import thunk, become
     # these are the Smalltalk semantics of become().
     x = []; idx = id(x)
     y = []; idy = id(y)
     assert idx != idy
     become(x, y)
     assert id(x) == id(y) == idy
示例#4
0
 def test_is_thunk_become(self):
     from __pypy__ import thunk, become, is_thunk
     def f():
         return 42
     x = thunk(f)
     y = []
     become(y, x)
     assert is_thunk(y)
     assert y == 42
     assert not is_thunk(y)
示例#5
0
 def send(self, obj, n=None):
     #print 'send', n,; self._check(obj)
     if n is None:
         n = self.count
         self.count += 2
         data = (n, obj, None)
     else:
         data = (n, obj)
     self.sendraw(data)
     become(obj, thunk(self._resume, n))
示例#6
0
 def test_double_become(self):
     skip("fix me")
     from __pypy__ import thunk, become
     x = [1]
     y = [2]
     z = [3]
     become(x, y)
     become(y, z)
     assert x is y is z
     a = []
     a.extend(x)
     a.extend(y)
     a.extend(z)
     assert a == [3, 3, 3]
示例#7
0
 def test_become_yourself(self):
     from __pypy__ import become
     x = []
     become(x, x)
     assert str(x) == "[]"