-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtest.js
More file actions
45 lines (36 loc) · 1.06 KB
/
test.js
File metadata and controls
45 lines (36 loc) · 1.06 KB
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
"use strict";
// Flags: --expose-gc
// Testing api calls for function
const test_function = loadAddon("test_function");
function func1() {
return 1;
}
assert.strictEqual(test_function.TestCall(func1), 1);
function func2() {
return null;
}
assert.strictEqual(test_function.TestCall(func2), null);
function func3(input) {
return input + 1;
}
assert.strictEqual(test_function.TestCall(func3, 1), 2);
function func4(input) {
return func3(input);
}
assert.strictEqual(test_function.TestCall(func4, 1), 2);
assert.strictEqual(test_function.TestName.name, "Name");
assert.strictEqual(test_function.TestNameShort.name, "Name_");
let tracked_function = test_function.MakeTrackedFunction(mustCall());
assert(!!tracked_function);
tracked_function = null;
gc();
assert.deepStrictEqual(test_function.TestCreateFunctionParameters(), {
envIsNull: "Invalid argument",
nameIsNull: "napi_ok",
cbIsNull: "Invalid argument",
resultIsNull: "Invalid argument",
});
assert.throws(() => test_function.TestBadReturnExceptionPending(), {
code: "throwing exception",
name: "Error",
});