[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash/testsuite/actionscript.all Random.as
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] gnash/testsuite/actionscript.all Random.as |
Date: |
Tue, 11 Dec 2007 14:32:57 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Benjamin Wolsey <bwy> 07/12/11 14:32:57
Modified files:
testsuite/actionscript.all: Random.as
Log message:
That's sorted it; "tally[0] += 1;" doesn't work in SWF7 or above if
tally[0] is undefined.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Random.as?cvsroot=gnash&r1=1.3&r2=1.4
Patches:
Index: Random.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Random.as,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- Random.as 11 Dec 2007 12:55:13 -0000 1.3
+++ Random.as 11 Dec 2007 14:32:56 -0000 1.4
@@ -30,8 +30,6 @@
#include "check.as"
-#if OUTPUT_VERSION <= 6
-
// Number of random numbers to generate.
var max = 1000;
@@ -43,11 +41,13 @@
*/
// With n = integer (how it should be used...)
-var tally = array();
+var tally = new Array();
-for (i = 0; i < max; i++)
+for (var i = 0; i < max; i++)
{
- tally[random(4)] += 1;
+ rnd = random(4);
+ if (typeof(tally[rnd]) == "undefined") { tally[rnd] = 0; }
+ tally[rnd] += 1;
}
// Check proportion of each number exceeds 10%; should be about
@@ -61,10 +61,12 @@
// With n = non-integer
-var tally = array();
-for (i = 0; i < max; i++)
+var tally = new Array();
+for (var i = 0; i < max; i++)
{
- tally[random(4.5)] += 1;
+ rnd = random(4.5);
+ if (typeof(tally[rnd]) == "undefined") { tally[rnd] = 0; }
+ tally[rnd] += 1;
}
// Check proportion of each number exceeds 10%; should be about
@@ -78,10 +80,12 @@
// With n = negative number
-var tally = array();
-for (i = 0; i < max / 5; i++)
+var tally = new Array();
+for (var i = 0; i < max / 5; i++)
{
- tally[random(-1)] += 1;
+ rnd = random(-1);
+ if (typeof(tally[rnd]) == "undefined") { tally[rnd] = 0; }
+ tally[rnd] += 1;
}
check_equals (tally[0], max / 5 );
@@ -97,11 +101,12 @@
// Note: test also relies on Math.round()!
-var tally = array();
+var tally = new Array();
for (i = 0; i < max; i++)
{
rnd = Math.round(Math.random() * 10 + 0.5);
+ if (typeof(tally[rnd]) == "undefined") { tally[rnd] = 0; }
tally[rnd] += 1;
}
@@ -143,6 +148,3 @@
/* End of tests */
check_totals(24);
-totals();
-
-#endif // OUTPUT_VERSION <= 6