]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Test order is randomized
authorIan Coleman <coleman.ian@gmail.com>
Tue, 23 Aug 2016 08:25:38 +0000 (18:25 +1000)
committerIan Coleman <coleman.ian@gmail.com>
Tue, 23 Aug 2016 08:25:38 +0000 (18:25 +1000)
tests.js

index a04137f84d4205eea1917a9168964e8e8b5f2227..bacaec008d44ec1e8b06c985214169034d98396e 100644 (file)
--- a/tests.js
+++ b/tests.js
@@ -56,6 +56,21 @@ function next() {
     }
 }
 
+/**
+ * Randomize array element order in-place.
+ * Using Durstenfeld shuffle algorithm.
+ * See http://stackoverflow.com/a/12646864
+ */
+function shuffle(array) {
+    for (var i = array.length - 1; i > 0; i--) {
+        var j = Math.floor(Math.random() * (i + 1));
+        var temp = array[i];
+        array[i] = array[j];
+        array[j] = temp;
+    }
+    return array;
+}
+
 tests = [
 
 // Page loads with status of 'success'
@@ -602,4 +617,5 @@ page.open(url, function(status) {
 ];
 
 console.log("Running tests...");
+tests = shuffle(tests);
 next();