aboutsummaryrefslogtreecommitdiffhomepage
path: root/libslang/src/test/nspace2.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/nspace2.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/nspace2.sl')
-rw-r--r--libslang/src/test/nspace2.sl70
1 files changed, 70 insertions, 0 deletions
diff --git a/libslang/src/test/nspace2.sl b/libslang/src/test/nspace2.sl
new file mode 100644
index 0000000..d13c15d
--- /dev/null
+++ b/libslang/src/test/nspace2.sl
@@ -0,0 +1,70 @@
+#ifexists This_Namespace
+if (This_Namespace == "NS3")
+ {
+ if (current_namespace () != "NS3")
+ {
+ failed ("evalfile in NS3");
+ }
+ }
+else
+ implements (This_Namespace);
+%vmessage ("Loading ...");
+% From this point on, define and variable defaults to static
+private variable NS = This_Namespace;
+define func ()
+{
+ return NS;
+}
+#else
+variable This_Namespace;
+_debug_info = 1; () = evalfile ("inc.sl");
+
+print ("Testing more NameSpace routines ...");
+This_Namespace = "NS1";
+() = evalfile (__FILE__);
+This_Namespace = "NS2";
+() = evalfile (__FILE__);
+
+This_Namespace = "NS3";
+() = evalfile (__FILE__, "NS3");
+
+use_namespace ("NS1");
+if (func () != "NS1")
+ failed ("use_namespace 1, found %s", func());
+
+use_namespace ("NS2");
+if (func () != "NS2")
+ failed ("use_namespace 2");
+
+use_namespace ("Global");
+if (is_defined ("func"))
+ failed ("use_namespace Global");
+
+if (NS1->func () != "NS1")
+ failed ("NS1->func");
+if (NS2->func () != "NS2")
+ failed ("NS2->func");
+
+if ("NS1" != eval ("func", "NS1"))
+ failed ("eval in NS1");
+if ("NS2" != eval ("func", "NS2"))
+ failed ("eval in NS2");
+if ("NS3" != eval ("func", "NS3"))
+ failed ("eval in NS3");
+
+if ("NS4" != eval ("current_namespace()", "NS4"))
+ failed ("eval in NS4");
+
+implements ("foo");
+variable X = "foo";
+implements ("bar");
+variable X = "bar";
+
+if (foo->X != "foo")
+ failed ("foo");
+if (bar->X != "bar")
+ failed ("bar");
+
+print ("Ok\n");
+exit (0);
+#endif