diff options
Diffstat (limited to 'src/sexp/step.rs')
-rw-r--r-- | src/sexp/step.rs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/src/sexp/step.rs b/src/sexp/step.rs index ee76ebf..bb3ada5 100644 --- a/src/sexp/step.rs +++ b/src/sexp/step.rs @@ -44,6 +44,7 @@ impl SExp { /// ``` /// /// Also, addition and multiplication can take more than two arguments: + /// (as of 2025-08-05 not allowed by the type system, might change) /// ```rust /// use myslip::sexp::{SExp::*, SLeaf::*, util::*}; /// @@ -84,6 +85,119 @@ impl SExp { /// /// ``` /// + /// **Integer comparisons** + /// + /// ```rust + /// use myslip::sexp::{SExp::*, SLeaf::*, util::*}; + /// + /// assert_eq!( + /// scons(Lt, scons(1, scons(2, Nil))).step(), + /// Ok(Atom(True)) + /// ); + /// assert_eq!( + /// scons(Lt, scons(2, scons(2, Nil))).step(), + /// Ok(Atom(False)) + /// ); + /// + /// assert_eq!( + /// scons(Gt, scons(2, scons(1, Nil))).step(), + /// Ok(Atom(True)) + /// ); + /// assert_eq!( + /// scons(Lt, scons(1, scons(1, Nil))).step(), + /// Ok(Atom(False)) + /// ); + /// + /// assert_eq!( + /// scons(Le, scons(1, scons(2, Nil))).step(), + /// Ok(Atom(True)) + /// ); + /// assert_eq!( + /// scons(Le, scons(2, scons(2, Nil))).step(), + /// Ok(Atom(True)) + /// ); + /// assert_eq!( + /// scons(Lt, scons(2, scons(1, Nil))).step(), + /// Ok(Atom(False)) + /// ); + /// + /// assert_eq!( + /// scons(Ge, scons(2, scons(1, Nil))).step(), + /// Ok(Atom(True)) + /// ); + /// assert_eq!( + /// scons(Ge, scons(1, scons(1, Nil))).step(), + /// Ok(Atom(True)) + /// ); + /// assert_eq!( + /// scons(Lt, scons(1, scons(2, Nil))).step(), + /// Ok(Atom(False)) + /// ); + /// + /// assert_eq!( + /// scons(Eq, scons(1, scons(2, Nil))).step(), + /// Ok(Atom(False)) + /// ); + /// assert_eq!( + /// scons(Eq, scons(2, scons(2, Nil))).step(), + /// Ok(Atom(True)) + /// ); + /// + /// assert_eq!( + /// scons(Neq, scons(1, scons(2, Nil))).step(), + /// Ok(Atom(True)) + /// ); + /// assert_eq!( + /// scons(Neq, scons(2, scons(2, Nil))).step(), + /// Ok(Atom(False)) + /// ); + /// ``` + /// + /// **Boolean expressions** + /// + /// ```rust + /// use myslip::sexp::{SExp::*, SLeaf::*, util::*}; + /// assert_eq!( + /// scons(And, scons(True, scons(True, Nil))).step(), + /// Ok(Atom(True)) + /// ); + /// assert_eq!( + /// scons(And, scons(False, scons(True, Nil))).step(), + /// Ok(Atom(False)) + /// ); + /// + /// assert_eq!( + /// scons(Or, scons(False, scons(True, Nil))).step(), + /// Ok(Atom(True)) + /// ); + /// assert_eq!( + /// scons(Or, scons(False, scons(False, Nil))).step(), + /// Ok(Atom(False)) + /// ); + /// + /// assert_eq!( + /// scons(Xor, scons(False, scons(True, Nil))).step(), + /// Ok(Atom(True)) + /// ); + /// assert_eq!( + /// scons(Xor, scons(False, scons(False, Nil))).step(), + /// Ok(Atom(False)) + /// ); + /// assert_eq!( + /// scons(Xor, scons(True, scons(True, Nil))).step(), + /// Ok(Atom(False)) + /// ); + /// + /// assert_eq!( + /// scons(Not, scons(True, Nil)).step(), + /// Ok(Atom(False)) + /// ); + /// assert_eq!( + /// scons(Not, scons(False, Nil)).step(), + /// Ok(Atom(True)) + /// ); + /// ``` + /// /// **Quotes** /// If an s-expression should not be evaluated /// as a function, but it is instead to be treated |