1() = evalfile ("inc.sl");
2
3testing_feature ("method calls");
4
5static variable S = struct
6{
7   f, a
8};
9
10static variable T = struct
11{
12   g, b
13};
14
15static define method_0 (s)
16{
17   if ((_NARGS != 1) and (s != S))
18     failed ("method_0: %S: %S", _NARGS, s);
19}
20S.f = &method_0;
21S.f();
22
23static define method_1 (s,pi)
24{
25   if ((_NARGS != 2) and (s != S))
26     failed ("method_1");
27
28   if (pi != PI)
29     failed ("method_1");
30}
31
32S.f = &method_1;
33S.f(PI);
34
35static define method_2 (s,null,pi)
36{
37   if ((_NARGS != 3) and (s != S) and (null != NULL))
38     failed ("method_2");
39
40   if (pi != PI)
41     failed ("method_2");
42}
43
44S.f = &method_2;
45S.f(,PI);
46
47static define method_t (s)
48{
49   return s.a;
50}
51
52static define method_g (t, a)
53{
54   if ((_NARGS != 2) and (t != T))
55     failed ("method_g");
56
57   return a;
58}
59T.g = &method_g;
60S.f = &method_t;
61S.a = T;
62
63if (T != S.f().g (T))
64  failed ("s.f().g T");
65
66if (sin(1) != S.f().g (sin(1)))
67  failed ("s.f().g sin(1)");
68
69S.f = T;
70if (PI != S.f.g (PI))
71  failed ("s.f.g PI");
72
73S.f = Struct_Type[1];
74S.f[0] = T;
75
76if (PI != S.f[0].g (PI))
77  failed ("s.f[0].g PI");
78
79print ("Ok\n");
80
81exit (0);
82
83