-
Notifications
You must be signed in to change notification settings - Fork 11
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
Showing
4 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
70 changes: 70 additions & 0 deletions
70
tests/baseline_compat/hyperon-mettalog_sanity/subtraction_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,70 @@ | ||
;; Test basic subtraction functionality | ||
;; This checks that subtracting (b c) from (a b c d) correctly returns (a d). | ||
!(assertEqual | ||
(subtract (superpose (a b c d)) (superpose (b c))) | ||
(superpose (a d)) | ||
) | ||
|
||
;; Test subtraction with multiple subsequent lists | ||
;; Here, subtracting (b c) and (d) from (a b c d) should result in (a). | ||
!(assertEqual | ||
(subtract (superpose (a b c d)) (superpose (b c)) (superpose (d))) | ||
(superpose (a)) | ||
) | ||
|
||
;; Test subtraction with nested structures | ||
;; This test ensures that nested elements like (foo (bar baz)) are handled correctly. | ||
!(assertEqual | ||
(subtract (superpose ((foo bar) (bar baz) qux)) (superpose ((bar baz) qux))) | ||
(superpose ((foo bar))) | ||
) | ||
|
||
;; Test subtraction with mixed types | ||
;; This checks that the function handles lists with symbols, numbers, and mixed content. | ||
!(assertEqual | ||
(subtract (superpose (1 2 3 foo bar)) (superpose (2 foo))) | ||
(superpose (1 3 bar)) | ||
) | ||
|
||
;; Test subtraction with duplicates | ||
;; This test ensures that duplicates are treated correctly. | ||
!(assertEqual | ||
(subtract (superpose (a b b c d)) (superpose (b c))) | ||
(superpose (a b d)) | ||
) | ||
|
||
;; Test subtraction with `unique` applied outside | ||
;; In this case, `unique` is applied after the subtraction, removing duplicates. | ||
!(assertEqual | ||
(unique (subtract (superpose (a b b c)) (superpose (b c c d)))) | ||
(superpose (a)) | ||
) | ||
|
||
;; Test subtraction with `unique` applied inside | ||
;; In this test, `unique` is applied to each input set before performing the subtraction. | ||
!(assertEqual | ||
(subtract (unique (superpose (a b b c))) (unique (superpose (b c c d)))) | ||
(superpose (a)) | ||
) | ||
|
||
;; Test variable substitution during subtraction | ||
;; This ensures that variables can be used and are properly instantiated during the operation. | ||
!(assertEqual | ||
(subtract (superpose ($x $y)) (superpose (b))) | ||
(superpose ($x $y)) | ||
) | ||
|
||
;; Test subtraction with empty lists | ||
;; Subtracting an empty list should return the original list. | ||
!(assertEqual | ||
(subtract (superpose (a b c)) (superpose ())) | ||
(superpose (a b c)) | ||
) | ||
|
||
;; Test subtraction with variables and nested structures | ||
;; This checks how variables interact with nested lists during subtraction. | ||
!(assertEqual | ||
(subtract (superpose ((foo ?x) (bar $y))) (superpose ((bar $y) (foo qux)))) | ||
(superpose ((foo ?x))) | ||
) | ||
|