diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2016-08-23 18:25:38 +1000 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2016-08-23 18:25:38 +1000 |
commit | fb3726873f9dd6d7319388a1a5e472042098248b (patch) | |
tree | 5c2133c7b08b88d16b27396366ddb02519a48aa3 | |
parent | d077e1e71643798614f66652509ca3a409e530a8 (diff) | |
download | BIP39-fb3726873f9dd6d7319388a1a5e472042098248b.tar.gz BIP39-fb3726873f9dd6d7319388a1a5e472042098248b.tar.zst BIP39-fb3726873f9dd6d7319388a1a5e472042098248b.zip |
Test order is randomized
-rw-r--r-- | tests.js | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -56,6 +56,21 @@ function next() { | |||
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | /** | ||
60 | * Randomize array element order in-place. | ||
61 | * Using Durstenfeld shuffle algorithm. | ||
62 | * See http://stackoverflow.com/a/12646864 | ||
63 | */ | ||
64 | function shuffle(array) { | ||
65 | for (var i = array.length - 1; i > 0; i--) { | ||
66 | var j = Math.floor(Math.random() * (i + 1)); | ||
67 | var temp = array[i]; | ||
68 | array[i] = array[j]; | ||
69 | array[j] = temp; | ||
70 | } | ||
71 | return array; | ||
72 | } | ||
73 | |||
59 | tests = [ | 74 | tests = [ |
60 | 75 | ||
61 | // Page loads with status of 'success' | 76 | // Page loads with status of 'success' |
@@ -602,4 +617,5 @@ page.open(url, function(status) { | |||
602 | ]; | 617 | ]; |
603 | 618 | ||
604 | console.log("Running tests..."); | 619 | console.log("Running tests..."); |
620 | tests = shuffle(tests); | ||
605 | next(); | 621 | next(); |