[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog testsuite/actionscript.all/Make...
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] gnash ChangeLog testsuite/actionscript.all/Make... |
Date: |
Tue, 11 Dec 2007 12:41:31 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Benjamin Wolsey <bwy> 07/12/11 12:41:30
Modified files:
. : ChangeLog
testsuite/actionscript.all: Makefile.am
Added files:
testsuite/actionscript.all: Random.as
Log message:
testsuite/actionscript.all/Random.as: tests for distribution of
(pseudo-)random output, which should catch anything seriously amiss with the
RNG. Also tests correctness of random(n) output.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5129&r2=1.5130
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Makefile.am?cvsroot=gnash&r1=1.82&r2=1.83
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Random.as?cvsroot=gnash&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5129
retrieving revision 1.5130
diff -u -b -r1.5129 -r1.5130
--- ChangeLog 11 Dec 2007 11:34:57 -0000 1.5129
+++ ChangeLog 11 Dec 2007 12:41:30 -0000 1.5130
@@ -1,3 +1,9 @@
+2007-12-11 Benjamin Wolsey <address@hidden>
+
+ * testsuite/actionscript.all/Random.as: tests for distribution
+ of all (pseudo-)random output; and for correctness of random(n)
+ behaviour.
+
2007-12-11 Sandro Santilli <address@hidden>
* server/asobj/string.cpp: fix slice, register native functions,
Index: testsuite/actionscript.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Makefile.am,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -b -r1.82 -r1.83
--- testsuite/actionscript.all/Makefile.am 10 Dec 2007 23:17:19 -0000
1.82
+++ testsuite/actionscript.all/Makefile.am 11 Dec 2007 12:41:30 -0000
1.83
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# $Id: Makefile.am,v 1.82 2007/12/10 23:17:19 strk Exp $
+# $Id: Makefile.am,v 1.83 2007/12/11 12:41:30 bwy Exp $
AUTOMAKE_OPTIONS = dejagnu
@@ -92,6 +92,7 @@
MovieClipLoader.as \
NetStream.as \
Number.as \
+ Random.as \
Selection.as \
SharedObject.as \
Stage.as \
Index: testsuite/actionscript.all/Random.as
===================================================================
RCS file: testsuite/actionscript.all/Random.as
diff -N testsuite/actionscript.all/Random.as
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/actionscript.all/Random.as 11 Dec 2007 12:41:30 -0000
1.1
@@ -0,0 +1,144 @@
+//
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// 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; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+//
+// Tests for random behaviour. This tests only the randomness of the output
+// and the range of results. Tests for Math.random() actionscript correctness
+// are in Math.as.
+//
+// compile this test case with Ming makeswf, and then
+// execute it like this gnash -1 -r 0 -v out.swf
+
+// For obvious reasons, tests of randomness can fail even if there is
+// nothing wrong (though with carefully-designed pseudo-randomness this
+// is very unlikely). The chance of a failure is very small if Gnash
+// is working correctly.
+
+#include "check.as"
+
+// Number of random numbers to generate.
+var max = 1000;
+
+/*
+Tests for random(n).
+
+This AS function should return an integer from 0 up to but not
+including n.
+*/
+
+// With n = integer (how it should be used...)
+var tally = array();
+
+for (i = 0; i < max; i++)
+{
+ tally[random(4)] += 1;
+}
+
+// Check proportion of each number exceeds 10%; should be about
+// 25%.
+check (tally[0] > max / 10);
+check (tally[1] > max / 10);
+check (tally[2] > max / 10);
+check (tally[3] > max / 10);
+
+check_equals(typeof(tally[4]), "undefined"); // Should not exist
+
+// With n = non-integer
+
+var tally = array();
+for (i = 0; i < max; i++)
+{
+ tally[random(4.5)] += 1;
+}
+
+// Check proportion of each number exceeds 10%; should be about
+// 25%.
+check (tally[0] > max / 10);
+check (tally[1] > max / 10);
+check (tally[2] > max / 10);
+check (tally[3] > max / 10);
+
+check_equals(typeof(tally[4]), "undefined"); // Should not exist
+
+// With n = negative number
+
+var tally = array();
+for (i = 0; i < max / 5; i++)
+{
+ tally[random(-1)] += 1;
+}
+
+check_equals (tally[0], max / 5 );
+check_equals(typeof(tally[1]), "undefined"); // Should not exist
+
+/*
+
+Tests for Math.random()
+
+Returns double n where 0 <= n < 1.
+
+*/
+
+
+// Note: test also relies on Math.round()!
+var tally = array();
+
+for (i = 0; i < max; i++)
+{
+ rnd = Math.round(Math.random() * 10 + 0.5);
+ tally[rnd] += 1;
+}
+
+check_equals(typeof(tally[0]), "undefined"); // Should not exist
+note(tally[0]);
+
+check (tally[1] > max / 20);
+note(tally[1]);
+
+check (tally[2] > max / 20);
+note(tally[2]);
+
+check (tally[3] > max / 20);
+note(tally[3]);
+
+check (tally[4] > max / 20);
+note(tally[4]);
+
+check (tally[5] > max / 20);
+note(tally[5]);
+
+check (tally[6] > max / 20);
+note(tally[6]);
+
+check (tally[7] > max / 20);
+note(tally[7]);
+
+check (tally[8] > max / 20);
+note(tally[8]);
+
+check (tally[9] > max / 20);
+note(tally[9]);
+
+check (tally[10] > max / 20);
+note(tally[10]);
+
+check_equals(typeof(tally[11]), "undefined"); // Should not exist
+note(tally[11]);
+
+/* End of tests */
+check_totals(24);
+totals();