Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a (crashing) test that calls an ffi-function from a callback #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
(ert-deftest ffi-add ()
(should (eq (test-add 23 -23) 0)))

(defun callback-with-ffi-add-call (arg)
(test-add 1 arg)
)

(ert-deftest ffi-call-callback-with-ffi-add-call ()
(let* ((cif (ffi--prep-cif :int [:int]))
(pointer-to-callback (ffi-make-closure cif #'callback-with-ffi-add-call)))
(should (eq (test-call-callback pointer-to-callback) "hello"))))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is strange here, because test-call-callback is going to return an integer, but this test is checking to see if it is eq to a string -- which can't happen.

When I change this to expect 23, it works locally.

I wouldn't doubt that there is a problem -- that issue you pointed at has never been fixed -- but I think some other test case is required to show it.


(ert-deftest ffi-struct-layout ()
(let ((struct-type (ffi--define-struct :int)))
(should (eq (ffi--type-size struct-type)
Expand Down