2017-03-20 14:55:26 -07:00
|
|
|
'use strict';
|
2018-07-06 10:47:48 -04:00
|
|
|
// Flags: --expose-gc
|
|
|
|
|
2017-03-20 14:55:26 -07:00
|
|
|
const common = require('../../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
// testing api calls for function
|
2018-01-23 21:49:25 +11:00
|
|
|
const test_function = require(`./build/${common.buildType}/test_function`);
|
2017-03-20 14:55:26 -07:00
|
|
|
|
|
|
|
function func1() {
|
|
|
|
return 1;
|
|
|
|
}
|
2017-09-11 09:57:38 -04:00
|
|
|
assert.strictEqual(test_function.TestCall(func1), 1);
|
2017-03-20 14:55:26 -07:00
|
|
|
|
|
|
|
function func2() {
|
|
|
|
console.log('hello world!');
|
|
|
|
return null;
|
|
|
|
}
|
2017-09-11 09:57:38 -04:00
|
|
|
assert.strictEqual(test_function.TestCall(func2), null);
|
2017-03-20 14:55:26 -07:00
|
|
|
|
|
|
|
function func3(input) {
|
|
|
|
return input + 1;
|
|
|
|
}
|
2017-09-11 09:57:38 -04:00
|
|
|
assert.strictEqual(test_function.TestCall(func3, 1), 2);
|
2017-03-20 14:55:26 -07:00
|
|
|
|
|
|
|
function func4(input) {
|
|
|
|
return func3(input);
|
|
|
|
}
|
2017-09-11 09:57:38 -04:00
|
|
|
assert.strictEqual(test_function.TestCall(func4, 1), 2);
|
|
|
|
|
|
|
|
assert.strictEqual(test_function.TestName.name, 'Name');
|
|
|
|
assert.strictEqual(test_function.TestNameShort.name, 'Name_');
|
2018-07-06 10:47:48 -04:00
|
|
|
|
|
|
|
let tracked_function = test_function.MakeTrackedFunction(common.mustCall());
|
|
|
|
assert(!!tracked_function);
|
|
|
|
tracked_function = null;
|
|
|
|
global.gc();
|