[squeak-dev] The Trunk: GraphicsTests-wiz.25.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Jul 3 15:44:06 UTC 2010


David T. Lewis uploaded a new version of GraphicsTests to project The Trunk:
http://source.squeak.org/trunk/GraphicsTests-wiz.25.mcz

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

Name: GraphicsTests-wiz.25
Author: wiz
Time: 2 July 2010, 11:29:04.987 pm
UUID: 09631ad5-ff19-4c96-bb76-d54c7222ce8e
Ancestors: GraphicsTests-nice.24

>From mantis #6596 this changeset and the patches to make the test work were marked as having been put into updates for 3.10 by Edgar. Apparently the historic record got lost as others took over. Resubmitted here.

"Change Set:		morePointTests-wiz
Date:			6 August 2007
Author:			(wiz) Jerome Peace

Point tests for repairs and enhancements to Point

normal -- now has a default for the zero point. 

sign -- extended to include point

rightRotated 
leftRotated  -- basic shortcuts added to point

fourDirections -- easy way to get a square shape from a point."

=============== Diff against GraphicsTests-nice.24 ===============

Item was added:
+ ----- Method: PointTest>>testNormal (in category 'testing - testing') -----
+ testNormal
+ " quick check of results for #normal."
+ 
+ | samples rejects results |
+ 
+ samples :=
+ 0 asPoint eightNeighbors 
+ , (Array with: 0 asPoint) .
+ 
+ results := 
+  { 0.0 at 1.0 
+ . -0.707106781186547 at 0.707106781186547 
+ . -1.0 at 0.0 
+ . -0.707106781186547 at -0.707106781186547 
+ . 0.0 at -1.0 
+ . 0.707106781186547 at -0.707106781186547 
+ . 1.0 at 0.0 
+ . 0.707106781186547 at 0.707106781186547 
+ . -1 at 0} .
+ 
+ 
+ rejects := 
+ (1 to: samples size ) reject: [ :each | ((samples at: each) normal - (results at: each)) abs  < 1e-15 asPoint ] .
+ 
+ self assert: ( rejects isEmpty ) .
+ 
+ 
+  
+ !

Item was added:
+ ----- Method: PointTest>>testSign (in category 'testing - testing') -----
+ testSign 
+ 
+ | samples results rejects |
+ samples := 
+ 0 asPoint eightNeighbors 
+ , (Array with: 0 asPoint) .
+ 
+ self shouldnt: [ results :=
+ 				samples collect: [ :each | each sign ] ]
+ 	raise: Error .
+ 	
+ rejects :=
+ (1 to: samples size ) reject: [ :each |
+ 		 (samples at: each) = (results at: each) ] .
+ 
+ self assert: ( rejects isEmpty) 
+ 
+ 
+ !

