pike.git/
src/
testsuite.in
Branch:
Tag:
Non-build tags
All tags
No tags
2003-04-08
2003-04-08 14:23:16 by Martin Stjernholm <mast@lysator.liu.se>
2a21271fa7857dd65828fc7fa3de7b1e9c162eed (
118
lines) (+
116
/-
2
)
[
Show
|
Annotate
]
Branch:
7.4
Test scoped frames wrt the various function call opcodes.
Rev: src/testsuite.in:1.587
1:
-
test_true([["$Id: testsuite.in,v 1.
586
2003/
03
/
29
10
:
52
:
29
marcus
Exp $"]]);
+
test_true([["$Id: testsuite.in,v 1.
587
2003/
04
/
08
14
:
23
:
16
mast
Exp $"]]);
// This triggered a bug only if run sufficiently early. test_compile_any([[#pike 7.2]])
710:
Top(); ]]);
-
// Testing stack popping
in
the
tail
recursion
opcodes
+
// Testing stack popping
wrt
the
various
function
call
opcodes
test_program([[ inherit Thread.Mutex : monitor; int f (int x)
981:
test_do(add_constant("f")) test_do(add_constant("monitor"))
+
// Testing scoped frames wrt the various function call opcodes
+
test_program([[
+
int f (int x)
+
{
+
return x;
+
}
+
int a (void|int x)
+
{
+
function s = lambda () {return x;};
+
return f (1); // F_CALL_LFUN_AND_RETURN
+
};
+
]]);
+
test_program([[
+
int f (int x)
+
{
+
return x;
+
};
+
mixed g = f;
+
int a (void|int x)
+
{
+
function s = lambda () {return x;};
+
return g (1); // F_CALL_FUNCTION_AND_RETURN
+
}
+
]]);
+
test_program([[
+
int f (int x)
+
{
+
return x;
+
}
+
int a()
+
{
+
add_constant ("f", f);
+
return compile_string(#"
+
int g (void|int x)
+
{
+
function s = lambda () {return x;};
+
return f (1); // F_APPLY_AND_RETURN
+
}")()->g();
+
}
+
]]);
+
test_program([[
+
int iter = 0;
+
int a (void|int x)
+
{
+
if (iter == 1) {
+
return x;
+
}
+
else {
+
function s = lambda () {return x;};
+
iter = 1;
+
return a (1); // F_COND_RECUR
+
}
+
}
+
]]);
+
test_program([[
+
int iter = 0;
+
int a (void|int x)
+
{
+
if (!iter) {
+
iter = 1;
+
return a (x);
+
}
+
else if (iter == 2) {
+
return x;
+
}
+
else {
+
function s = lambda () {return x;};
+
iter = 2;
+
return a (1); // F_TAIL_RECUR
+
}
+
}
+
]]);
+
test_program([[
+
int iter = 0;
+
int a (void|int x)
+
{
+
if (!iter) {
+
iter = 1;
+
return a (x);
+
}
+
else if (iter == 2) {
+
return x;
+
}
+
else {
+
function s = lambda () {return x;};
+
iter = 2;
+
int res = a (1); // F_RECUR
+
iter = -1;
+
return res;
+
}
+
}
+
]]);
+
test_program([[
+
int iter = 0;
+
int a (void|int x)
+
{
+
if (!iter) {
+
iter = 1;
+
return a (x);
+
}
+
else if (iter == 2) {
+
iter = x;
+
}
+
else {
+
function s = lambda () {return x;};
+
iter = 2;
+
a (1); // F_RECUR_AND_POP
+
return iter;
+
}
+
}
+
]]);
+
test_do(add_constant("f"))
+
test_false([[object_variablep(class X { int y; int z() { return 1; }}(),"foo")]]) test_false([[object_variablep(class X { int y; int z() { return 1; }}(),"z")]]) test_true([[object_variablep(class X { int y; int z() { return 1; }}(),"y")]])