aboutsummaryrefslogtreecommitdiffhomepage
path: root/libslang/src/test/selfload.sl
blob: a360a2922e127291e2d64c7e6b6ef123fe780448 (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
% This is also a good test to perform leak checking on.
_debug_info = 1; () = evalfile ("inc.sl");

print ("Testing recursive function modifications ...");

variable X = "";

variable V1 = "define crash () { eval(V2); X += \"V1\"; }";
variable V2 = "define crash () { eval(V1); X += \"V2\"; }";

define crash ();

define crash ()
{
   eval (V1);			       
   crash ();
   if (X != "V1")
     failed ("V1");

   if (1) 
     {
	eval (V2);
	crash ();
	if (X != "V1V2")
	  failed ("V1V2");

	if (1) 
	  eval (V1);
	crash ();
	if (X != "V1V2V1")
	  failed ("V1V2V1");
     }
   X += "V0";
}

crash ();
if (X != "V1V2V1V0") failed ("V1V2V1V0 : ", + X);

print ("Ok\n");
exit (0);