Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.97.mcz ==================== Summary ==================== Name: KernelTests-nice.97 Author: nice Time: 4 October 2009, 10:15:29 am UUID: c1724359-077f-45e4-8252-d181bce38f4b Ancestors: KernelTests-nice.96 Tests from http://bugs.squeak.org/view.php?id=6781 plus additional tests for license clean #reciprocal #/ etc... =============== Diff against KernelTests-nice.96 =============== Item was added: + ----- Method: NumberTest>>testOne (in category 'tests') ----- + testOne + + self + assert: Integer one = 1; + assert: Float one = 1.0; + assert: Fraction one = 1! Item was added: + ----- Method: FloatTest>>testRaisedTo (in category 'testing - arithmetic') ----- + testRaisedTo + "this is a test related to http://bugs.squeak.org/view.php?id=6781" + + self should: [0.0 raisedTo: -1] raise: ZeroDivide. + self should: [0.0 raisedTo: -1.0] raise: ZeroDivide.! Item was added: + ----- Method: ScaledDecimalTest>>testZeroRaisedToInteger (in category 'tests') ----- + testZeroRaisedToInteger + "Zero might be handle specially" + + self should: [0.0s1 raisedToInteger: -1] raise: Error. + self assert: (0.0s1 raisedToInteger: 0) = 1. + self assert: (0.0s1 raisedToInteger: 0) scale = 1. + self assert: (0.0s1 raisedToInteger: 1) = 0. + self assert: (0.0s1 raisedToInteger: 1) scale = 1. + self assert: (0.0s1 raisedToInteger: 2) = 0. + self assert: (0.0s1 raisedToInteger: 2) scale = 1.! Item was added: + ----- Method: NumberTest>>testRaisedToIntegerWithFloats (in category 'tests') ----- + testRaisedToIntegerWithFloats + + self + assert: (2.0 raisedToInteger: 0) = 1.0; + assert: (2.0 raisedToInteger: 1) = 2.0; + assert: (2.0 raisedToInteger: 4) = 16.0; + assert: (0.0 raisedToInteger: 0) = 1.0; + assert: (0.0 raisedToInteger: 2) = 0.0; + assert: (2.0 raisedToInteger: -1) = 0.5; + assert: (2.0 raisedToInteger: -4) = 0.0625. + + self + assert: (-3.0 raisedTo: 0) = 1.0; + assert: (-3.0 raisedTo: 1) = -3.0; + assert: (-3.0 raisedTo: 2) = 9.0; + assert: (-3.0 raisedTo: 3) = -27.0; + assert: (-2.0 raisedTo: -2) = 0.25; + assert: (-2.0 raisedTo: -3) = -0.125. + + self should: [ 0.0 raisedTo: -1 ] raise: ZeroDivide! Item was added: + ----- Method: ScaledDecimalTest>>testScaleExtension (in category 'tests') ----- + testScaleExtension + "The scale is extended to the larger one in case of arithmetic operation" + + #( #* #+ #- #/) do: [:op | + self assert: (2.5s1 perform: op with: 1.000s3) scale = 3. + self assert: (3.5000s4 perform: op with: 1.0s1) scale = 4.]! Item was added: + ----- Method: NumberTest>>testReciprocal (in category 'tests') ----- + testReciprocal + + self + assert: 1 reciprocal = 1; + assert: 2 reciprocal = (1/2); + assert: -1 reciprocal = -1; + assert: -3 reciprocal = (-1/3). + + self should: [ 0 reciprocal ] raise: ZeroDivide! Item was added: + ----- Method: NumberTest>>testRaisedTo (in category 'tests') ----- + testRaisedTo + "this is a test related to http://bugs.squeak.org/view.php?id=6781" + + self should: [0 raisedTo: -1] raise: ZeroDivide. + self should: [0 raisedTo: -1.0] raise: ZeroDivide.! Item was added: + ----- Method: ScaledDecimalTest>>testRaisedToInteger (in category 'tests') ----- + testRaisedToInteger + "Raising to integer should preserve class and scale" + + self assert: (3.0s1 raisedToInteger: -1) scale = 1. + self assert: (3.0s1 raisedToInteger: -1) = (1/3). + self assert: (3.0s1 raisedToInteger: 0) scale = 1. + self assert: (3.0s1 raisedToInteger: 0) = 1. + self assert: (3.0s1 raisedToInteger: 1) scale = 1. + self assert: (3.0s1 raisedToInteger: 1) = 3. + self assert: (3.0s1 raisedToInteger: 2) scale = 1. + self assert: (3.0s1 raisedToInteger: 2) = 9.! Item was added: + ----- Method: FractionTest>>testReciprocal (in category 'tests - sinuses') ----- + testReciprocal + + self + assert: (1/2) reciprocal = 2; + assert: (3/4) reciprocal = (4/3); + assert: (-1/3) reciprocal = -3; + assert: (-3/5) reciprocal = (-5/3)! Item was changed: ----- Method: FloatTest>>testDivide (in category 'testing - arithmetic') ----- testDivide + + self assert: 1.5 / 2.0 = 0.75. + + self assert: 2.0 / 1 = 2.0. + + self should: [ 2.0 / 0 ] raise: ZeroDivide. + self should: [ 2.0 / 0.0 ] raise: ZeroDivide. + self should: [ 1.2 / Float negativeZero ] raise: ZeroDivide. + self should: [ 1.2 / (1.3 - 1.3) ] raise: ZeroDivide + ! - self assert: 2.0 / 1 = 2. - self should: [ 2.0 / 0 ] raise: ZeroDivide.! Item was added: + ----- Method: NumberTest>>testFractionPart (in category 'tests') ----- + testFractionPart + + self + assert: 2 fractionPart = 0; + assert: (1/2) fractionPart = (1/2); + assert: (4/3) fractionPart = (1/3); + assert: 2.0 fractionPart = 0.0; + assert: 0.5 fractionPart = 0.5; + assert: 2.5 fractionPart = 0.5 + ! Item was added: + ----- Method: NumberTest>>testIntegerPart (in category 'tests') ----- + testIntegerPart + + self + assert: 2 integerPart = 2; + assert: (1/2) integerPart = 0; + assert: (4/3) integerPart = 1; + assert: 2.0 integerPart = 2.0; + assert: 0.5 integerPart = 0.0; + assert: 2.5 integerPart = 2.0 + ! Item was added: + ----- Method: ScaledDecimalTest>>testOneRaisedToInteger (in category 'tests') ----- + testOneRaisedToInteger + "One might be handled specially" + + self assert: (1.0s1 raisedToInteger: -1) scale = 1. + self assert: (1.0s1 raisedToInteger: -1) = 1. + self assert: (1.0s1 raisedToInteger: 0) scale = 1. + self assert: (1.0s1 raisedToInteger: 0) = 1. + self assert: (1.0s1 raisedToInteger: 1) scale = 1. + self assert: (1.0s1 raisedToInteger: 1) = 1. + self assert: (1.0s1 raisedToInteger: 2) scale = 1. + self assert: (1.0s1 raisedToInteger: 2) = 1.! Item was added: + ----- Method: FloatTest>>testReciprocal (in category 'NaN behavior') ----- + testReciprocal + + self + assert: 1.0 reciprocal = 1.0; + assert: 2.0 reciprocal = 0.5; + assert: -1.0 reciprocal = -1.0; + assert: -2.0 reciprocal = -0.5. + + self should: [ 0.0 reciprocal ] raise: ZeroDivide! Item was added: + ----- Method: NumberTest>>testRaisedToInteger (in category 'tests') ----- + testRaisedToInteger + + self + assert: (2 raisedToInteger: 0) = 1; + assert: (2 raisedToInteger: 1) = 2; + assert: (2 raisedToInteger: 4) = 16; + assert: (0 raisedToInteger: 0) = 1; + assert: (0 raisedToInteger: 2) = 0; + assert: (2 raisedToInteger: -1) = (1/2); + assert: (2 raisedToInteger: -4) = (1/16). + + self + assert: (-3 raisedTo: 0) = 1; + assert: (-3 raisedTo: 1) = -3; + assert: (-3 raisedTo: 2) = 9; + assert: (-3 raisedTo: 3) = -27; + assert: (-3 raisedTo: -2) = (1/9); + assert: (-3 raisedTo: -3) = (-1/27). + + self should: [ 0 raisedTo: -1 ] raise: ZeroDivide! |
Free forum by Nabble | Edit this page |