Item was added:
+ ----- Method: PointTest>>testRotations (in category 'testing - testing') -----
+ testRotations
+ " Here we are testing rightRotated and leftRotated which are new.
+ Because there is really no coverage for point functions this also serves as a tests of sorts for 
+ rotateBy:CenterAt:"
+ 
+ | samples |
+ samples :=
+ 0 asPoint eightNeighbors 
+ , (Array with: 0 asPoint) .
+ 
+ self assert: (samples allSatisfy: [ :each |
+ 	each rightRotated leftRotated = each ] ) .
+ 
+ self assert: (samples allSatisfy: [ :each |
+ 	each rightRotated  = (each rotateBy: #right centerAt: 0 asPoint)] ) .
+ 
+ self assert: (samples allSatisfy: [ :each |
+ 	each leftRotated  = (each rotateBy: #left centerAt: 0 asPoint ) ] ) .
+ 
+ self assert: (samples allSatisfy: [ :each |
+ 	each negated  = (each rotateBy: #pi centerAt: 0 asPoint ) ] ) .
+ 
+ self assert: (samples allSatisfy: [ :each | 
+ 	each leftRotated leftRotated leftRotated leftRotated = each ]) .
+ 
+ self assert: (samples allSatisfy: [ :each |
+ 	each rightRotated rightRotated rightRotated rightRotated  = each ] ) .
+ !

Item was added:
+ ----- Method: PointTest>>testNormal2 (in category 'testing - testing') -----
+ testNormal2
+ " quick check of results for #normal.
+ differs from the other testNormal in the way that the difference is measured."
+ 
+ | samples rejects results differences |
+ 
+ samples :=
+ 0 asPoint eightNeighbors 
+ , (Array with: 0 asPoint) .
+ 
+ results := 
+  { 0.0 at 1.0 
+ . -0.707106781186547 at 0.707106781186547 
+ . -1.0 at 0.0 
+ . -0.707106781186547 at -0.707106781186547 
+ . 0.0 at -1.0 
+ . 0.707106781186547 at -0.707106781186547 
+ . 1.0 at 0.0 
+ . 0.707106781186547 at 0.707106781186547 
+ . -1 at 0} .
+ 
+ differences :=
+ samples with: results collect: [ :each :eachResult |
+ 	each normal - eachResult ] .
+ 
+ rejects := 
+ differences reject: [ :each | 
+ 	(each x closeTo: 0.0) and: [each y closeTo: 0.0] ] .
+ 
+ self assert: ( rejects isEmpty ) .
+ 
+ 
+  
+ !

Item was added:
+ ----- Method: PointTest>>testBasicFourDirections (in category 'testing - testing') -----
+ testBasicFourDirections
+ " fourDirections returns the four rotation of the reciever in counter clockwise order with the reciever appearing last. "
+ 
+ | samples results rejects |
+ 
+ self assert:  (0 asPoint fourDirections) = (Array new: 4 withAll: 0 asPoint) . 
+ 
+ 
+ samples := 
+ 0 asPoint eightNeighbors  .
+ 
+ results := 
+  { {0 at -1 . -1 at 0 . 0 at 1 . 1 at 0} 
+  . {1 at -1 . -1 at -1 . -1 at 1 . 1 at 1}  
+  . {1 at 0 . 0 at -1 . -1 at 0 . 0 at 1}  
+  . {1 at 1 . 1 at -1 . -1 at -1 . -1 at 1}  
+  . {0 at 1 . 1 at 0 . 0 at -1 . -1 at 0}  
+  . {-1 at 1 . 1 at 1 . 1 at -1 . -1 at -1}  
+  . {-1 at 0 . 0 at 1 . 1 at 0 . 0 at -1}  
+  . {-1 at -1 . -1 at 1 . 1 at 1 . 1 at -1} } .
+ 
+ rejects :=
+ (1 to: samples size ) reject: [ :each |
+ 		 (samples at: each) fourDirections = (results at: each) ] .
+ 
+ self assert: ( rejects isEmpty) .
+ 
+ 
+ !

Item was added:
+ ----- Method: PointTest>>testFourDirectionsInvarients (in category 'testing - testing') -----
+ testFourDirectionsInvarients
+ " fourDirections returns the four rotation of the reciever in counter clockwise order with the reciever appearing last. "
+ 
+ | samples  rejects |
+ 
+ samples := 
+ 0 asPoint eightNeighbors  .
+ 
+ rejects :=
+ (1 to: samples size ) reject: [ :each |
+ 		 (samples at: each) fourDirections last = ( samples  at: each) ] .
+ 
+ self assert: ( rejects isEmpty) .
+ 
+ 
+ !

Item was added:
+ ----- Method: PointTest>>testFourDirectionsRotationInvarients (in category 'testing - testing') -----
+ testFourDirectionsRotationInvarients
+ " fourDirections returns the four rotation of the reciever in counter clockwise order with the reciever appearing last. "
+ 
+ | samples  rejects |
+ 
+ samples := 
+ 0 asPoint eightNeighbors  .
+ 
+ rejects :=
+ (1 to: samples size ) reject: [ :each | | answer  |
+ 		(answer :=  (samples at: each) fourDirections ) .
+ 		(1 to: 4) allSatisfy: [ :eachDirIndex | 
+ 			( answer atWrap: eachDirIndex)  leftRotated
+ 					 = (( answer atWrap: eachDirIndex + 1) )  ] ] .
+ 
+ self assert: ( rejects isEmpty) .
+ 
+ 
+ !

Item was added:
+ ----- Method: PointTest>>testZeroPointNormal (in category 'testing - testing') -----
+ testZeroPointNormal
+ "old: normal of zero point raised divide by zero error.
+ new: normal of zero point returns a direction right rotated from zero points direction."
+ 
+ 
+ self shouldnt: [ (0 asPoint normal bearingToPoint: 0 asPoint) = 90 ] raise: Error.  
+ !




More information about the Squeak-dev mailing list