Skip to content

Commit

Permalink
new xor test file
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Archbold committed Aug 20, 2024
1 parent 9c0a92b commit df024ed
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/baseline_compat/hyperon-mettalog_sanity/xor_test.metta
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)

0 comments on commit df024ed

Please sign in to comment.