blob: d8e85d2a904a078fd2b09f2b0c30ea4c79827745 (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
The "this" object accesses the current function context.
-- Expect stdout --
true
true
-- End --
-- Testcase --
{%
// Functions not invoked on objects have no this context
function test() {
return (this === null);
}
// When invoked, "this" will point to the object containing the function
let o;
o = {
test: function() {
return (this === o);
}
};
print(test(), "\n");
print(o.test(), "\n");
%}
-- End --
Test that the context is properly restored if function call arguments are
dot or bracket expressions as well.
-- Expect stdout --
true
true
-- End --
-- Testcase --
{%
let o;
o = {
test: function() {
return (this === o);
}
};
let dummy = { foo: true, bar: false };
print(o.test(dummy.foo, dummy.bar), "\n");
print(o.test(dummy.foo, o.test(dummy.foo, dummy.bar)), "\n");
%}
-- End --
|