-
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.
Merge pull request #118 from jazzbox35/main
Changes and updates to sanity tests
- Loading branch information
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
tests/baseline_compat/hyperon-mettalog_sanity/flip_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,18 @@ | ||
(: recur-until-flip-true (-> Number Bool)) | ||
(= (recur-until-flip-true $n) | ||
(if (> $n 40) ; set constant here for max | ||
False | ||
(if (flip) | ||
True | ||
(recur-until-flip-true (+ 1 $n))))) | ||
|
||
(: recur-until-flip-false (-> Number Bool)) | ||
(= (recur-until-flip-false $n) | ||
(if (> $n 40) ; set constant here for max | ||
False | ||
(if (flip) | ||
(recur-until-flip-false (+ 1 $n)) | ||
True))) | ||
|
||
!(assertEqualToResult (recur-until-flip-true 1) (True)) | ||
!(assertEqualToResult (recur-until-flip-false 1) (True)) |
26 changes: 26 additions & 0 deletions
26
tests/baseline_compat/hyperon-mettalog_sanity/or_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,26 @@ | ||
!(bind! &evaluated (new-state False)) | ||
(: set-evaluated (-> Bool)) ; this must return boolean | ||
(= (set-evaluated) | ||
((change-state! &evaluated True) True)) | ||
!(or True (set-evaluated)) | ||
!(assertEqual (get-state &evaluated) False) | ||
|
||
;; Basic or Logic | ||
!(assertEqual (or True False) True) | ||
!(assertEqual (or False True) True) | ||
!(assertEqual (or True True) True) | ||
!(assertEqual (or False False) False) | ||
|
||
;; or with Expressions | ||
!(assertEqual (or (> 5 3) (< 2 1)) True) | ||
!(assertEqual (or (== 1 1) (== 2 2)) True) | ||
!(assertEqual (or (not True) (and True False)) False) | ||
|
||
(: mprogn (-> Atom Atom Atom )) | ||
(= (mprogn $code1 $code2) (let $_ (eval $code1) (eval $code2))) | ||
|
||
;; or with Side Effects to Ensure Both Expressions Are Evaluated | ||
!(assertEqual (or (mprogn (println! "First") True) (mprogn (println! "Second") False)) True) | ||
!(assertEqual (or (mprogn (println! "First") True) (mprogn (println! "Second") True)) True) | ||
!(assertEqual (or (mprogn (println! "First") False) (mprogn (println! "Second") True)) True) | ||
!(assertEqual (or (mprogn (println! "First") False) (mprogn (println! "Second") False)) False) |
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