Nicolas Cellier uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-nice.268.mcz ==================== Summary ==================== Name: CollectionsTests-nice.268 Author: nice Time: 21 September 2016, 9:46:42.419239 pm UUID: 13ee237c-8a1d-46b4-870c-86fcb2aaddbd Ancestors: CollectionsTests-pre.267 Provide some tests for half-word, word and double-word arrays (positive 16, 32 and 64 bits integer elements). At time of writing, half and double words require VM improvments. =============== Diff against CollectionsTests-pre.267 =============== Item was added: + ClassTestCase subclass: #DoubleWordArrayTest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'CollectionsTests-Arrayed'! + + !DoubleWordArrayTest commentStamp: 'nice 9/21/2016 21:09' prior: 0! + DoubleWordArrayTest are SUnit tests for DoubleWordArray. + ! Item was added: + ----- Method: DoubleWordArrayTest>>testByteSize (in category 'testing') ----- + testByteSize + self assert: (DoubleWordArray new: 1) byteSize = 8 "8 bytes are 64 bits"! Item was added: + ----- Method: DoubleWordArrayTest>>testCannotPutNegativeValue (in category 'testing') ----- + testCannotPutNegativeValue + self should: [DoubleWordArray with: -1] raise: Error! Item was added: + ----- Method: DoubleWordArrayTest>>testCannotPutTooLargeValue (in category 'testing') ----- + testCannotPutTooLargeValue + | maxValue | + maxValue := 1 << 64 - 1. + self assert: (DoubleWordArray with: maxValue) first = maxValue. + self should: [DoubleWordArray with: maxValue + 1] raise: Error! Item was added: + ----- Method: DoubleWordArrayTest>>testElementSize (in category 'testing') ----- + testElementSize + self assert: DoubleWordArray new bytesPerElement = 8 "8 bytes are 64 bits"! Item was added: + ----- Method: DoubleWordArrayTest>>testSomeValues (in category 'testing') ----- + testSomeValues + | dwArray int next | + next := [:x | x - 3 * x sqrtFloor + 5]. + int := 0. + dwArray := DoubleWordArray new: 1. + [int highBit < 64] + whileTrue: + [dwArray at: 1 put: int. + self assert: (dwArray at: 1) = int. + int := next value: int]. + self should: [dwArray at: 1 put: int] raise: Error! Item was added: + ClassTestCase subclass: #HalfWordArrayTest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'CollectionsTests-Arrayed'! + + !HalfWordArrayTest commentStamp: 'nice 9/21/2016 21:08' prior: 0! + HalfWordArrayTest are SUnit tests for HalfWordArray. + ! Item was added: + ----- Method: HalfWordArrayTest>>testAllPossibleValues (in category 'testing') ----- + testAllPossibleValues + | halfWordArray | + halfWordArray := (1 to: 65535) as: HalfWordArray. + 1 to: halfWordArray size do: [:i | + self assert: (halfWordArray at: i) = i]! Item was added: + ----- Method: HalfWordArrayTest>>testByteSize (in category 'testing') ----- + testByteSize + self assert: (HalfWordArray new: 1) byteSize = 2 "2 bytes are 16 bits"! Item was added: + ----- Method: HalfWordArrayTest>>testCannotPutNegativeValue (in category 'testing') ----- + testCannotPutNegativeValue + self should: [HalfWordArray with: -1] raise: Error! Item was added: + ----- Method: HalfWordArrayTest>>testCannotPutTooLargeValue (in category 'testing') ----- + testCannotPutTooLargeValue + | maxValue | + maxValue := 1 << 16 - 1. + self assert: (HalfWordArray with: maxValue) first = maxValue. + self should: [HalfWordArray with: maxValue + 1] raise: Error! Item was added: + ----- Method: HalfWordArrayTest>>testElementSize (in category 'testing') ----- + testElementSize + self assert: HalfWordArray new bytesPerElement = 2 "2 bytes are 16 bits"! Item was added: + ClassTestCase subclass: #WordArrayTest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'CollectionsTests-Arrayed'! Item was added: + ----- Method: WordArrayTest>>testByteSize (in category 'testing') ----- + testByteSize + self assert: (WordArray new: 1) byteSize = 4 "4 bytes are 32 bits"! Item was added: + ----- Method: WordArrayTest>>testCannotPutNegativeValue (in category 'testing') ----- + testCannotPutNegativeValue + self should: [WordArray with: -1] raise: Error! Item was added: + ----- Method: WordArrayTest>>testCannotPutTooLargeValue (in category 'testing') ----- + testCannotPutTooLargeValue + | maxValue | + maxValue := 1 << 32 - 1. + self assert: (WordArray with: maxValue) first = maxValue. + self should: [WordArray with: maxValue + 1] raise: Error! Item was added: + ----- Method: WordArrayTest>>testElementSize (in category 'testing') ----- + testElementSize + self assert: WordArray new bytesPerElement = 4 "4 bytes are 32 bits"! Item was added: + ----- Method: WordArrayTest>>testSomeValues (in category 'testing') ----- + testSomeValues + | wArray int next | + next := [:x | x - 3 * x sqrtFloor + 5]. + int := 0. + wArray := WordArray new: 1. + [int highBit < 32] + whileTrue: + [wArray at: 1 put: int. + self assert: (wArray at: 1) = int. + int := next value: int]. + self should: [wArray at: 1 put: int] raise: Error! |
Free forum by Nabble | Edit this page |