mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-06 08:46:53 +08:00
Add test for explicitly capturing "this"
This commit is contained in:
parent
c54d84fae6
commit
94fb7c2453
26
unittests/explicit_this_capture.chai
Normal file
26
unittests/explicit_this_capture.chai
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
class Test
|
||||||
|
{
|
||||||
|
def Test()
|
||||||
|
{}
|
||||||
|
|
||||||
|
def a(Function f)
|
||||||
|
{
|
||||||
|
f("test");
|
||||||
|
// f();
|
||||||
|
}
|
||||||
|
|
||||||
|
def b()
|
||||||
|
{
|
||||||
|
var l = fun [this](x) { this.thing(); }
|
||||||
|
this.a(l)
|
||||||
|
}
|
||||||
|
|
||||||
|
def thing()
|
||||||
|
{
|
||||||
|
print("hello world");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var t = Test()
|
||||||
|
t.b()
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user