2017-03-20 14:55:26 -07:00
|
|
|
'use strict';
|
|
|
|
|
const common = require('../../common');
|
|
|
|
|
const assert = require('assert');
|
2021-05-14 09:17:02 -07:00
|
|
|
const addon = require(`./build/${common.buildType}/3_callbacks`);
|
2017-03-20 14:55:26 -07:00
|
|
|
|
2025-10-29 16:16:59 +01:00
|
|
|
addon.RunCallback(common.mustCall((msg) => {
|
2017-03-20 14:55:26 -07:00
|
|
|
assert.strictEqual(msg, 'hello world');
|
2025-10-29 16:16:59 +01:00
|
|
|
}));
|
2017-03-20 14:55:26 -07:00
|
|
|
|
|
|
|
|
function testRecv(desiredRecv) {
|
2025-10-29 16:16:59 +01:00
|
|
|
addon.RunCallbackWithRecv(common.mustCall(function() {
|
2017-03-20 14:55:26 -07:00
|
|
|
assert.strictEqual(this, desiredRecv);
|
2025-10-29 16:16:59 +01:00
|
|
|
}), desiredRecv);
|
2017-03-20 14:55:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
testRecv(undefined);
|
|
|
|
|
testRecv(null);
|
|
|
|
|
testRecv(5);
|
|
|
|
|
testRecv(true);
|
|
|
|
|
testRecv('Hello');
|
|
|
|
|
testRecv([]);
|
|
|
|
|
testRecv({});
|