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

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

#
Python | 38 lines | 21 code | 11 blank | 6 comment | 6 complexity | cf4e019df53bede8f57a4c4a1c04da38 MD5 | raw file
 1import virtual_poly
 2
 3d = virtual_poly.NDouble(3.5)
 4i = virtual_poly.NInt(2)
 5
 6#
 7# the copy methods return the right polymorphic types
 8# 
 9dc = d.copy()
10ic = i.copy()
11
12if d.get() != dc.get():
13  raise RuntimeError
14
15if i.get() != ic.get():
16  raise RuntimeError
17
18virtual_poly.incr(ic)
19
20if (i.get() + 1) != ic.get():
21  raise RuntimeError
22
23
24dr = d.ref_this()
25if d.get() != dr.get():
26  raise RuntimeError
27
28
29#
30# 'narrowing' also works
31#
32ddc = virtual_poly.NDouble_narrow(d.nnumber())
33if d.get() != ddc.get():
34  raise RuntimeError
35
36dic = virtual_poly.NInt_narrow(i.nnumber())
37if i.get() != dic.get():
38  raise RuntimeError