Skip to content

Commit dd7126f

Browse files
committed
test: write tests for unwrapping functions to their original language
1 parent 88765ae commit dd7126f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/python/test_pythonmonkey_eval.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,18 @@ def fn0(n):
246246
assert 101.9 == pm.eval("(fn1, x) => { return fn1()(x) }")(fn1, 1.9)
247247
assert 101.9 == pm.eval("(fn1) => { return fn1() }")(fn1)(1.9)
248248

249+
def test_unwrap_py_function():
250+
# https://github.com/Distributive-Network/PythonMonkey/issues/65
251+
def pyFunc():
252+
pass
253+
unwrappedPyFunc = pm.eval("(wrappedPyFunc) => { return wrappedPyFunc }")(pyFunc)
254+
assert unwrappedPyFunc is pyFunc
255+
256+
def test_unwrap_js_function():
257+
# https://github.com/Distributive-Network/PythonMonkey/issues/65
258+
wrappedJSFunc = pm.eval("const JSFunc = () => { return 0 }\nJSFunc")
259+
assert pm.eval("(unwrappedJSFunc) => { return unwrappedJSFunc === JSFunc }")(wrappedJSFunc)
260+
249261
def test_eval_functions_pyfunctions_ints():
250262
caller = pm.eval("(func, param1, param2) => { return func(param1, param2) }")
251263
def add(a, b):

0 commit comments

Comments
 (0)