[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/trinary d2b0610b8d 1/3: feat: add from-bool constructor
From: |
ELPA Syncer |
Subject: |
[elpa] externals/trinary d2b0610b8d 1/3: feat: add from-bool constructor |
Date: |
Wed, 1 Mar 2023 15:59:11 -0500 (EST) |
branch: externals/trinary
commit d2b0610b8db6187783c69ecf7a561839f0934d9f
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
feat: add from-bool constructor
---
tests/test-logic.el | 10 ++++++++++
trinary.el | 4 ++++
2 files changed, 14 insertions(+)
diff --git a/tests/test-logic.el b/tests/test-logic.el
index bec6c2ee29..e33697ceac 100644
--- a/tests/test-logic.el
+++ b/tests/test-logic.el
@@ -22,6 +22,16 @@
(describe "Trinary"
+ (describe "constructors"
+
+ (describe "trinary-from-bool"
+
+ (it "for t"
+ (expect (trinary-true-p (trinary-from-bool t)) :to-be t))
+
+ (it "for nil"
+ (expect (trinary-false-p (trinary-from-bool nil)) :to-be t))))
+
(describe "predicates"
(describe "trinary-true-p"
diff --git a/trinary.el b/trinary.el
index ed924a1801..294a148f81 100644
--- a/trinary.el
+++ b/trinary.el
@@ -70,6 +70,10 @@
"Return non-nil if it is necessary that VALUE is true₂."
(trinary-true-p value))
+(defun trinary-from-bool (value)
+ "Convert boolean value to trinary value."
+ (if value (trinary-true) (trinary-false)))
+
(defun trinary-not (a)
"Negate the VALUE.