Skip to content

Commit 417a7f9

Browse files
committed
Add more complex tests cases for callbacks.
1 parent b9f3a07 commit 417a7f9

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

source/ports/node_port/source/node_port.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ napi_value metacall_node_call(napi_env env, napi_callback_info info)
730730

731731
metacall_node_exception(env, status);
732732

733-
for (size_t i = 1; i < argc; i++)
733+
for (size_t i = 1; i < argc; ++i)
734734
{
735735
args[i - 1] = metacall_node_napi_to_value(env, recv, argv[i]);
736736
}

source/ports/node_port/test/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ describe('metacall', () => {
135135

136136
// Currying more
137137
assert.strictEqual(f.function_currying_more(5)(4)(3)(2)(1), 120);
138+
139+
// Factorial composition (@trgwii)
140+
/*
141+
const factorial = f.function_factorial_compose(f.function_factorial);
142+
assert.notStrictEqual(factorial, undefined);
143+
assert.strictEqual(factorial(5), 120);
144+
*/
138145
});
139146
});
140147
});

source/scripts/python/function/source/function.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ def function_currying(y):
2424

2525
def function_currying_more(y):
2626
return lambda x: lambda z: lambda w: lambda n: x * z * w * n * y
27+
28+
def function_factorial_compose(x):
29+
return lambda n: x(x)(n)
30+
31+
def function_factorial(x):
32+
return lambda n: 1 if n == 0 else n * x(x)(n - 1)

0 commit comments

Comments
 (0)