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

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

#
Python | 74 lines | 53 code | 14 blank | 7 comment | 18 complexity | 64de07c276af68ea1d91f1f539cca314 MD5 | raw file
 1# Ported to C# li_attribute_runme.cs
 2
 3import li_attribute
 4
 5aa = li_attribute.A(1,2,3)
 6
 7if aa.a != 1:
 8  raise RuntimeError
 9aa.a = 3
10if aa.a != 3:
11  print aa.a
12  raise RuntimeError
13
14if aa.b != 2:
15  print aa.b
16  raise RuntimeError
17aa.b = 5
18if aa.b != 5:
19  raise RuntimeError
20
21if aa.d != aa.b:
22  raise RuntimeError
23
24if aa.c != 3:
25  raise RuntimeError
26#aa.c = 5
27#if aa.c != 3:
28#  raise RuntimeError
29
30pi = li_attribute.Param_i(7)
31if pi.value != 7:
32 raise RuntimeError
33
34pi.value=3
35if pi.value != 3:
36 raise RuntimeError
37
38b = li_attribute.B(aa)
39
40if b.a.c != 3:
41 raise RuntimeError
42  
43# class/struct attribute with get/set methods using return/pass by reference
44myFoo = li_attribute.MyFoo()
45myFoo.x = 8
46myClass = li_attribute.MyClass()
47myClass.Foo = myFoo
48if myClass.Foo.x != 8:
49  raise RuntimeError
50
51# class/struct attribute with get/set methods using return/pass by value
52myClassVal = li_attribute.MyClassVal()
53if myClassVal.ReadWriteFoo.x != -1:
54  raise RuntimeError
55if myClassVal.ReadOnlyFoo.x != -1:
56  raise RuntimeError
57myClassVal.ReadWriteFoo = myFoo
58if myClassVal.ReadWriteFoo.x != 8:
59  raise RuntimeError
60if myClassVal.ReadOnlyFoo.x != 8:
61  raise RuntimeError
62
63# string attribute with get/set methods using return/pass by value
64myStringyClass = li_attribute.MyStringyClass("initial string")
65if myStringyClass.ReadWriteString != "initial string":
66  raise RuntimeError
67if myStringyClass.ReadOnlyString != "initial string":
68  raise RuntimeError
69myStringyClass.ReadWriteString = "changed string"
70if myStringyClass.ReadWriteString != "changed string":
71  raise RuntimeError
72if myStringyClass.ReadOnlyString != "changed string":
73  raise RuntimeError
74