summaryrefslogtreecommitdiff
path: root/testprogs/ejs
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-31 01:20:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:20 -0500
commit509e57995c535db09b84c3e0efb4d33c5822e289 (patch)
tree16622f3f3335172573ed8457b9c95216af97a39c /testprogs/ejs
parent5c1a3defc6ba20fd833c99012c01195f39e515e6 (diff)
downloadsamba-509e57995c535db09b84c3e0efb4d33c5822e289.tar.gz
samba-509e57995c535db09b84c3e0efb4d33c5822e289.tar.bz2
samba-509e57995c535db09b84c3e0efb4d33c5822e289.zip
r7125: demonstrate some bugs in ejs
(This used to be commit 46adb4a065f3f7dd81d72ed041f24e2d81733b63)
Diffstat (limited to 'testprogs/ejs')
-rw-r--r--testprogs/ejs/bugs.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/testprogs/ejs/bugs.js b/testprogs/ejs/bugs.js
new file mode 100644
index 0000000000..3a211f3bdc
--- /dev/null
+++ b/testprogs/ejs/bugs.js
@@ -0,0 +1,76 @@
+/*
+ demonstrate some bugs in ejs
+
+ tridge <appweb@tridgell.net>
+*/
+
+
+/****************************************
+demo a bug in constructing arrays
+fix at http://build.samba.org/build.pl?function=diff;tree=samba4;revision=7124
+*****************************************/
+function arraybug() {
+ var a;
+
+ println("First with 3 elements");
+ a = new Array("one", "two", "three");
+ printVars(a);
+ assert(a.length == 3);
+ assert(a[0] == "one");
+ assert(a[1] == "two");
+ assert(a[2] == "three");
+
+ println("with a array length");
+ a = new Array(5);
+ printVars(a);
+ assert(a.length == 5);
+
+ println("\nNow with 1 element");
+ a = new Array("one");
+ printVars(a);
+ assert(a.length == 1);
+ assert(a[0] == "one");
+
+ println("ALL OK");
+}
+
+
+/****************************************
+demo a bug in variable arguments
+fix at http://build.samba.org/build.pl?function=diff;tree=samba4;revision=7085
+*****************************************/
+function argsbug() {
+ println("we should have been called with 3 arguments");
+ assert(arguments.length == 3);
+ assert(arguments[0] == "one");
+ assert(arguments[1] == "two");
+ assert(arguments[2] == "three");
+}
+
+
+/****************************************
+demo a bug in constructing objects
+no fix available yet
+*****************************************/
+function MyObj() {
+ var o = new Object();
+ o.test = 42;
+ return o;
+}
+
+function objbug() {
+ println("the docs say you should use 'new'");
+ var o1 = new MyObj();
+ var o2 = MyObj();
+ printVars(o1);
+ printVars(o2);
+ assert(o1.test == 42);
+ assert(o2.test == 42);
+}
+
+
+
+/* run the tests */
+arraybug();
+argsbug("one", "two", "three");
+objbug()