The Trunk: CollectionsTests-ul.254.mcz

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

The Trunk: CollectionsTests-ul.254.mcz

commits-2
Levente Uzonyi uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-ul.254.mcz

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

Name: CollectionsTests-ul.254
Author: ul
Time: 10 October 2015, 3:38:59.878 pm
UUID: 2c18cac6-27e3-48cd-94ce-e2cc617d71c5
Ancestors: CollectionsTests-topa.252, CollectionsTests-ul.253

Added thorough tests for #asIntegerSigned:.

=============== Diff against CollectionsTests-topa.252 ===============

Item was changed:
  ----- Method: ByteArrayTest>>testPlatformIndepentendIntegerAccessorsAtBitBorders (in category 'testing - platform independent access') -----
  testPlatformIndepentendIntegerAccessorsAtBitBorders
 
  #(
  shortAt:put:bigEndian: shortAt:bigEndian: false 16
  longAt:put:bigEndian: longAt:bigEndian: false 32
+ long64At:put:bigEndian: long64At:bigEndian: false 64
  unsignedShortAt:put:bigEndian: unsignedShortAt:bigEndian: true 16
  unsignedLongAt:put:bigEndian: unsignedLongAt:bigEndian: true 32
  unsignedLong64At:put:bigEndian: unsignedLong64At:bigEndian: true 64
  ) groupsDo: [ :setter :getter :unsigned :storageBits |
  self
  verifyPlatformIndepentendIntegerAccessorsAtBitBordersSetter: setter
  getter: getter
  unsigned: unsigned
  storageBits: storageBits ]!

Item was changed:
  ----- Method: ByteArrayTest>>testPlatformIndepentendIntegerAccessorsWithRandomValues (in category 'testing - platform independent access') -----
  testPlatformIndepentendIntegerAccessorsWithRandomValues
 
  | random |
  random := Random seed: 36rSqueak.
  #(
  shortAt:put:bigEndian: shortAt:bigEndian: false 16
  longAt:put:bigEndian: longAt:bigEndian: false 32
+ long64At:put:bigEndian: long64At:bigEndian: false 64
  unsignedShortAt:put:bigEndian: unsignedShortAt:bigEndian: true 16
  unsignedLongAt:put:bigEndian: unsignedLongAt:bigEndian: true 32
  unsignedLong64At:put:bigEndian: unsignedLong64At:bigEndian: true 64
  ) groupsDo: [ :setter :getter :unsigned :storageBits |
  self
  verifyPlatformIndepentendIntegerAccessorsWithRandomValuesSetter: setter
  getter: getter
  unsigned: unsigned
  storageBits: storageBits
  random: random ]!

Item was changed:
  ----- Method: StringTest>>testAsInteger (in category 'tests - converting') -----
  testAsInteger
 
+ #(
+ '' nil nil nil
+ '1796exportFixes-tkMX' 1796 1796 1796
+ 'donald' nil nil nil
+ 'abc234def567' 234 234 234
+ '-94' -94 -94 94
+ 'foo-bar-92' -92 -92 92
+ ) groupsDo: [ :inputString :asIntegerExpectedValue :asSignedIntegerExpectedValue :asUnsignedIntegerExpectedValue |
+ self
+ assert: asIntegerExpectedValue equals: inputString asInteger;
+ assert: asSignedIntegerExpectedValue equals: inputString asSignedInteger;
+ assert: asUnsignedIntegerExpectedValue equals: inputString asUnsignedInteger ]!
- self assert: '1796exportFixes-tkMX' asInteger = 1796.
- self assert: 'donald' asInteger isNil.
- self assert: 'abc234def567' asInteger = 234.
- self assert: '-94' asInteger = -94.
- self assert: 'foo-bar-92' asInteger = -92!

Item was added:
+ ----- Method: StringTest>>testAsIntegerSigned (in category 'tests - converting') -----
+ testAsIntegerSigned
+
+ #(
+ '' nil nil
+ '1796exportFixes-tkMX' 1796 1796
+ 'donald' nil nil
+ 'abc234def567' 234 234
+ '-94' -94 94
+ 'foo-bar-92' -92 92
+ '1234567890' 1234567890 1234567890
+ '--1234567890--' -1234567890 1234567890
+ '--1234567890123456789012345678901234567890--' -1234567890123456789012345678901234567890 1234567890123456789012345678901234567890
+ ) groupsDo: [ :inputString :expectedSignedValue :expectedUnsignedValue |
+ self
+ assert: expectedSignedValue equals: (inputString asIntegerSigned: true);
+ assert: expectedUnsignedValue equals: (inputString asIntegerSigned: false) ]!

