Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.130.mcz ==================== Summary ==================== Name: KernelTests-nice.130 Author: nice Time: 13 February 2010, 2:32:10.559 am UUID: 033fe124-e9aa-f545-96ba-fb0be90c3e4c Ancestors: KernelTests-nice.129 Some tests for the ExtendedNumberParser =============== Diff against KernelTests-nice.129 =============== Item was added: + ----- Method: ExtendedNumberParserTest>>testInvalidExponent (in category 'testing') ----- + testInvalidExponent + "The leading number is returned, the invalid part is ignored" + + self assert: (ExtendedNumberParser parse: '1e') = 1. + self assert: (ExtendedNumberParser parse: '1eZ') = 1. + self assert: (ExtendedNumberParser parse: '+1eW') = 1. + self assert: (ExtendedNumberParser parse: '-1eX') = -1. + + self assert: (ExtendedNumberParser parse: '2e-') = 2. + self assert: (ExtendedNumberParser parse: '2e--1') = 2. + self assert: (ExtendedNumberParser parse: '2e-+1') = 2. + self assert: (ExtendedNumberParser parse: '2e-Z') = 2. + self assert: (ExtendedNumberParser parse: '+2e-W') = 2. + self assert: (ExtendedNumberParser parse: '-2e-X') = -2. + + self assert: (ExtendedNumberParser parse: '3e+') = 3. + self assert: (ExtendedNumberParser parse: '3e+-') = 3. + self assert: (ExtendedNumberParser parse: '3e+-1') = 3. + self assert: (ExtendedNumberParser parse: '+3e+W') = 3. + self assert: (ExtendedNumberParser parse: '-3e+Z') = -3.! Item was added: + ----- Method: ExtendedNumberParserTest>>testInvalidScale (in category 'testing') ----- + testInvalidScale + "The leading number is returned, the invalid part is ignored" + + self assert: (ExtendedNumberParser parse: '1s') = 1. + self assert: (ExtendedNumberParser parse: '1sZ') = 1. + self assert: (ExtendedNumberParser parse: '+1sW') = 1. + self assert: (ExtendedNumberParser parse: '-1sX') = -1. + + self assert: (ExtendedNumberParser parse: '2s-') = 2. + self assert: (ExtendedNumberParser parse: '2s--1') = 2. + self assert: (ExtendedNumberParser parse: '2s-+1') = 2. + self assert: (ExtendedNumberParser parse: '2s-1') = 2. + self assert: (ExtendedNumberParser parse: '+2s-2') = 2. + self assert: (ExtendedNumberParser parse: '-2s-3') = -2. + + self assert: (ExtendedNumberParser parse: '3s+') = 3. + self assert: (ExtendedNumberParser parse: '3s+-') = 3. + self assert: (ExtendedNumberParser parse: '3s+-1') = 3. + self assert: (ExtendedNumberParser parse: '+3s+2') = 3. + self assert: (ExtendedNumberParser parse: '-3s+3') = -3.! Item was added: + ----- Method: ExtendedNumberParserTest>>testPositive (in category 'testing') ----- + testPositive + "A leading + sign is allowed" + + self assert: (ExtendedNumberParser parse: '+1') = 1. + self assert: (ExtendedNumberParser parse: '+22') = 22. + self assert: (ExtendedNumberParser parse: '+2r11') = 3. + self assert: (ExtendedNumberParser parse: '+2r+101') = 5. + self assert: (ExtendedNumberParser parse: '+2r-101') = -5. + self assert: (ExtendedNumberParser parse: '-2r+101') = -5. + + self assert: (ExtendedNumberParser parse: '+1.') isFloat. + self assert: (ExtendedNumberParser parse: '+1.') = 1. + self assert: (ExtendedNumberParser parse: '+21.') = 21. + self assert: (ExtendedNumberParser parse: '+3r21.') = 7. + self assert: (ExtendedNumberParser parse: '+3r+201.') = 19. + self assert: (ExtendedNumberParser parse: '+3r-201.') = -19. + self assert: (ExtendedNumberParser parse: '-3r+201.') = -19.! Item was added: + ----- Method: ExtendedNumberParserTest>>testFractionPartWithoutIntegerPart (in category 'testing') ----- + testFractionPartWithoutIntegerPart + "The integer part before the decimal is optional" + + self assert: (ExtendedNumberParser parse: '.5') = (1/2). + self assert: (ExtendedNumberParser parse: '.5') isFloat. + + self assert: (ExtendedNumberParser parse: '.3e2') = 30. + self assert: (ExtendedNumberParser parse: '.3e2') isFloat. + + self assert: (ExtendedNumberParser parse: '-.4e2') = -40. + self assert: (ExtendedNumberParser parse: '-.4e2') isFloat. + + self assert: (ExtendedNumberParser parse: '+.5e2') = 50. + self assert: (ExtendedNumberParser parse: '+.5e2') isFloat. + + self assert: (ExtendedNumberParser parse: '+.6e+2') = 60. + self assert: (ExtendedNumberParser parse: '+.6e+2') isFloat. + + self assert: (ExtendedNumberParser parse: '-.7e+2') = -70. + self assert: (ExtendedNumberParser parse: '-.7e+2') isFloat. + + self assert: (ExtendedNumberParser parse: '+2r.1e-2') = (1/8). + self assert: (ExtendedNumberParser parse: '+2r.1e-2') isFloat. + + self assert: (ExtendedNumberParser parse: '-4r.1e-2') = (-1/64). + self assert: (ExtendedNumberParser parse: '-4r.1e-2') isFloat.! Item was added: + ClassTestCase subclass: #ExtendedNumberParserTest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'KernelTests-Numbers'! Item was added: + ----- Method: ExtendedNumberParserTest>>testPositiveExponent (in category 'testing') ----- + testPositiveExponent + "A leading + sign is allowed in exponent" + + self assert: (ExtendedNumberParser parse: '1e+2') = 100. + self assert: (ExtendedNumberParser parse: '1e+2') isInteger. + self assert: (ExtendedNumberParser parse: '-1e+2') = -100. + + self assert: (ExtendedNumberParser parse: '1.e+2') = 100. + self assert: (ExtendedNumberParser parse: '1.e+2') isFloat. + self assert: (ExtendedNumberParser parse: '-1.0e+2') = -100.! Item was added: + ----- Method: ExtendedNumberParserTest>>testIntegerPartWithoutFraction (in category 'testing') ----- + testIntegerPartWithoutFraction + "The fraction part after the decimal is optional" + + self assert: (ExtendedNumberParser parse: '1.') = 1. + self assert: (ExtendedNumberParser parse: '1.') isFloat. + + self assert: (ExtendedNumberParser parse: '3.e2') = 300. + self assert: (ExtendedNumberParser parse: '3.e2') isFloat. + + self assert: (ExtendedNumberParser parse: '-4.e2') = -400. + self assert: (ExtendedNumberParser parse: '-4.e2') isFloat. + + self assert: (ExtendedNumberParser parse: '+5.e2') = 500. + self assert: (ExtendedNumberParser parse: '+5.e2') isFloat. + + self assert: (ExtendedNumberParser parse: '+6.e+2') = 600. + self assert: (ExtendedNumberParser parse: '+6.e+2') isFloat. + + self assert: (ExtendedNumberParser parse: '-7.e+2') = -700. + self assert: (ExtendedNumberParser parse: '-7.e+2') isFloat. + + self assert: (ExtendedNumberParser parse: '+2r1.e-2') = (1/4). + self assert: (ExtendedNumberParser parse: '+2r1.e-2') isFloat. + + self assert: (ExtendedNumberParser parse: '-4r1.e-2') = (-1/16). + self assert: (ExtendedNumberParser parse: '-4r1.e-2') isFloat.! Item was changed: ----- Method: SmallIntegerTest>>testPrintString (in category 'testing - printing') ----- testPrintString + self assert: 1 printString = '1'. + self assert: -1 printString = '-1'. + self assert: SmallInteger minVal printString = '-1073741824'. + self assert: SmallInteger maxVal printString = '1073741823'. + self assert: 12345 printString = '12345'. + self assert: -54321 printString = '-54321'. + self assert: 0 decimalDigitLength = 1. + self assert: 4 decimalDigitLength = 1. + self assert: 12 decimalDigitLength = 2. + self assert: 123 decimalDigitLength = 3. + self assert: 1234 decimalDigitLength = 4. + self assert: 56789 decimalDigitLength = 5. + self assert: 657483 decimalDigitLength = 6. + self assert: 6571483 decimalDigitLength = 7. + self assert: 65174383 decimalDigitLength = 8. + self assert: 625744831 decimalDigitLength = 9. + self assert: 1000001111 decimalDigitLength = 10. + self assert: SmallInteger maxVal decimalDigitLength = 10.! - self assert: 1 printString = '1'. - self assert: -1 printString = '-1'. - self assert: SmallInteger minVal printString = '-1073741824'. - self assert: SmallInteger maxVal printString = '1073741823'. - self assert: 12345 printString = '12345'. - self assert: -54321 printString = '-54321'. - - self assert: 0 decimalDigitLength = 1. - self assert: 4 decimalDigitLength = 1. - self assert: 12 decimalDigitLength = 2. - self assert: 123 decimalDigitLength = 3. - self assert: 1234 decimalDigitLength = 4. - self assert: 56789 decimalDigitLength = 5. - self assert: 657483 decimalDigitLength = 6. - self assert: 6571483 decimalDigitLength = 7. - self assert: 65174383 decimalDigitLength = 8. - self assert: 625744831 decimalDigitLength = 9. - self assert: 1000001111 decimalDigitLength = 10. - self assert: SmallInteger maxVal decimalDigitLength = 10.! Item was added: + ----- Method: ExtendedNumberParserTest>>testInvalidRadix (in category 'testing') ----- + testInvalidRadix + "The leading number is returned, the invalid part is ignored" + + self assert: (ExtendedNumberParser parse: '1r') = 1. + self assert: (ExtendedNumberParser parse: '+1r') = 1. + self assert: (ExtendedNumberParser parse: '-1r') = -1. + self assert: (ExtendedNumberParser parse: '-1r+') = -1. + self assert: (ExtendedNumberParser parse: '-1r-') = -1. + + self assert: (ExtendedNumberParser parse: '-2r.') = -2. + self assert: (ExtendedNumberParser parse: '-2r-.') = -2. + self assert: (ExtendedNumberParser parse: '+2r-.') = 2. + + self assert: (ExtendedNumberParser parse: '+2r3.') = 2. + self assert: (ExtendedNumberParser parse: '+2r.3') = 2. + self assert: (ExtendedNumberParser parse: '+2r-.3') = 2.! |
Free forum by Nabble | Edit this page |