Nicolas Cellier uploaded a new version of CollectionsTests to project The Inbox:
http://source.squeak.org/inbox/CollectionsTests-nice.338.mcz ==================== Summary ==================== Name: CollectionsTests-nice.338 Author: nice Time: 2 May 2020, 12:46:51.581176 am UUID: 9860b2e2-750f-da40-a73f-4332c3facd4f Ancestors: CollectionsTests-mt.337 Introduce tests for Float64Array =============== Diff against CollectionsTests-mt.337 =============== Item was added: + ClassTestCase subclass: #Float64ArrayTest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'CollectionsTests-Arrayed'! + + !Float64ArrayTest commentStamp: 'nice 5/30/2006 01:24' prior: 0! + These tests are used to assert that Float64ArrayPlugin has same results as Float asIEEE32BitWord! Item was added: + ----- Method: Float64ArrayTest>>testArithmeticCoercion (in category 'tests') ----- + testArithmeticCoercion + + self should: [3.5 / (Float64Array with: 2.0) = (Float64Array with: 1.75)]. + self should: [3.5 * (Float64Array with: 2.0) = (Float64Array with: 7.0)]. + self should: [3.5 + (Float64Array with: 2.0) = (Float64Array with: 5.5)]. + self should: [3.5 - (Float64Array with: 2.0) = (Float64Array with: 1.5)].! Item was added: + ----- Method: Float64ArrayTest>>testFloat64ArrayPluginPrimitiveAt (in category 'tests') ----- + testFloat64ArrayPluginPrimitiveAt + "Trivial test" + + #(zero one epsilon fmax fminDenormalized fminNormalized negativeZero negativeInfinity infinity) do: [:e | + | aFloat | + aFloat := Float perform: e. + self assert: ((Float64Array with: aFloat) at: 1) = aFloat]. + + "Cannot compare NaN" + self assert: ((Float64Array with: Float nan) at: 1) isNaN.! Item was added: + ----- Method: Float64ArrayTest>>testThatDivideAvoidsUnecessaryOverflow (in category 'tests') ----- + testThatDivideAvoidsUnecessaryOverflow + | f1 f2 expectedResult | + f1 := Float fminNormalized. + f2 := Float fminDenormalized. + expectedResult := Float64Array with: f1 / f2. + + "If any of these primitives inverse the dividend, then it will overflow" + self assert: expectedResult equals: f1 / (Float64Array with: f2). + self assert: expectedResult equals: (Float64Array with: f1) / f2. + self assert: expectedResult equals: (Float64Array with: f1) / (Float64Array with: f2).! Item was added: + ----- Method: Float64ArrayTest>>testVectorOperations (in category 'tests') ----- + testVectorOperations + + "Test primtive cases 'receiver size = argument size'." + self assert: (Float64Array withAll: {2.0. 2.0}) equals: (Float64Array withAll: {4.0. 6.0}) / (Float64Array withAll: {2.0. 3.0}). + self assert: (Float64Array withAll: {8.0. 9.0}) equals: (Float64Array withAll: {4.0. 4.5}) * (Float64Array withAll: {2.0. 2.0}). + self assert: (Float64Array withAll: {6.0. 9.0}) equals: (Float64Array withAll: {4.0. 6.0}) + (Float64Array withAll: {2.0. 3.0}). + self assert: (Float64Array withAll: {2.0. 3.0}) equals: (Float64Array withAll: {4.0. 6.0}) - (Float64Array withAll: {2.0. 3.0}). + self assert: 26 equals: ((Float64Array withAll: {4.0. 6.0}) dot: (Float64Array withAll: {2.0. 3.0})). + + "Test corner cases where 'receiver size < argument size'." + self should: [(Float64Array withAll: {4.0. 6.0}) / (Float64Array withAll: {2.0. 3.0. 42.0})] raise: Error. + self should: [(Float64Array withAll: {4.0. 6.0}) * (Float64Array withAll: {2.0. 3.0. 42.0})] raise: Error. + self should: [(Float64Array withAll: {4.0. 6.0}) + (Float64Array withAll: {2.0. 3.0. 42.0})] raise: Error. + self should: [(Float64Array withAll: {4.0. 6.0}) - (Float64Array withAll: {2.0. 3.0. 42.0})] raise: Error. + self should: [(Float64Array withAll: {4.0. 6.0}) dot: (Float64Array withAll: {2.0. 3.0. 42.0})] raise: Error. + + "Test corner cases where 'receiver size > argument size'." + self should: [(Float64Array withAll: {4.0. 6.0. 42.0}) / (Float64Array withAll: {2.0. 3.0})] raise: Error. + self should: [(Float64Array withAll: {4.0. 6.0. 42.0}) * (Float64Array withAll: {2.0. 3.0})] raise: Error. + self should: [(Float64Array withAll: {4.0. 6.0. 42.0}) + (Float64Array withAll: {2.0. 3.0})] raise: Error. + self should: [(Float64Array withAll: {4.0. 6.0. 42.0}) - (Float64Array withAll: {2.0. 3.0})] raise: Error. + self should: [(Float64Array withAll: {4.0. 6.0. 42.0}) dot: (Float64Array withAll: {2.0. 3.0})] raise: Error. + + + + ! Item was added: + ----- Method: FloatArrayTest>>testThatDivideAvoidsUnecessaryOverflow (in category 'tests') ----- + testThatDivideAvoidsUnecessaryOverflow + | f1 expectedResult | + f1 := 1.0e-39. + expectedResult := Float64Array with: 1.0. + + "If any of these primitives inverse the dividend into a float, then it will overflow. + It will work though if using intermediate double." + self assert: expectedResult equals: f1 / (Float64Array with: f1). + self assert: expectedResult equals: (Float64Array with: f1) / f1. + self assert: expectedResult equals: (Float64Array with: f1) / (Float64Array with: f1).! |
Free forum by Nabble | Edit this page |