FFI: FFI-Tests-mt.19.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FFI: FFI-Tests-mt.19.mcz

commits-2
Marcel Taeumel uploaded a new version of FFI-Tests to project FFI:
http://source.squeak.org/FFI/FFI-Tests-mt.19.mcz

==================== Summary ====================

Name: FFI-Tests-mt.19
Author: mt
Time: 17 June 2020, 11:48:14.239028 am
UUID: 5b5f9c13-eb5c-2f45-8ecb-240a1dab2993
Ancestors: FFI-Tests-mt.18

Adds tests for ExternalType. Complements FFI-Kernel-mt.110.

=============== Diff against FFI-Tests-mt.18 ===============

Item was added:
+ TestCase subclass: #ExternalTypeTests
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: 'ExternalType'
+ category: 'FFI-Tests'!

Item was added:
+ ----- Method: ExternalTypeTests>>testAtomicType (in category 'tests') -----
+ testAtomicType
+
+ AtomicTypes keysAndValuesDo: [:typeName :type |
+ self
+ assert: type isAtomic;
+ assert: typeName equals: type atomicTypeName;
+
+ deny: type isPointerType;
+ deny: type isStructureType;
+ deny: type isTypeAlias].!

Item was added:
+ ----- Method: ExternalTypeTests>>testAtomicTypeByName (in category 'tests') -----
+ testAtomicTypeByName
+
+ AtomicTypeNames do: [:typeName |
+ self
+ assert: (AtomicTypes at: typeName)
+ identical: (ExternalType typeNamed: typeName);
+ assert: (AtomicTypes at: typeName)
+ identical: (ExternalType atomicTypeNamed: typeName)].!

Item was added:
+ ----- Method: ExternalTypeTests>>testAtomicTypeBySelector (in category 'tests') -----
+ testAtomicTypeBySelector
+
+ AtomicTypeNames do: [:typeName |
+ self
+ assert: (AtomicTypes at: typeName)
+ identical: (ExternalType perform: typeName asSymbol)].!

Item was added:
+ ----- Method: ExternalTypeTests>>testIntegerPointerTypes (in category 'tests') -----
+ testIntegerPointerTypes
+
+ | wordSize |
+ wordSize := FFIPlatformDescription current wordSize.
+
+ #(size_t ptrdiff_t uintptr_t intptr_t) do: [:typeName |
+ | type |
+ type := ExternalType typeNamed: typeName.
+ self
+ assert: type isIntegerType;
+ assert: wordSize equals: type byteSize].!

Item was added:
+ ----- Method: ExternalTypeTests>>testIntegerTypes (in category 'tests') -----
+ testIntegerTypes
+
+ #(
+ uint8_t 1 int8_t 1
+ uint16_t 2 int16_t 2
+ uint32_t 4 int32_t 4
+ uint64_t 8 int64_t 8
+ ) pairsDo: [:typeName :byteSize |
+ | type |
+ type := ExternalType typeNamed: typeName.
+ self
+ assert: type isIntegerType;
+ assert: byteSize equals: type byteSize].!

Item was added:
+ ----- Method: ExternalTypeTests>>testSignFloatTypes (in category 'tests') -----
+ testSignFloatTypes
+
+ self
+ should: [ExternalType float isSigned] raise: Error;
+ should: [ExternalType float isUnsigned] raise: Error;
+ should: [ExternalType float asSigned] raise: Error;
+ should: [ExternalType float asUnsigned] raise: Error;
+ should: [ExternalType double isSigned] raise: Error;
+ should: [ExternalType double isUnsigned] raise: Error;
+ should: [ExternalType double asSigned] raise: Error;
+ should: [ExternalType double asUnsigned] raise: Error.!

Item was added:
+ ----- Method: ExternalTypeTests>>testSignIntegerTypes (in category 'tests') -----
+ testSignIntegerTypes
+
+ AtomicTypeNames do: [:typeName |
+ | type |
+ type := ExternalType atomicTypeNamed: typeName.
+ self
+ assert: type isIntegerType ==> [
+ (type isSigned and: [type asUnsigned isUnsigned])
+ or: [type isUnsigned and: [type asSigned isSigned]]]].!