mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
785 B
44 lines
785 B
/*
|
|
* Bound function as initial function of a Thread.
|
|
*/
|
|
|
|
/*---
|
|
{
|
|
"custom": true,
|
|
"knownissue": "initial function of a new coroutine cannot be bound"
|
|
}
|
|
---*/
|
|
|
|
/*===
|
|
non-bound
|
|
func called: 321
|
|
bound
|
|
func called: 123
|
|
===*/
|
|
|
|
function nonBoundTest() {
|
|
var func = function (x) {
|
|
print('func called:', x);
|
|
};
|
|
var t = new Duktape.Thread(func);
|
|
Duktape.Thread.resume(t, 321);
|
|
}
|
|
|
|
function boundTest() {
|
|
var func = function (x) {
|
|
print('func called:', x);
|
|
};
|
|
var boundFunc = func.bind('myThis', 123);
|
|
var t = new Duktape.Thread(boundFunc);
|
|
Duktape.Thread.resume(t, 321); // arg ignored because bound
|
|
}
|
|
|
|
try {
|
|
print('non-bound');
|
|
nonBoundTest();
|
|
|
|
print('bound');
|
|
boundTest();
|
|
} catch (e) {
|
|
print(e.stack || e);
|
|
}
|
|
|