Marcel Taeumel uploaded a new version of FFI-Tests to project FFI:
http://source.squeak.org/FFI/FFI-Tests-mt.36.mcz ==================== Summary ==================== Name: FFI-Tests-mt.36 Author: mt Time: 15 May 2021, 7:04:54.637008 pm UUID: ee0e3f05-aef0-6a43-9514-cd18cdef0092 Ancestors: FFI-Tests-mt.35 Complements FFI-Kernel-mt.149 =============== Diff against FFI-Tests-mt.35 =============== Item was changed: ----- Method: ExternalTypeTests>>testAtomicTypeRange (in category 'tests - atomic types') ----- testAtomicTypeRange "Tests the range of non-integer and non-float types. Includes char types because those look different in Smalltalk." self should: [ExternalType void minVal] raise: Error. self should: [ExternalType void maxVal] raise: Error. self should: [ExternalType bool minVal] raise: Error. self should: [ExternalType bool maxVal] raise: Error. + self should: [ExternalType char "unsignedChar" minVal] raise: Error. + self should: [ExternalType char "unsignedChar" maxVal] raise: Error. + + self should: [ExternalType signedChar "schar" minVal] raise: Error. + self should: [ExternalType signedChar "schar" maxVal] raise: Error. - self assert: Character null equals: ExternalType char "unsignedChar" minVal. - self assert: (Character value: 255) equals: ExternalType char "unsignedChar" maxVal. - self assert: (Character value: 128) equals: ExternalType signedChar "schar" minVal. - self assert: (Character value: 127) equals: ExternalType signedChar "schar" maxVal. ! Item was added: + ----- Method: ExternalTypeTests>>testIntegerNotCharType (in category 'tests - atomic integer types') ----- + testIntegerNotCharType + + #( signedChar unsignedChar ) do: [:typeName | + | type | + type := ExternalType typeNamed: typeName. + self deny: type isIntegerType].! Item was added: + ----- Method: FFIAllocateExternalTests>>test10ArrayClasses (in category 'tests - array') ----- + test10ArrayClasses + "Array classes do not apply to external allocation."! Item was added: + ----- Method: FFIAllocateTests>>performTest (in category 'running') ----- + performTest + "Tests should opt-in to have more control." + + | prior | + prior := ExternalType useArrayClasses. + [ExternalType useArrayClasses: false. + super performTest] + ensure: [ExternalType useArrayClasses: prior].! Item was added: + ----- Method: FFIAllocateTests>>test10ArrayClasses (in category 'tests - array') ----- + test10ArrayClasses + "For integer and float types, allocate arrays and check for specific array classes. Then construct a conventional byte array for an external data structure. A copy should also convert into a specific array class with the same contents." + + ExternalType useArrayClassesDuring: [ + + ExternalType atomicTypes do: [:contentType | + (contentType isIntegerType + or: [contentType isFloatType] + or: [contentType isCharType]) ifTrue: [ + | array arrayType data copy | + array := self allocate: contentType size: 5. + arrayType := array externalType. + + self assert: array isArray. + self assert: 5 equals: array size. + self assert: array byteSize equals: arrayType byteSize. + + contentType = ExternalType signedChar ifFalse: [ + self flag: #discuss. "mt: What is signedChar even for?" + self assert: contentType equals: array contentType]. + + self deny: array isNull. + self deny: (array isKindOf: ExternalData). + self assert: array equals: array getHandle. + + self shouldnt: [array at: 1 put: contentType allocate] raise: Error. + self shouldnt: [array zeroMemory] raise: Error. + self should: [array setContentType: ExternalType byte] raise: Error. + self should: [array setSize: 42] raise: Error. + + data := ExternalData + fromHandle: (ByteArray new: arrayType byteSize) + type: arrayType. + copy := data copy. "From external data into raw-bits array." + self deny: array equals: data. + self assert: array equals: copy. ]]].! |
Free forum by Nabble | Edit this page |