Skip to content

Commit

Permalink
Introduce Z3DatatypeTest
Browse files Browse the repository at this point in the history
  • Loading branch information
shingarov committed Sep 11, 2024
1 parent 58d55fb commit 90d4b36
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/Z3-Tests/Z3DatatypeTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"
These tests correspond to L8uniqueVoid.smt2 on our experiment-z3datatypes
branch of liquid-fixpoint, see dbd390e:
https://github.com/shingarov/liquid-fixpoint/commit/dbd390e323a96f5c973c5bd6285a10b066340b0b
at the lowest (SMT) level of the test-ladder, cf:
https://github.com/shingarov/sprite-lang/commit/248f59b7758befa7a812b1981b43999a8c45adb6
"
Class {
#name : #Z3DatatypeTest,
#superclass : #TestCase,
#category : #'Z3-Tests-ADT'
}

{ #category : #running }
Z3DatatypeTest >> testUniqueVoid [
| V x y |
V := Z3Datatype named: 'V'.
V declare: 'Nil'.
V := V create.
x := V mkConst: 'x'.
y := V mkConst: 'y'.
self assert: (x===y) isValid
]

{ #category : #running }
Z3DatatypeTest >> testUniqueVoidNeg [
| V x y solver model xConsName yConsName |
V := Z3Datatype named: 'V'.
V declare: 'One'.
V declare: 'Two'.
V := V create.
x := V mkConst: 'x'.
y := V mkConst: 'y'.
"exactly two counterexamples"
solver := Z3Solver new.
model := (solver findCounterexample: x===y) constants.
xConsName := (model at: 'x') functorName.
yConsName := (model at: 'y') functorName.
self assert: (xConsName='One' and: yConsName='Two')
| (yConsName='One' and: xConsName='Two')
]

0 comments on commit 90d4b36

Please sign in to comment.