summaryrefslogtreecommitdiff
path: root/Examples/test-suite/octave/li_attribute_runme.m
blob: ed051d9df81ec3f854530a63b7c6232cf764ca59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
  crash_dumps_octave_core(0);
endif

li_attribute

aa = li_attribute.A(1,2,3);

if (aa.a != 1)
  error
endif
aa.a = 3;
if (aa.a != 3)
  error("aa.a = %i",aa.a)
endif

if (aa.b != 2)
  error(aa.b)
endif
aa.b = 5;
if (aa.b != 5)
  error
endif

if (aa.d != aa.b)
  error
endif

if (aa.c != 3)
  error
endif

pi = li_attribute.Param_i(7);
if (pi.value != 7)
 error
endif

pi.value=3;
if (pi.value != 3)
 error
endif

b = li_attribute.B(aa);

if (b.a.c != 3)
 error
endif

# class/struct attribute with get/set methods using return/pass by reference
myFoo = li_attribute.MyFoo();
myFoo.x = 8;
myClass = li_attribute.MyClass();
myClass.Foo = myFoo;
if (myClass.Foo.x != 8)
  error
endif

# class/struct attribute with get/set methods using return/pass by value
myClassVal = li_attribute.MyClassVal();
if (myClassVal.ReadWriteFoo.x != -1)
  error
endif
if (myClassVal.ReadOnlyFoo.x != -1)
  error
endif
myClassVal.ReadWriteFoo = myFoo;
if (myClassVal.ReadWriteFoo.x != 8)
  error
endif
if (myClassVal.ReadOnlyFoo.x != 8)
  error
endif

# string attribute with get/set methods using return/pass by value
myStringyClass = li_attribute.MyStringyClass("initial string");
if (myStringyClass.ReadWriteString != "initial string")
  error
endif
if (myStringyClass.ReadOnlyString != "initial string")
  error
endif
myStringyClass.ReadWriteString = "changed string";
if (myStringyClass.ReadWriteString != "changed string")
  error
endif
if (myStringyClass.ReadOnlyString != "changed string")
  error
endif