Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MathNotaiton] Decode unsafe names of Z3Sorts #387

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
]
Loading