diff options
author | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2007-12-16 22:22:11 +0000 |
---|---|---|
committer | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2007-12-16 22:22:11 +0000 |
commit | f5266a8a1b139e65a366b2ec6534f2ab1bdf8bc0 (patch) | |
tree | 2680a53efd1595a4e6ebd32b7c467e1b89f3a460 /tests/webtbs/tw10425.pp | |
parent | efce2b04e97282bdcce3db1bfd667fe8445033fc (diff) | |
download | fpc-f5266a8a1b139e65a366b2ec6534f2ab1bdf8bc0.tar.gz |
+ new cpo_openequalisexact parameter comparison option which
treats equal open arrays, open strings and arrays of const
(implicitly also open) as exactly matching (since you
cannot declare such types on their own, so they will
never match exactly)
* require that forward declared procedures match the
implementation exactly for both the parameters (with
the above modification) and result type (mantis
#10425 and the related webtbf/tw10425a.pp)
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@9484 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'tests/webtbs/tw10425.pp')
-rw-r--r-- | tests/webtbs/tw10425.pp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/webtbs/tw10425.pp b/tests/webtbs/tw10425.pp new file mode 100644 index 0000000000..96909ee0e8 --- /dev/null +++ b/tests/webtbs/tw10425.pp @@ -0,0 +1,66 @@ +{ %norun } + +unit tw10425; + +{$mode delphi} + +interface + +type + TFloat = double; + TPoint2D = record x,y:TFloat; end; + TRectangle = array [1..2] of TPoint2D; + + TPoint2DArray = array of TPoint2D; + TPolygon2D = array of TPoint2D; + + function AABB(const Polygon : TPolygon2D ):TRectangle; overload; + function AABB(const Curve : TPoint2DArray):TRectangle; overload; + +implementation + +function AABB(const Polygon : TPolygon2D):TRectangle; +var + i : Integer; +begin + Result[1].x := Polygon[0].x; + Result[1].y := Polygon[0].y; + Result[2].x := Polygon[0].x; + Result[2].y := Polygon[0].y; + for i := 1 to Length(Polygon) - 1 do + begin + if Polygon[i].x < Result[1].x then + Result[1].x := Polygon[i].x + else if Polygon[i].x > Result[2].x then + Result[2].x := Polygon[i].x; + if Polygon[i].y < Result[1].y then + Result[1].y := Polygon[i].y + else if Polygon[i].y > Result[2].y then + Result[2].y := Polygon[i].y; + end; +end; + +function AABB(const Curve : TPoint2DArray):TRectangle; +var + i : Integer; +begin + Result[1].x := Curve[0].x; + Result[1].y := Curve[0].y; + Result[2].x := Curve[0].x; + Result[2].y := Curve[0].y; + for i := 1 to Length(Curve) - 1 do + begin + if Curve[i].x < Result[1].x then + Result[1].x := Curve[i].x + else if Curve[i].x > Result[2].x then + Result[2].x := Curve[i].x; + if Curve[i].y < Result[1].y then + Result[1].y := Curve[i].y + else if Curve[i].y > Result[2].y then + Result[2].y := Curve[i].y; + end; +end; + + +end. + |