diff --git a/Stdlib/Data/Bool/Base.juvix b/Stdlib/Data/Bool/Base.juvix index 75fe8a63..0f0a1ceb 100644 --- a/Stdlib/Data/Bool/Base.juvix +++ b/Stdlib/Data/Bool/Base.juvix @@ -37,5 +37,11 @@ or (a b : Bool) : Bool := a || b; --- Logical conjunction. and (a b : Bool) : Bool := a && b; +--- Logical exclusive or. +xor : Bool -> Bool -> Bool + | true true := false + | false flase := false + | _ _ := true; + builtin assert assert (x : Bool) : Bool := x; diff --git a/test/Test/Prelude.juvix b/test/Test/Prelude.juvix index e0b65989..f2e451a1 100644 --- a/test/Test/Prelude.juvix +++ b/test/Test/Prelude.juvix @@ -4,7 +4,15 @@ import Test.JuvixUnit open; import Stdlib.Prelude open; tests : List Test := - [testCase "And" (assertEqual "and works as expected" (and true false) false)]; + [ + testCase "And" (assertEqual "and works as expected" (and true false) false); + testCase + "Xor" + (assertEqual "and works as expected" (xor true false) (xor false true)); + testCase + "Xor-2" + (assertEqual "and works as expected" (xor false false) (xor true true)); + ]; suite : TestSuite := testSuite "Prelude" tests;