summaryrefslogtreecommitdiffhomepage
path: root/tests/02_runtime/02_this
diff options
context:
space:
mode:
Diffstat (limited to 'tests/02_runtime/02_this')
-rw-r--r--tests/02_runtime/02_this28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/02_runtime/02_this b/tests/02_runtime/02_this
new file mode 100644
index 0000000..2c47811
--- /dev/null
+++ b/tests/02_runtime/02_this
@@ -0,0 +1,28 @@
+The "this" object accesses the current function context.
+
+-- Expect stdout --
+
+-- End --
+true
+true
+-- Testcase --
+{%
+ local g = this;
+
+ // Functions not invoked on objects have no this context
+ function test() {
+ print(this, "\n");
+ return (this === null);
+ }
+
+ // When invoked, "this" will point to the object containing the function
+ local o = {
+ test: function() {
+ return (this === o);
+ }
+ };
+
+ print(test(), "\n");
+ print(o.test(), "\n");
+%}
+-- End --