-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mike Archbold
committed
Aug 20, 2024
1 parent
9c0a92b
commit df024ed
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
tests/baseline_compat/hyperon-mettalog_sanity/xor_test.metta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
;; Basic XOR Logic | ||
!(assertEqual (xor True False) True) | ||
!(assertEqual (xor False True) True) | ||
!(assertEqual (xor True True) False) | ||
!(assertEqual (xor False False) False) | ||
|
||
;; XOR with Expressions | ||
!(assertEqual (xor (> 5 3) (< 2 1)) True) | ||
!(assertEqual (xor (== 1 1) (== 2 2)) False) | ||
!(assertEqual (xor (not True) (and True False)) False) | ||
|
||
(: mprogn (-> Atom Atom Atom )) | ||
(= (mprogn $code1 $code2) (let $_ (eval $code1) (eval $code2))) | ||
|
||
;; XOR with Side Effects to Ensure Both Expressions Are Evaluated | ||
!(assertEqual (xor (mprogn (println! "First") True) (mprogn (println! "Second") False)) True) | ||
!(assertEqual (xor (mprogn (println! "First") True) (mprogn (println! "Second") True)) False) | ||
!(assertEqual (xor (mprogn (println! "First") False) (mprogn (println! "Second") True)) True) | ||
!(assertEqual (xor (mprogn (println! "First") False) (mprogn (println! "Second") False)) False) |