summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/math-random.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/basic/math-random.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/basic/math-random.js')
-rw-r--r--js/src/jit-test/tests/basic/math-random.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/math-random.js b/js/src/jit-test/tests/basic/math-random.js
new file mode 100644
index 000000000..e9efab588
--- /dev/null
+++ b/js/src/jit-test/tests/basic/math-random.js
@@ -0,0 +1,43 @@
+function test() {
+ setRNGState(0x12341234, 0x98765);
+
+ function f() {
+ let x = [];
+ for (let i = 0; i < 10000; i++) {
+ x.push(Math.random());
+ }
+ return x;
+ }
+ let x = f();
+ assertEq(x[0], 0.28443027522441433);
+ assertEq(x[10], 0.5283908544644392);
+ assertEq(x[100], 0.5593668121538891);
+ assertEq(x[1000], 0.7008807796441313);
+ assertEq(x[2000], 0.11737403776989574);
+ assertEq(x[3000], 0.08573924080320472);
+ assertEq(x[4000], 0.22428965439295678);
+ assertEq(x[5000], 0.4657521920883555);
+ assertEq(x[6000], 0.11816220100329233);
+ assertEq(x[7000], 0.6306689010335697);
+ assertEq(x[8000], 0.8654862148946609);
+ assertEq(x[9000], 0.31734259460387015);
+ assertEq(x[9999], 0.013959566914027777);
+
+ // Test some other (arbitrary) seeds.
+ setRNGState(0, 1);
+ x = f();
+ assertEq(x[0], 2.220446049250313e-16);
+ assertEq(x[2000], 0.8259328082050756);
+ assertEq(x[6000], 0.01060492365550314);
+ assertEq(x[9999], 0.7402370773147143);
+
+ setRNGState(0x0fff0101, 0x44440001);
+ x = f();
+ assertEq(x[0], 0.24994062119568194);
+ assertEq(x[2000], 0.4375430448883283);
+ assertEq(x[6000], 0.7298689950209452);
+ assertEq(x[9999], 0.13284280897626954);
+}
+
+if (typeof setRNGState == "function")
+ test();