diff --git a/testsuite/actionscript.all/Makefile.am b/testsuite/actionscript.all/Makefile.am index 9c78a4d..40d857b 100644 --- a/testsuite/actionscript.all/Makefile.am +++ b/testsuite/actionscript.all/Makefile.am @@ -134,6 +134,7 @@ ASTESTS = \ caseconv.as \ ops.as \ toString_valueOf.as \ + toRoundString.as \ Rectangle.as \ argstest.as \ $(NULL) diff --git a/testsuite/actionscript.all/Matrix.as b/testsuite/actionscript.all/Matrix.as index 1acda9e..803cfe1 100644 --- a/testsuite/actionscript.all/Matrix.as +++ b/testsuite/actionscript.all/Matrix.as @@ -31,6 +31,7 @@ rcsid="Matrix.as"; // // A ming bug up to version 0.4 beta 5 makes very large numbers fail. #include "check.as" +#include "toRoundString.as" ASSetPropFlags (_global, "flash", 0, 5248); @@ -269,11 +270,13 @@ check_equals(m6.toString(), "(a=3.51033024756149, b=6.78504050247288, c=-1.91770 // Matrix.transformPoint (and deltaTransformPoint again) p = new Point(23, 95); p2 = m6.transformPoint(p); -check_equals(p2.toString(), "(x=-99.4441089756828, y=348.180517617807)"); +check_equals(toRoundString(p2.x,13), "-99.4441089756828"); +check_equals(toRoundString(p2.y,12), "348.180517617807"); p3 = m6.deltaTransformPoint(p); check_equals(p3.toString(), "(x=-101.444108975683, y=345.180517617807)"); p2 = m6.transformPoint(p2); -check_equals(p2.toString(), "(x=-1014.78819244077, y=21.420285172384)"); +check_equals(toRoundString(p2.x,11), "-1014.78819244077"); +check_equals(toRoundString(p2.y,12), "21.420285172384"); // Transforming points with a fake matrix. fakematrix = {a:3, b:2, c: 5, d: 3, tx:5, ty: 5}; @@ -409,9 +412,9 @@ check_equals(fakematrix.ty.toString(), undefined); // END OF TEST //------------------------------------------------------------- #if MING_VERSION_CODE > 00040005 -totals(162); +totals(164); #else -totals(153); +totals(155); #endif #endif // OUTPUT_VERSION >= 8 diff --git a/testsuite/actionscript.all/toRoundString.as b/testsuite/actionscript.all/toRoundString.as new file mode 100644 index 0000000..3c14434 --- /dev/null +++ b/testsuite/actionscript.all/toRoundString.as @@ -0,0 +1,28 @@ +// +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modchecky +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; check not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fcheckth Floor, Boston, MA 02110-1301 USA +// + +rcsid="toRoundString.as"; +#include "check.as" + +function toRoundString(num:Number, precision:Number):String +{ + var decimalPlaces:Number = Math.pow(10, precision); + trace(Math.round(decimalPlaces * num)/decimalPlaces); + a = Math.round(decimalPlaces * num)/decimalPlaces; + return a.toString(); +}