pike.git/
src/
testsuite.in
Branch:
Tag:
Non-build tags
All tags
No tags
2006-10-28
2006-10-28 19:18:08 by Henrik Grubbström (Grubba) <grubba@grubba.org>
a85e2ffc670d0ffd7d4025e847a9515db1590185 (
45
lines) (+
44
/-
1
)
[
Show
|
Annotate
]
Branch:
7.9
Added some tests of getters and setters.
Rev: src/testsuite.in:1.769
1:
START_MARKER
-
test_true([["$Id: testsuite.in,v 1.
768
2006/
09
/
04
12
:
11
:
00
nilsson
Exp $"]]);
+
test_true([["$Id: testsuite.in,v 1.
769
2006/
10
/
28
19
:
18
:
08
grubba
Exp $"]]);
// This triggered a bug only if run sufficiently early. test_compile_any([[#pike 7.2]])
3456:
return zz->x + zz->y + zz->z; ]], 7)
+
// Testing getter/setters
+
test_any([[
+
// Trivial case.
+
class X {
+
int `->x() { return 5; }
+
};
+
return X()->x;
+
]], 5)
+
+
test_any([[
+
// Strange behaviour getter & setter.
+
class X {
+
int y = 2;
+
int `->x() { return y*3; }
+
void `->x=(int z) { y += z*5; }
+
};
+
X x = X();
+
x->x = 2;
+
return x->x;
+
]], 36)
+
+
test_any([[
+
// Multiple inheritance.
+
class X {
+
int y = 0;
+
int `->x() { return y; }
+
void `->x=(int z) { y = z; }
+
};
+
class Y {
+
inherit X:x1;
+
inherit X:x2;
+
int `->x1() { return x1::x; }
+
void `->x1=(int z) { x1::x = z; }
+
int `->x2() { return x2::x; }
+
void `->x2=(int z) { x2::x = z; }
+
};
+
Y y = Y();
+
y->x1 = 1;
+
y->x2 = 2;
+
return (y->x1 + y->x2) * y->x;
+
]], 6)
+
test_do([[ // bug 3006 class X {