PageRenderTime 13ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/python/refcount_runme.py

#
Python | 61 lines | 37 code | 20 blank | 4 comment | 9 complexity | a229094f13b2876b99066aa3d357f9ea MD5 | raw file
 1from refcount import *
 2#
 3# very innocent example
 4#
 5
 6a = A3()
 7b1 = B(a)
 8b2 = B.create(a)
 9
10
11
12if a.ref_count() != 3:
13  raise RuntimeError("Count = %d" % a.ref_count())
14
15
16rca = b2.get_rca()
17b3 = B.create(rca)
18
19if a.ref_count() != 5:
20  raise RuntimeError("Count = %d" % a.ref_count())
21
22
23v = vector_A(2)
24v[0] = a
25v[1] = a
26
27x = v[0]
28del v
29
30if a.ref_count() != 6:
31  raise RuntimeError("Count = %d" % a.ref_count())
32
33# Check %newobject
34b4 = b2.cloner()
35if b4.ref_count() != 1:
36  raise RuntimeError
37
38b5 = global_create(a)
39if b5.ref_count() != 1:
40  raise RuntimeError
41
42b6 = Factory.create(a)
43if b6.ref_count() != 1:
44  raise RuntimeError
45
46b7 = Factory().create2(a)
47if b7.ref_count() != 1:
48  raise RuntimeError
49
50
51if a.ref_count() != 10:
52  raise RuntimeError("Count = %d" % a.ref_count())
53
54del b4
55del b5
56del b6
57del b7
58
59if a.ref_count() != 6:
60  raise RuntimeError("Count = %d" % a.ref_count())
61