Item was added:
+ ----- Method: StringTest>>testAsIntegerSignedUsingRandomNumbers (in category 'tests - converting') -----
+ testAsIntegerSignedUsingRandomNumbers
+
+ | random |
+ random := Random seed: 36rSqueak.
+ 1 to: 100 do: [ :digitLength |
+ 50 timesRepeat: [
+ | number inputString |
+ number := ((2 atRandom: random) = 1
+ ifTrue: [ LargePositiveInteger ]
+ ifFalse: [ LargeNegativeInteger ])
+ new: digitLength.
+ 1 to: digitLength do: [ :index | number at: index put: (256 atRandom: random) - 1 ].
+ number := number normalize.
+ inputString := number asString.
+ self
+ assert: number equals: (inputString asIntegerSigned: true);
+ assert: number abs equals: (inputString asIntegerSigned: false) ] ]!

Item was changed:
  ----- Method: WideStringTest>>testAsInteger (in category 'tests - converting') -----
  testAsInteger
- self assert: '1796exportFixes-tkMX' asWideString asInteger = 1796.
- self assert: 'donald' asWideString asInteger isNil.
- self assert: 'abc234def567' asWideString asInteger = 234.
- self assert: '-94' asWideString asInteger = -94.
- self assert: 'foo-bar-92' asWideString asInteger = -92.
 
+ #(
+ '' nil nil nil
+ '1796exportFixes-tkMX' 1796 1796 1796
+ 'donald' nil nil nil
+ 'abc234def567' 234 234 234
+ '-94' -94 -94 94
+ 'foo-bar-92' -92 -92 92
+ ) groupsDo: [ :inputString :asIntegerExpectedValue :asSignedIntegerExpectedValue :asUnsignedIntegerExpectedValue |
+ | wideString |
+ wideString := inputString asWideString.
+ self
+ assert: asIntegerExpectedValue equals: wideString asInteger;
+ assert: asSignedIntegerExpectedValue equals: wideString asSignedInteger;
+ assert: asUnsignedIntegerExpectedValue equals: wideString asUnsignedInteger ]!
- self assert: '1796exportFixes-tkMX' asWideString asSignedInteger = 1796.
- self assert: 'donald' asWideString asSignedInteger isNil.
- self assert: 'abc234def567' asWideString asSignedInteger = 234.
- self assert: '-94' asWideString asSignedInteger = -94.
- self assert: 'foo-bar-92' asWideString asSignedInteger = -92.
-
- self assert: '1796exportFixes-tkMX' asWideString asUnsignedInteger = 1796.
- self assert: 'donald' asWideString asUnsignedInteger isNil.
- self assert: 'abc234def567' asWideString asUnsignedInteger = 234.
- self assert: '-94' asWideString asUnsignedInteger = 94.
- self assert: 'foo-bar-92' asWideString asUnsignedInteger = 92!

Item was added:
+ ----- Method: WideStringTest>>testAsIntegerSigned (in category 'tests - converting') -----
+ testAsIntegerSigned
+
+ #(
+ '' nil nil
+ '1796exportFixes-tkMX' 1796 1796
+ 'donald' nil nil
+ 'abc234def567' 234 234
+ '-94' -94 94
+ 'foo-bar-92' -92 92
+ '1234567890' 1234567890 1234567890
+ '--1234567890--' -1234567890 1234567890
+ '--1234567890123456789012345678901234567890--' -1234567890123456789012345678901234567890 1234567890123456789012345678901234567890
+ ) groupsDo: [ :inputString :expectedSignedValue :expectedUnsignedValue |
+ self
+ assert: expectedSignedValue equals: (inputString asIntegerSigned: true);
+ assert: expectedUnsignedValue equals: (inputString asIntegerSigned: false) ]!

Item was added:
+ ----- Method: WideStringTest>>testAsIntegerSignedUsingRandomNumbers (in category 'tests - converting') -----
+ testAsIntegerSignedUsingRandomNumbers
+
+ | random digitCharactersByValue |
+ random := Random seed: 36rSqueak.
+ digitCharactersByValue := (((0 to: 65535) collect: #asCharacter as: String) select: #isDigit)
+ groupBy: #digitValue.
+ 1 to: 100 do: [ :digitLength |
+ 50 timesRepeat: [
+ | number inputString |
+ number := ((2 atRandom: random) = 1
+ ifTrue: [ LargePositiveInteger ]
+ ifFalse: [ LargeNegativeInteger ])
+ new: digitLength.
+ 1 to: digitLength do: [ :index | number at: index put: (256 atRandom: random) - 1 ].
+ number := number normalize.
+ inputString := number asString asWideString.
+ inputString replace: [ :each |
+ each == $-
+ ifTrue: [ each ]
+ ifFalse: [ (digitCharactersByValue at: each digitValue) atRandom: random ] ].
+ self
+ assert: number equals: (inputString asIntegerSigned: true);
+ assert: number abs equals: (inputString asIntegerSigned: false) ] ]!