The Trunk: GraphicsTests-nice.24.mcz

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

The Trunk: GraphicsTests-nice.24.mcz

commits-2
Nicolas Cellier uploaded a new version of GraphicsTests to project The Trunk:
http://source.squeak.org/trunk/GraphicsTests-nice.24.mcz

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

Name: GraphicsTests-nice.24
Author: nice
Time: 20 June 2010, 11:05:21.594 pm
UUID: d6cc2cfd-2790-344f-bc46-9a82f91a88dd
Ancestors: GraphicsTests-wiz.23

A few more tests of Rectangle functions, including behaviour of empty rectangles

=============== Diff against GraphicsTests-wiz.23 ===============

Item was added:
+ ----- Method: RectangleTest>>testCenterEmpty (in category 'testing') -----
+ testCenterEmpty
+ | r1 c |
+ r1 := 30@10 corner: 10@20.
+ c := r1 center.
+ self deny: (r1 containsPoint: c) description: 'An empty rectangle does not contain any point.'.
+ self assert: (r1 topLeft dist: c) = (r1 bottomRight dist: c).
+ self assert: (r1 bottomLeft dist: c) = (r1 topRight dist: c).
+ self assert: (r1 topLeft dist: c) = (r1 bottomLeft dist: c).
+ self assert: (r1 translateBy: -20@10) center = (c translateBy: -20@10) description: 'the center is translated with the rectangle'.!

