[squeak-dev] The Trunk: KernelTests-nice.231.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Aug 31 21:02:03 UTC 2012


Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.231.mcz

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

Name: KernelTests-nice.231
Author: nice
Time: 31 August 2012, 11:01:26.531 pm
UUID: fb87513c-6c77-42a4-bd01-2d2b12acf8b8
Ancestors: KernelTests-cmm.230

Add a test for (1<<63) negated arithmetic bugs

=============== Diff against KernelTests-cmm.230 ===============

Item was added:
+ ----- Method: LargeNegativeIntegerTest>>testMinimumNegativeIntegerArithmetic (in category 'tests') -----
+ testMinimumNegativeIntegerArithmetic
+ 	"We are speaking of minimum integer in underlying hardware here.
+ 	In 2-complement, abs(INT_MIN) = (INT-MAX+1) and thus overflows hardware register.
+ 	Since some old VM forgot this edge case they may fail and it's better to be aware of it.
+ 	http://code.google.com/p/cog/issues/detail?id=92
+ 	http://bugs.squeak.org/view.php?id=7705
+ 	We only test the cases of 32 and 64 bit signed integers."
+ 
+ 	#(32 64) do: [:nBits |
+ 		| largePositiveInt largeNegativeInt |
+ 		largePositiveInt := (1 << (nBits - 1)).
+ 		largeNegativeInt := largePositiveInt negated.
+ 		self assert: (largeNegativeInt >> 3) equals: (largeNegativeInt bitInvert >> 3) bitInvert.
+ 		self assert: (largeNegativeInt + 1) equals: (largePositiveInt - 1) negated.
+ 		self assert: (largeNegativeInt - -1) equals: (largePositiveInt - 1) negated.
+ 		self assert: (largeNegativeInt // -1) equals: largePositiveInt.
+ 		self assert: (largeNegativeInt \\ -1) equals: 0.
+ 		self assert: (largeNegativeInt rem: -1) equals: 0.
+ 		self assert: (largeNegativeInt quo: -1) equals: largePositiveInt.
+ 		self assert: (largeNegativeInt * -1) equals: largePositiveInt.
+ 		self assert: (largeNegativeInt / -1) equals: largePositiveInt]!



More information about the Squeak-dev mailing list