Issue 4414 in pharo: test for Number

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

Issue 4414 in pharo: test for Number

pharo
Status: Accepted
Owner: [hidden email]
Labels: Type-Squeak Milestone-1.4

New issue 4414 by [hidden email]: test for Number
http://code.google.com/p/pharo/issues/detail?id=4414

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

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

Name: KernelTests-nice.193
Author: nice
Time: 3 June 2011, 9:41:10.753 pm
UUID: 525af4ab-6857-482b-9d70-1e94739311ee
Ancestors: KernelTests-eem.192

Add tests for ceiling/floor/truncated/rounded

=============== Diff against KernelTests-eem.192 ===============

Item was added:
+ ----- Method: FloatTest>>testCeiling (in category 'testing - conversion')  
-----
+ testCeiling
+       self assert: 1.0 ceiling = 1.
+       self assert: 1.1 ceiling = 2.
+       self assert: -2.0 ceiling = -2.
+       self assert: -2.1 ceiling = -2.!

Item was added:
+ ----- Method: FloatTest>>testFloor (in category 'testing - conversion')  
-----
+ testFloor
+       self assert: 1.0 floor = 1.
+       self assert: 1.1 floor = 1.
+       self assert: -2.0 floor = -2.
+       self assert: -2.1 floor = -3.!

Item was added:
+ ----- Method: FloatTest>>testRounded (in category 'testing - conversion')  
-----
+ testRounded
+       self assert: 0.9 rounded = 1.
+       self assert: 1.0 rounded = 1.
+       self assert: 1.1 rounded = 1.
+       self assert: -1.9 rounded = -2.
+       self assert: -2.0 rounded = -2.
+       self assert: -2.1 rounded = -2.
+
+       "In case of tie, round to upper magnitude"
+       self assert: 1.5 rounded = 2.
+       self assert: -1.5 rounded = -2.!

Item was added:
+ ----- Method: FloatTest>>testTruncated (in category 'testing -  
conversion') -----
+ testTruncated
+       self assert: 1.0 truncated = 1.
+       self assert: 1.1 truncated = 1.
+       self assert: -2.0 truncated = -2.
+       self assert: -2.1 truncated = -2.!

Item was added:
+ ----- Method: FractionTest>>testCeiling (in category 'tests -  
conversions') -----
+ testCeiling
+       self assert: (3 / 2) ceiling = 2.
+       self assert: (-3 / 2) ceiling = -1.!

Item was added:
+ ----- Method: FractionTest>>testFloor (in category 'tests - conversions')  
-----
+ testFloor
+       self assert: (3 / 2) floor = 1.
+       self assert: (-3 / 2) floor = -2.!

Item was added:
+ ----- Method: FractionTest>>testRounded (in category 'tests -  
conversions') -----
+ testRounded
+       self assert: (4 / 5) rounded = 1.
+       self assert: (6 / 5) rounded = 1.
+       self assert: (-4 / 5) rounded = -1.
+       self assert: (-6 / 5) rounded = -1.
+
+       "In case of tie, round to upper magnitude"
+       self assert: (3 / 2) rounded = 2.
+       self assert: (-3 / 2) rounded = -2.!

Item was added:
+ ----- Method: FractionTest>>testTruncated (in category 'tests -  
conversions') -----
+ testTruncated
+       self assert: (3 / 2) truncated = 1.
+       self assert: (-3 / 2) truncated = -1.!



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4414 in pharo: test for Number

pharo

Comment #1 on issue 4414 by [hidden email]: test for Number
http://code.google.com/p/pharo/issues/detail?id=4414

Name: KernelTests-nice.194
Author: nice
Time: 4 June 2011, 9:01:45.693 pm
UUID: c6cd136f-95ab-4d8d-9b73-8cc231b299fb
Ancestors: KernelTests-nice.193

Add a test for Montgomery multiplication (if ever implemented by the VM).

=============== Diff against KernelTests-nice.193 ===============

Item was added:
+ ----- Method: IntegerTest>>testMontgomeryMultiplication (in  
category 'testing - arithmetic') -----
+ testMontgomeryMultiplication
+       | a m mInv |
+       m := 15485863.
+       mInv := 256 - ((m bitAnd: 255) reciprocalModulo: 256).
+       a := (256 raisedTo: m digitLength) \\ m.
+       #(483933 3871465 8951195) do: [:s |
+               (s montgomeryTimes: a modulo: m mInvModB: mInv) ifNotNil:  
[:s1 |
+                       | s2 sa ssa |
+                       self assert: s = s1.
+                       sa := s montgomeryTimes: (a * a \\ m) modulo: m  
mInvModB: mInv.
+                       self assert: sa = (s * a \\ m).
+                       ssa := sa montgomeryTimes: sa modulo: m mInvModB:  
mInv.
+                       self assert: ssa = (s * s * a \\ m).
+                       s2 := ssa montgomeryTimes: 1 modulo: m mInvModB:  
mInv.
+                       self assert: s2 = (s * s \\ m)]].!


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4414 in pharo: test for Number

pharo
Updates:
        Labels: Difficulty-Easy

Comment #2 on issue 4414 by [hidden email]: test for Number
http://code.google.com/p/pharo/issues/detail?id=4414

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4414 in pharo: test for Number

pharo

Comment #3 on issue 4414 by [hidden email]: test for Number
http://code.google.com/p/pharo/issues/detail?id=4414

added in PharoInbox KernelTests-CamilloBruni.330


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4414 in pharo: test for Number

pharo

Comment #4 on issue 4414 by [hidden email]: test for Number
http://code.google.com/p/pharo/issues/detail?id=4414

in 14032


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4414 in pharo: test for Number

pharo
Updates:
        Status: Closed

Comment #5 on issue 4414 by [hidden email]: test for Number
http://code.google.com/p/pharo/issues/detail?id=4414

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker