Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
This adds another test case, and fixes a minor issue with the memory
example.
  • Loading branch information
DavePearce committed Dec 13, 2024
1 parent 404a7eb commit 858a490
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/corset/stdlib.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,13 @@
(defpurefun (stamp-constancy STAMP C)
(if (will-remain-constant! STAMP)
(will-remain-constant! C)))

;; =============================================================================
;; Add
;; =============================================================================
(defpurefun (if-not-eq X Y then)
(if (eq! X Y)
;; True branch
(vanishes! 0)
;; False branch
then))
4 changes: 4 additions & 0 deletions pkg/test/valid_corset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ func Test_If_09(t *testing.T) {
Check(t, false, "if_09")
}

func Test_If_10(t *testing.T) {
Check(t, false, "if_10")
}

// ===================================================================
// Guards
// ===================================================================
Expand Down
36 changes: 36 additions & 0 deletions testdata/if_10.accepts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{ "X": [], "Y": [], "A": [] }
;;
{ "X": [0], "Y": [0], "A": [0] }
{ "X": [0], "Y": [1], "A": [0] }
{ "X": [1], "Y": [0], "A": [0] }
{ "X": [1], "Y": [1], "A": [0] }
{ "X": [1], "Y": [0], "A": [1] }
;;
{ "X": [0,0], "Y": [0,0], "A": [0,0] }
{ "X": [0,0], "Y": [0,1], "A": [0,0] }
{ "X": [0,1], "Y": [0,0], "A": [0,0] }
{ "X": [0,1], "Y": [0,1], "A": [0,0] }
{ "X": [1,0], "Y": [0,0], "A": [0,0] }
{ "X": [1,0], "Y": [0,1], "A": [0,0] }
{ "X": [1,1], "Y": [0,0], "A": [0,0] }
{ "X": [1,1], "Y": [0,1], "A": [0,0] }
{ "X": [0,0], "Y": [1,0], "A": [0,0] }
{ "X": [0,0], "Y": [1,1], "A": [0,0] }
{ "X": [0,1], "Y": [1,0], "A": [0,0] }
{ "X": [0,1], "Y": [1,1], "A": [0,0] }
{ "X": [1,0], "Y": [1,0], "A": [0,0] }
{ "X": [1,0], "Y": [1,1], "A": [0,0] }
{ "X": [1,1], "Y": [1,0], "A": [0,0] }
{ "X": [1,1], "Y": [1,1], "A": [0,0] }
;;
{ "X": [0,1], "Y": [0,0], "A": [0,1] }
{ "X": [1,1], "Y": [0,0], "A": [0,1] }
{ "X": [0,1], "Y": [1,0], "A": [0,1] }
{ "X": [1,1], "Y": [1,0], "A": [0,1] }
;;
{ "X": [1,0], "Y": [0,0], "A": [1,0] }
{ "X": [1,0], "Y": [0,1], "A": [1,0] }
{ "X": [1,1], "Y": [0,0], "A": [1,0] }
{ "X": [1,1], "Y": [0,1], "A": [1,0] }
;;
{ "X": [1,1], "Y": [0,0], "A": [1,1] }
5 changes: 5 additions & 0 deletions testdata/if_10.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(defpurefun ((vanishes! :@loob) x) x)

(defcolumns (X :binary@loob) (Y :binary@bool) A)
(defconstraint c1 () (if X (vanishes! A)))
(defconstraint c2 () (if Y (vanishes! A)))
45 changes: 45 additions & 0 deletions testdata/if_10.rejects
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{ "X": [0], "Y": [0], "A": [1] }
{ "X": [0], "Y": [1], "A": [1] }
{ "X": [1], "Y": [1], "A": [1] }
;;
{ "X": [0,0], "Y": [0,0], "A": [0,1] }
{ "X": [0,0], "Y": [0,1], "A": [0,1] }
{ "X": [0,1], "Y": [0,1], "A": [0,1] }
{ "X": [1,0], "Y": [0,0], "A": [0,1] }
{ "X": [1,0], "Y": [0,1], "A": [0,1] }
{ "X": [1,1], "Y": [0,1], "A": [0,1] }
{ "X": [0,0], "Y": [1,0], "A": [0,1] }
{ "X": [0,0], "Y": [1,1], "A": [0,1] }
{ "X": [0,1], "Y": [1,1], "A": [0,1] }
{ "X": [1,0], "Y": [1,0], "A": [0,1] }
{ "X": [1,0], "Y": [1,1], "A": [0,1] }
{ "X": [1,1], "Y": [1,1], "A": [0,1] }
;;
{ "X": [0,0], "Y": [0,0], "A": [1,0] }
{ "X": [0,0], "Y": [0,1], "A": [1,0] }
{ "X": [0,1], "Y": [0,0], "A": [1,0] }
{ "X": [0,1], "Y": [0,1], "A": [1,0] }
{ "X": [0,0], "Y": [1,0], "A": [1,0] }
{ "X": [0,0], "Y": [1,1], "A": [1,0] }
{ "X": [0,1], "Y": [1,0], "A": [1,0] }
{ "X": [0,1], "Y": [1,1], "A": [1,0] }
{ "X": [1,0], "Y": [1,0], "A": [1,0] }
{ "X": [1,0], "Y": [1,1], "A": [1,0] }
{ "X": [1,1], "Y": [1,0], "A": [1,0] }
{ "X": [1,1], "Y": [1,1], "A": [1,0] }
;;
{ "X": [0,0], "Y": [0,0], "A": [1,1] }
{ "X": [0,0], "Y": [0,1], "A": [1,1] }
{ "X": [0,1], "Y": [0,0], "A": [1,1] }
{ "X": [0,1], "Y": [0,1], "A": [1,1] }
{ "X": [1,0], "Y": [0,0], "A": [1,1] }
{ "X": [1,0], "Y": [0,1], "A": [1,1] }
{ "X": [1,1], "Y": [0,1], "A": [1,1] }
{ "X": [0,0], "Y": [1,0], "A": [1,1] }
{ "X": [0,0], "Y": [1,1], "A": [1,1] }
{ "X": [0,1], "Y": [1,0], "A": [1,1] }
{ "X": [0,1], "Y": [1,1], "A": [1,1] }
{ "X": [1,0], "Y": [1,0], "A": [1,1] }
{ "X": [1,0], "Y": [1,1], "A": [1,1] }
{ "X": [1,1], "Y": [1,0], "A": [1,1] }
{ "X": [1,1], "Y": [1,1], "A": [1,1] }

0 comments on commit 858a490

Please sign in to comment.