[Pkg] The Trunk: KernelTests-nice.357.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Apr 27 12:45:17 UTC 2019


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

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

Name: KernelTests-nice.357
Author: nice
Time: 27 April 2019, 2:45:13.141833 pm
UUID: b42dbfd6-b189-4082-bd9b-7c9f5b0fd586
Ancestors: KernelTests-fn.356

Add some tests for new huge Integer arithmetic algorithms

Note: I'd like to test things like:

	x := self x106kbits
	self assert: [x squaredToom4] runsFasterThan: [x squaredKaratsuba].
	
But I'm afraid that it might sometimes fail, depending on particular slave machnie load...

Benchmarking is an art...

=============== Diff against KernelTests-fn.356 ===============

Item was added:
+ ----- Method: IntegerTest>>testSqrtRem (in category 'tests - mathematical functions') -----
+ testSqrtRem
+ 
+ 	#(
+ 		0 1 2 3 4 5 10 16 30 160479924 386234481 501619156 524723498 580855366 766098594 834165249 1020363860 1042083924 1049218924
+ 		1459774772895569 3050005981408238 4856589481837079 5650488387708463 7831037396100244) do: [ :each |
+ 			| sr |
+ 			sr := each sqrtRem.
+ 			self assert: sr first squared <= each.
+ 			self assert: (sr first+1) squared > each.
+ 			self assert: sr first squared + sr last = each]
+ 		!

Item was added:
+ ----- Method: LargePositiveIntegerTest>>testDigitDiv (in category 'tests') -----
+ testDigitDiv
+ 	| a b q r qr ap bp |
+ 	ap := self x23kbits.
+ 	bp := self x13kbits.
+ 	self assert: (ap recursiveDigitDiv: bp) = ((ap primDigitDiv: bp neg: false) collect: #normalize).
+ 	#(#yourself #negated) do: [:opa | 
+ 		#(#yourself #negated) do: [:opb | 
+ 			a := ap perform: opa.
+ 			b := bp perform: opb.
+ 			qr := a digitDiv: b neg: opa ~~ opb.
+ 			q := qr first normalize.
+ 			r := qr last normalize.
+ 			self assert: q * b + r = a.
+ 			self assert: r abs < b abs.
+ 			self assert: a positive ==> r positive.
+ 			self assert: a negative ==> (r negative | r isZero)]]
+ 	!

Item was added:
+ ----- Method: LargePositiveIntegerTest>>testFastMultiply (in category 'tests') -----
+ testFastMultiply
+ 	| a b ab ap bp |
+ 	ap := self x92kbits.
+ 	bp := self x106kbits.
+ 	#(#yourself #negated) do: [:opa | 
+ 		#(#yourself #negated) do: [:opb | 
+ 			a := ap perform: opa.
+ 			b := bp perform: opb.
+ 			ab := a * b.
+ 			self assert: (a fastMultiply: b) = ab.
+ 			self assert: (a karatsubaTimes: b) = ab.
+ 			self assert: (a toom3Times: b) = ab]]!

Item was added:
+ ----- Method: LargePositiveIntegerTest>>testSqrtRem (in category 'tests') -----
+ testSqrtRem
+ 	| x sr |
+ 	x := self x92kbits.
+ 	sr := x sqrtRem.
+ 	self assert: sr first squared <= x.
+ 	self assert: (sr first+1) squared > x.
+ 	self assert: sr first squared + sr last = x.!

Item was added:
+ ----- Method: LargePositiveIntegerTest>>testSquared (in category 'tests') -----
+ testSquared
+ 
+ 	| large ref |
+ 	large := self x23kbits.
+ 	ref := large * large.
+ 	self assert: ref = large squared.
+ 	self assert: ref = large squaredKaratsuba.
+ 	self assert: ref = large squaredToom3.
+ 	self assert: ref = large squaredToom4.!

Item was added:
+ ----- Method: LargePositiveIntegerTest>>x106kbits (in category 'accessing') -----
+ x106kbits
+ 	"Return a 106 kilo bits integer"
+ 	^(15 to: 55 by: 4)
+ 				inject: 9876543210
+ 				into: [:big :bits | big * big << bits + bits]!

Item was added:
+ ----- Method: LargePositiveIntegerTest>>x13kbits (in category 'accessing') -----
+ x13kbits
+ 	"Return a 13 kilo bits integer"
+ 	^(15 to: 44 by: 4)
+ 				inject: 9876543210
+ 				into: [:big :bits | big * big << bits + bits]!

Item was added:
+ ----- Method: LargePositiveIntegerTest>>x23kbits (in category 'accessing') -----
+ x23kbits
+ 	"Return a 23 kilo bits integer"
+ 	^(11 to: 44 by: 4)
+ 			inject: 1234567890
+ 			into: [:big :bits | big * big << bits + bits]!

Item was added:
+ ----- Method: LargePositiveIntegerTest>>x92kbits (in category 'accessing') -----
+ x92kbits
+ 	"Return a 92 kilo bits integer"
+ 	^(11 to: 51 by: 4)
+ 			inject: 1234567890
+ 			into: [:big :bits | big * big << bits + bits]!



More information about the Packages mailing list