blob: 0b961c7f6970ec7c843fc40f005c12d8e117561f (
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
91
92
93
|
_debug_info = 1; () = evalfile ("inc.sl");
print ("Testing NameSpace routines ...");
if (current_namespace () != "")
failed ("current_namespace - 1");
implements ("NSpace");
% From this point on, define and variable defaults to static
if (current_namespace () != "NSpace")
failed ("current_namespace - 2");
define static_function ()
{
"static_function";
}
variable static_variable = "static_variable";
public define public_function ()
{
"public_function";
}
public variable public_variable = "public_variable";
private define private_function ()
{
"private_function";
}
private variable private_variable = "private_variable";
!if (is_defined ("Global->public_function")) failed ("public_function");
!if (is_defined ("Global->public_variable")) failed ("public_variable");
!if (is_defined ("public_function")) failed ("public_function");
!if (is_defined ("public_variable")) failed ("public_variable");
!if (is_defined ("NSpace->static_function")) failed ("static_function");
!if (is_defined ("NSpace->static_variable")) failed ("static_variable");
if (is_defined ("NSpace->private_function")) failed ("private_function");
if (is_defined ("NSpace->private_variable")) failed ("private_variable");
if (static_variable != NSpace->static_variable) failed ("static_variable test");
if (public_variable != Global->public_variable) failed ("public_variable test");
if (private_variable != "private_variable") failed ("private_variable test");
public variable This_Namespace;
This_Namespace = "NS1";
() = evalfile ("ns1.inc");
This_Namespace = "NS2";
() = evalfile ("ns2.inc");
use_namespace ("NS1");
if (func () != "NS1")
failed ("use_namespace 1");
define func1 ()
{
return "1";
}
use_namespace ("NS2");
if (func () != "NS2")
failed ("use_namespace 2");
define func1 ()
{
return "2";
}
use_namespace ("Global");
if (is_defined ("func"))
failed ("use_namespace Global");
define func1 ()
{
return "3";
}
!if (is_defined ("func1"))
failed ("use_namespace Global: func1");
if (NS1->func () != "NS1")
failed ("NS1->func");
if (NS2->func () != "NS2")
failed ("NS2->func");
if (NS1->func1 () != "1")
failed ("NS1->func1");
if (NS2->func1 () != "2")
failed ("NS2->func1");
if (Global->func1 () != "3")
failed ("Global->func1");
if (length (_get_namespaces ()) != 4) % Global, NS1, NS2, NSpace
failed ("_get_namespaces: %S", _get_namespaces());
print ("Ok\n");
exit (0);
|