PageRenderTime 19ms CodeModel.GetById 1ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Python | 67 lines | 37 code | 26 blank | 4 comment | 15 complexity | 15dd4deff2a2ac4d8743e0a644dc0b92 MD5 | raw file
 1from kwargs_feature import *
 2
 3class MyFoo(Foo):
 4  def __init__(self, a , b = 0):
 5    Foo.__init__(self, a, b)
 6
 7    
 8
 9# Simple class
10f1 = MyFoo(2)
11
12f = Foo(b=2,a=1)
13
14if f.foo(b=1,a=2) != 3:
15  raise RuntimeError
16
17if Foo_statfoo(b=2) != 3:
18  raise RuntimeError
19
20if f.efoo(b=2) != 3:
21  raise RuntimeError
22
23if Foo_sfoo(b=2) != 3:
24  raise RuntimeError
25
26
27# Templated class
28b = BarInt(b=2,a=1)
29
30if b.bar(b=1,a=2) != 3:
31  raise RuntimeError
32
33if BarInt_statbar(b=2) != 3:
34  raise RuntimeError
35
36if b.ebar(b=2) != 3:
37  raise RuntimeError
38
39if BarInt_sbar(b=2) != 3:
40  raise RuntimeError
41
42
43# Functions
44if templatedfunction(b=2) != 3:
45  raise RuntimeError
46
47if foo(a=1,b=2) != 3:
48  raise RuntimeError
49
50if foo(b=2) != 3:
51  raise RuntimeError
52
53
54#Funtions with keywords
55
56if foo_kw(_from=2) != 4:
57  raise RuntimeError
58
59if foo_nu(_from=2, arg2=3) != 2:
60  raise RuntimeError
61
62if foo_mm(min=2) != 4:
63  raise RuntimeError
64
65if foo_mm(max=3) != 4:
66  raise RuntimeError
67