aboutsummaryrefslogtreecommitdiffhomepage
path: root/libslang/src/test/nspace.sl
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2011-10-14 04:55:05 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2011-10-14 04:55:05 +0200
commit6aa0e0017d7d0cddc006da885946934b06949a91 (patch)
tree66b688ec32e2f91266db760b1762f2a50cc52036 /libslang/src/test/nspace.sl
parenta966db5b71328f6adf9dd767e64b322a3bd7ed9c (diff)
downloaderlang-slang-fork-6aa0e0017d7d0cddc006da885946934b06949a91.tar.gz
include libslang-1.4.9 and automatically build it and link erlang-slang against it
few (erlang) people will still have libslang-1.4.9 installed or spend time to get it to link against the driver
Diffstat (limited to 'libslang/src/test/nspace.sl')
-rw-r--r--libslang/src/test/nspace.sl93
1 files changed, 93 insertions, 0 deletions
diff --git a/libslang/src/test/nspace.sl b/libslang/src/test/nspace.sl
new file mode 100644
index 0000000..0b961c7
--- /dev/null
+++ b/libslang/src/test/nspace.sl
@@ -0,0 +1,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);
+