Skip to content

Commit

Permalink
Elisp->Python conversion of bool
Browse files Browse the repository at this point in the history
  • Loading branch information
813gan committed Aug 15, 2024
1 parent ee024f1 commit d1360f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions emacspy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ cdef class EmacsValue:
return self.str()
elif my_type == "integer":
return self.int()
elif my_type == "symbol":
as_str = self.sym_str()
if as_str == "nil":
return False
elif as_str == "t":
return True
raise ValueError("Unable to export emacs value")

def __str__(self):
return _F().prin1_to_string(self).str()
Expand Down
7 changes: 6 additions & 1 deletion tests/test.el
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@

(ert-deftest ert-test-emacspy-data-bool ()
(should (eq 't (py-run-string "test" "True")))
(should (eq nil (py-run-string "test" "False"))) )
(should (eq nil (py-run-string "test" "False")))

(should (eq 't (py-get-global-variable
"test" (py-set-global "test" 't "test_bool"))))
(should (eq nil (py-get-global-variable
"test" (py-set-global "test" () "test_bool")))) )

(ert-deftest ert-test-emacspy-py-call-method ()
(should (string= "/" (py-call-method "test" "ospath" "realpath" nil "/")))
Expand Down

0 comments on commit d1360f6

Please sign in to comment.