Skip to content

Commit 66cf814

Browse files
committed
Allow multiple arguments when calling an object.
1 parent 94e1f64 commit 66cf814

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static PyObject *object_call(ObjectData *self, PyObject *args, PyObject *kwds) {
5656
PyMem_Free(cstring);
5757
}
5858
}
59-
JSValue value = JS_Call(self->context, self->object, JS_NULL, 1, jsargs);
59+
JSValue value = JS_Call(self->context, self->object, JS_NULL, nargs, jsargs);
6060
for (int i = 0; i < nargs; ++i) {
6161
JS_FreeValue(self->context, jsargs[i]);
6262
}

test_quickjs.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,29 @@ def test_function_call_int(self):
6262
""")
6363
self.assertEqual(f(2), 42)
6464

65-
def test_function_call_str(self):
65+
def test_function_call_int_two_args(self):
6666
f = self.context.eval("""
67-
f = function(a) {
68-
return a + " hej";
67+
f = function(x, y) {
68+
return 40 + x + y;
6969
}
7070
""")
71-
self.assertEqual(f("1"), "1 hej")
71+
self.assertEqual(f(3, -1), 42)
72+
73+
# def test_function_call_str(self):
74+
# f = self.context.eval("""
75+
# f = function(a) {
76+
# return a + " hej";
77+
# }
78+
# """)
79+
# self.assertEqual(f("1"), "1 hej")
80+
81+
# def test_function_call_str_three_args(self):
82+
# f = self.context.eval("""
83+
# f = function(a, b, c) {
84+
# return a + " hej " + b + " ho " + c;
85+
# }
86+
# """)
87+
# self.assertEqual(f("1", "2", "3"), "1 hej 2 ho 3")
7288

7389
def test_function_call_unsupported_arg(self):
7490
f = self.context.eval("""

0 commit comments

Comments
 (0)