Skip to content

Commit

Permalink
[MathNotaiton] Decode unsafe names of Z3Sorts
Browse files Browse the repository at this point in the history
  • Loading branch information
shingarov committed Nov 16, 2024
1 parent 5399529 commit 3e2b965
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 5 deletions.
54 changes: 54 additions & 0 deletions src/MathNotation-Tests/UnsafeZ3NameTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Class {
#name : #UnsafeZ3NameTest,
#superclass : #TestCaseWithZ3Context,
#category : #'MathNotation-Tests'
}

{ #category : #tests }
UnsafeZ3NameTest >> testIntName [
| Z |
Z := Int sort.
self assert: Z name isZ3Symbol.
self assert: Z name isStringSymbol.
self deny: Z name isIntSymbol.
self assert: Z name getString equals: 'Int' "NB: NOT 'ℤ'!!!"

]

{ #category : #tests }
UnsafeZ3NameTest >> testUnsafeEnum [
| fruit consts testers |
consts := Cell new.
testers := Cell new.
fruit := Z3DatatypeSort
mkEnumerationSort: 'rotten#fruit' encodeUnsafe
elements: { 'apple'. 'banana'. 'orange' }
consts: consts
testers: testers.
self assert: fruit name isZ3Symbol.
self assert: fruit name isStringSymbol.
self deny: fruit name isIntSymbol.
self assert: fruit name getString equals: 'rottenß35ßfruit'.
self assert: fruit unsafeName equals: 'rotten#fruit'

]

{ #category : #tests }
UnsafeZ3NameTest >> testUnsafeUninterpreted [
| s |
s := Z3Sort uninterpretedSortNamed: '(a b)' encodeUnsafe.
self assert: s name isZ3Symbol.
self assert: s name isStringSymbol.
self deny: s name isIntSymbol.
self assert: s name getString equals: 'ß40ßaß32ßbß41ß'.
self assert: s unsafeName equals: '(a b)'

]

{ #category : #tests }
UnsafeZ3NameTest >> testZahlenForInt [
| Z |
Z := Int sort.
self assert: Z unsafeName equals: ''

]
5 changes: 5 additions & 0 deletions src/MathNotation/Z3BoolSort.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ Extension { #name : #Z3BoolSort }

{ #category : #'*MathNotation' }
Z3BoolSort >> printString [
^self unsafeName
]

{ #category : #'*MathNotation' }
Z3BoolSort >> unsafeName [
^String with: (Character codePoint: 16r1D539)
]
11 changes: 11 additions & 0 deletions src/MathNotation/Z3DatatypeSort.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Extension { #name : #Z3DatatypeSort }

{ #category : #'*MathNotation' }
Z3DatatypeSort >> printString [
^self unsafeName
]

{ #category : #'*MathNotation' }
Z3DatatypeSort >> unsafeName [
^self name getString decodeUnsafe
]
5 changes: 5 additions & 0 deletions src/MathNotation/Z3IntSort.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ Extension { #name : #Z3IntSort }

{ #category : #'*MathNotation' }
Z3IntSort >> printString [
^self unsafeName
]

{ #category : #'*MathNotation' }
Z3IntSort >> unsafeName [
^String with: Character zahlen
]
11 changes: 11 additions & 0 deletions src/MathNotation/Z3RealSort.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Extension { #name : #Z3RealSort }

{ #category : #'*MathNotation' }
Z3RealSort >> printString [
^self unsafeName
]

{ #category : #'*MathNotation' }
Z3RealSort >> unsafeName [
^String with: Character reals
]
11 changes: 11 additions & 0 deletions src/MathNotation/Z3UninterpretedSort.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Extension { #name : #Z3UninterpretedSort }

{ #category : #'*MathNotation' }
Z3UninterpretedSort >> printOn: aStream [
aStream nextPutAll: self unsafeName
]

{ #category : #'*MathNotation' }
Z3UninterpretedSort >> unsafeName [
^self name asString decodeUnsafe
]
5 changes: 0 additions & 5 deletions src/Z3/Z3RealSort.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,3 @@ Z3RealSort >> nodeClass [
^ Real

]

{ #category : #printing }
Z3RealSort >> printString [
^String with: Character reals
]

0 comments on commit 3e2b965

Please sign in to comment.