Item was added:
+ ----- Method: RectangleTest>>testFlipEmpty (in category 'testing') -----
+ testFlipEmpty
+ | r1 c r1Horiz r1Vert |
+ r1 := 30@10 corner: 10@20.
+ c := 5@5.
+ r1Horiz := r1 flipBy: #horizontal centerAt: c.
+ r1Vert := r1 flipBy: #vertical centerAt: c.
+
+ self assert: r1 area = r1Horiz area description: 'flip preserves area'.
+ self assert: r1 area = r1Vert area description: 'flip preserves area'.
+
+ self assert: r1 extent = r1Horiz extent description: 'flip preserves extent'.
+ self assert: r1 extent = r1Vert extent description: 'flip preserves extent'.
+
+ self assert:  (r1 flipBy: #horizontal centerAt: r1 center) = r1.
+ self assert:  (r1 flipBy: #vertical centerAt: r1 center) = r1!

Item was added:
+ ----- Method: RectangleTest>>testFlip (in category 'testing') -----
+ testFlip
+ | r1 c r1Horiz r1Vert |
+ r1 := 30@10 extent: 10@20.
+ c := 5@5.
+ r1Horiz := r1 flipBy: #horizontal centerAt: c.
+ r1Vert := r1 flipBy: #vertical centerAt: c.
+
+ self assert: r1 area = r1Horiz area description: 'flip preserves area'.
+ self assert: r1 area = r1Vert area description: 'flip preserves area'.
+
+ self assert: r1 extent = r1Horiz extent description: 'flip preserves extent'.
+ self assert: r1 extent = r1Vert extent description: 'flip preserves extent'.
+
+ self assert:  (r1 flipBy: #horizontal centerAt: r1 center) = r1.
+ self assert:  (r1 flipBy: #vertical centerAt: r1 center) = r1!

Item was added:
+ ----- Method: RectangleTest>>testArea (in category 'testing') -----
+ testArea
+ | r1 empty |
+ r1 := 0@0 extent: 10@20.
+ self assert: r1 area = (10*20).
+ self assert: (r1 translateBy: -20@10) area = (10*20) description: 'translation preserves area'.
+
+ empty := 10@20 corner: 0@0.
+ self assert: empty area = 0 description: 'the area of an empty rectangle is null'.
+ empty := 10@0 corner: 0@20.
+ self assert: empty area = 0 description: 'the area of an empty rectangle is null'.
+ empty := 0@20 corner: 10@0.
+ self assert: empty area = 0 description: 'the area of an empty rectangle is null'.!

Item was added:
+ ----- Method: RectangleTest>>testRotateEmpty (in category 'testing') -----
+ testRotateEmpty
+ | r1 c r1Left r1Right r1Pi |
+ r1 := 30@10 corner: 10@20.
+ c := 5@5.
+ r1Left := r1 rotateBy: #left centerAt: c.
+ r1Right := r1 rotateBy: #right centerAt: c.
+ r1Pi := r1 rotateBy: #pi centerAt: c.
+
+ self assert: r1 area = r1Left area description: 'rotation preserves area'.
+ self assert: r1 area = r1Right area description: 'rotation preserves area'.
+ self assert: r1 area = r1Pi area description: 'rotation preserves area'.
+
+ self assert: r1 extent transposed = r1Left extent.
+ self assert: r1 extent transposed = r1Right extent.
+ self assert: r1 extent = r1Pi extent.
+
+ self assert:  (r1 rotateBy: #pi centerAt: r1 center) = r1!

Item was added:
+ ----- Method: RectangleTest>>testCenter (in category 'testing') -----
+ testCenter
+ | r1 c |
+ r1 := 0@0 extent: 10@20.
+ c := r1 center.
+ self assert: (r1 containsPoint: c) description: 'the center is inside the rectangle'.
+ self assert: (r1 topLeft dist: c) = (r1 bottomRight dist: c).
+ self assert: (r1 bottomLeft dist: c) = (r1 topRight dist: c).
+ self assert: (r1 topLeft dist: c) = (r1 bottomLeft dist: c).
+ self assert: (r1 translateBy: -20@10) center = (c translateBy: -20@10) description: 'the center is translated with the rectangle'.!

Item was added:
+ ----- Method: RectangleTest>>testRotate (in category 'testing') -----
+ testRotate
+ | r1 c r1Left r1Right r1Pi |
+ r1 := 30@10 extent: 10@20.
+ c := 5@5.
+ r1Left := r1 rotateBy: #left centerAt: c.
+ r1Right := r1 rotateBy: #right centerAt: c.
+ r1Pi := r1 rotateBy: #pi centerAt: c.
+
+ self assert: r1 area = r1Left area description: 'rotation preserves area'.
+ self assert: r1 area = r1Right area description: 'rotation preserves area'.
+ self assert: r1 area = r1Pi area description: 'rotation preserves area'.
+
+ self assert: r1 extent transposed = r1Left extent.
+ self assert: r1 extent transposed = r1Right extent.
+ self assert: r1 extent = r1Pi extent.
+
+ self assert:  (r1 rotateBy: #pi centerAt: r1 center) = r1!

Item was added:
+ ----- Method: RectangleTest>>testIntersectionEmpty (in category 'testing') -----
+ testIntersectionEmpty
+ | rect1 empty1 empty2 |
+ rect1 := 10@10 corner: 40@40.
+ empty1 := 50@50 corner: 0@0.
+ empty2 := 30@30 corner: 20@20.
+ self
+ deny: (rect1 intersects: empty1);
+ deny: (rect1 intersects: empty2);
+ deny: (empty1 intersects: rect1);
+ deny: (empty2 intersects: rect1);
+ deny: (empty1 intersects: empty2);
+ deny: (empty2 intersects: empty1).!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: GraphicsTests-nice.24.mcz

Nicolas Cellier
Oops, wanted to publish to inbox...
Feel free to remove the tests for empty rectangle behaviour if you don't agree.

Nicolas

2010/6/20  <[hidden email]>:

> Nicolas Cellier uploaded a new version of GraphicsTests to project The Trunk:
> http://source.squeak.org/trunk/GraphicsTests-nice.24.mcz
>
> ==================== Summary ====================
>
> Name: GraphicsTests-nice.24
> Author: nice
> Time: 20 June 2010, 11:05:21.594 pm
> UUID: d6cc2cfd-2790-344f-bc46-9a82f91a88dd
> Ancestors: GraphicsTests-wiz.23
>
> A few more tests of Rectangle functions, including behaviour of empty rectangles
>
> =============== Diff against GraphicsTests-wiz.23 ===============
>
> Item was added:
> + ----- Method: RectangleTest>>testCenterEmpty (in category 'testing') -----
> + testCenterEmpty
> +       | r1 c |
> +       r1 := 30@10 corner: 10@20.
> +       c := r1 center.
> +       self deny: (r1 containsPoint: c) description: 'An empty rectangle does not contain any point.'.
> +       self assert: (r1 topLeft dist: c) = (r1 bottomRight dist: c).
> +       self assert: (r1 bottomLeft dist: c) = (r1 topRight dist: c).
> +       self assert: (r1 topLeft dist: c) = (r1 bottomLeft dist: c).
> +       self assert: (r1 translateBy: -20@10) center = (c translateBy: -20@10) description: 'the center is translated with the rectangle'.!
>
> Item was added:
> + ----- Method: RectangleTest>>testFlipEmpty (in category 'testing') -----
> + testFlipEmpty
> +       | r1 c r1Horiz r1Vert |
> +       r1 := 30@10 corner: 10@20.
> +       c := 5@5.
> +       r1Horiz := r1 flipBy: #horizontal centerAt: c.
> +       r1Vert := r1 flipBy: #vertical centerAt: c.
> +
> +       self assert: r1 area = r1Horiz area description: 'flip preserves area'.
> +       self assert: r1 area = r1Vert area description: 'flip preserves area'.
> +
> +       self assert: r1 extent = r1Horiz extent description: 'flip preserves extent'.
> +       self assert: r1 extent = r1Vert extent description: 'flip preserves extent'.
> +
> +       self assert:  (r1 flipBy: #horizontal centerAt: r1 center) = r1.
> +       self assert:  (r1 flipBy: #vertical centerAt: r1 center) = r1!
>
> Item was added:
> + ----- Method: RectangleTest>>testFlip (in category 'testing') -----
> + testFlip
> +       | r1 c r1Horiz r1Vert |
> +       r1 := 30@10 extent: 10@20.
> +       c := 5@5.
> +       r1Horiz := r1 flipBy: #horizontal centerAt: c.
> +       r1Vert := r1 flipBy: #vertical centerAt: c.
> +
> +       self assert: r1 area = r1Horiz area description: 'flip preserves area'.
> +       self assert: r1 area = r1Vert area description: 'flip preserves area'.
> +
> +       self assert: r1 extent = r1Horiz extent description: 'flip preserves extent'.
> +       self assert: r1 extent = r1Vert extent description: 'flip preserves extent'.
> +
> +       self assert:  (r1 flipBy: #horizontal centerAt: r1 center) = r1.
> +       self assert:  (r1 flipBy: #vertical centerAt: r1 center) = r1!
>
> Item was added:
> + ----- Method: RectangleTest>>testArea (in category 'testing') -----
> + testArea
> +       | r1 empty |
> +       r1 := 0@0 extent: 10@20.
> +       self assert: r1 area = (10*20).
> +       self assert: (r1 translateBy: -20@10) area = (10*20) description: 'translation preserves area'.
> +
> +       empty := 10@20 corner: 0@0.
> +       self assert: empty area = 0 description: 'the area of an empty rectangle is null'.
> +       empty := 10@0 corner: 0@20.
> +       self assert: empty area = 0 description: 'the area of an empty rectangle is null'.
> +       empty := 0@20 corner: 10@0.
> +       self assert: empty area = 0 description: 'the area of an empty rectangle is null'.!
>
> Item was added:
> + ----- Method: RectangleTest>>testRotateEmpty (in category 'testing') -----
> + testRotateEmpty
> +       | r1 c r1Left r1Right r1Pi |
> +       r1 := 30@10 corner: 10@20.
> +       c := 5@5.
> +       r1Left := r1 rotateBy: #left centerAt: c.
> +       r1Right := r1 rotateBy: #right centerAt: c.
> +       r1Pi := r1 rotateBy: #pi centerAt: c.
> +
> +       self assert: r1 area = r1Left area description: 'rotation preserves area'.
> +       self assert: r1 area = r1Right area description: 'rotation preserves area'.
> +       self assert: r1 area = r1Pi area description: 'rotation preserves area'.
> +
> +       self assert: r1 extent transposed = r1Left extent.
> +       self assert: r1 extent transposed = r1Right extent.
> +       self assert: r1 extent = r1Pi extent.
> +
> +       self assert:  (r1 rotateBy: #pi centerAt: r1 center) = r1!
>
> Item was added:
> + ----- Method: RectangleTest>>testCenter (in category 'testing') -----
> + testCenter
> +       | r1 c |
> +       r1 := 0@0 extent: 10@20.
> +       c := r1 center.
> +       self assert: (r1 containsPoint: c) description: 'the center is inside the rectangle'.
> +       self assert: (r1 topLeft dist: c) = (r1 bottomRight dist: c).
> +       self assert: (r1 bottomLeft dist: c) = (r1 topRight dist: c).
> +       self assert: (r1 topLeft dist: c) = (r1 bottomLeft dist: c).
> +       self assert: (r1 translateBy: -20@10) center = (c translateBy: -20@10) description: 'the center is translated with the rectangle'.!
>
> Item was added:
> + ----- Method: RectangleTest>>testRotate (in category 'testing') -----
> + testRotate
> +       | r1 c r1Left r1Right r1Pi |
> +       r1 := 30@10 extent: 10@20.
> +       c := 5@5.
> +       r1Left := r1 rotateBy: #left centerAt: c.
> +       r1Right := r1 rotateBy: #right centerAt: c.
> +       r1Pi := r1 rotateBy: #pi centerAt: c.
> +
> +       self assert: r1 area = r1Left area description: 'rotation preserves area'.
> +       self assert: r1 area = r1Right area description: 'rotation preserves area'.
> +       self assert: r1 area = r1Pi area description: 'rotation preserves area'.
> +
> +       self assert: r1 extent transposed = r1Left extent.
> +       self assert: r1 extent transposed = r1Right extent.
> +       self assert: r1 extent = r1Pi extent.
> +
> +       self assert:  (r1 rotateBy: #pi centerAt: r1 center) = r1!
>
> Item was added:
> + ----- Method: RectangleTest>>testIntersectionEmpty (in category 'testing') -----
> + testIntersectionEmpty
> +       | rect1 empty1 empty2 |
> +       rect1 := 10@10 corner: 40@40.
> +       empty1 := 50@50 corner: 0@0.
> +       empty2 := 30@30 corner: 20@20.
> +       self
> +               deny: (rect1 intersects: empty1);
> +               deny: (rect1 intersects: empty2);
> +               deny: (empty1 intersects: rect1);
> +               deny: (empty2 intersects: rect1);
> +               deny: (empty1 intersects: empty2);
> +               deny: (empty2 intersects: empty1).!
>
>
>