aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/javascript/global_vars_runme.js
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/javascript/global_vars_runme.js')
-rw-r--r--Examples/test-suite/javascript/global_vars_runme.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/Examples/test-suite/javascript/global_vars_runme.js b/Examples/test-suite/javascript/global_vars_runme.js
new file mode 100644
index 000000000..1f5e1718a
--- /dev/null
+++ b/Examples/test-suite/javascript/global_vars_runme.js
@@ -0,0 +1,25 @@
+var global_vars = require("global_vars");
+
+// In javascript, assigning to a non-existent variable is
+// not an error
+
+global_vars.init();
+b = global_vars.b;
+if (b != "string b") {
+ throw new Error("Unexpected string: " + b.toString());
+}
+global_vars.b = "a string value";
+b = global_vars.b;
+if (b != "a string value") {
+ throw new Error("Unexpected string: " + b.toString());
+}
+
+x = global_vars.x;
+if (x != 1234) {
+ throw new Error("Unexpected x: " + x.toString());
+}
+global_vars.x = 9876;
+x = global_vars.x;
+if (x != 9876) {
+ throw new Error("Unexpected string: " + x.toString());
+}