mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-05-14 04:35:03 +00:00
Test order is randomized
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user