summaryrefslogtreecommitdiffhomepage
path: root/tests/02_runtime/02_this
blob: 2c47811e6006ee9caa7b923bb4589feab6f9cb8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 --